[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Help with staregies for outputting an incremental number in xslt


Subject: Re: [xsl] Help with staregies for outputting an incremental number in xslt
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Thu, 29 Nov 2007 09:27:15 -0800

I've found myself having to use result tree fragments so that I would
be able to make use of xsl:key/fn:key.  The spec seems to indicate
this is necessary, that it can't work on pointers into the document.
Am I correct?

The reason I sometimes like to use xsl:key/fn:key on a variable which
is pointing to an existing document is that it is easier to write an
xsl:key statement which is readily understandable, and then restrict
the scope of the key lookup by pointing to a subsection of the documnet.

The number of times I've seen people caution against using result tree
fragments makes me wonder if it would in fact be recommended to just
write the more complicated xsl:key statement, even if it strikes me as
being less legible.  I suppose it's the standard trade off between time,
space, and legibility!

>>>    <xsl:variable name="description">
>>>      <xsl:value-of select="../../expensys:ItemDescription"/>
>>>    </xsl:variable>
>>>
>>> when you mean this:
>>>
>>>    <xsl:variable name="description"
>>> select="../../expensys:ItemDescription"/>
> 
> The first one builds a result tree fragment consisting of a document node
> and a text node, whose value is a copy of the text of an existing node. The
> second one is (a pointer to) an existing node. Creating new nodes and
> copying text is expensive, and in this case is quite unnecessary.
> 
> Michael Kay
> http://www.saxonica.com/

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press      http://highwire.stanford.edu/
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)


Current Thread