xsl-list
[Top] [All Lists]

RE: code review

2004-02-21 14:42:05
-----Original Message-----
From: Theresa Devine

I was wondering if ya'll might review my xslt and see if there is a more
efficient way of doing this transformation. The part I have questions
about is the search and replace....


Hi,

Given your example source document, what exactly do you mean by 'the
occurrence of the schoolname and other info is unpredictable'? That it can
contain quotes, so you need to *first* replace the info, and perform a
subsequent replacement on the result?

*If* you are permitted to, as Jim suggested, change these #...# to simple
empty XML elements, like <data name="..." />.
In your stylesheet, you could then define a template as simple as:

<xsl:template match="data">
  <xsl:value-of select="resstr[name()=current()/@name]" />
</xsl:template>

to handle all possible replacements for you. The resstr being a ref to an
XML structure containing your replacement strings (--IOW a variable wrapper
around your params?)

And (--but maybe that's no real boost in efficiency, not sure)


<xsl:template match="BodyText/Title">
      <xsl:if test="../@sycampusid=$sycampusid">

In such scenarios, I usually make either the select or the match pattern for
the template contain the condition, so for example, delete the xsl:if and do
higher up:

<xsl:apply-templates select="BodyText[(_at_)sycampusid=$sycampusid]/*">

Saves you a few times of invoking the template for which the condition isn't
true to begin with...

Hope this helps!

Cheers,

Andreas


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>