xsl-list
[Top] [All Lists]

RE: [xsl] More addition questions: Using node-set()

2007-10-11 07:37:19
E.g., if I get a result fragment tree(by doing something like 
//a meaning get all the elements that are needed),

The expression //a returns a node-set. You will only get a result tree
fragment if you construct one by copying the elements, for example

<xsl:variable name="x">
  <xsl:copy-of select="//a"/>
</xsl:variable>

 convert it to a
node-set() and then use it, and I do this 2-3 times for 
different problem sets in say the same template, isn't there 
a lot of redunancy going on?

It depends on the processor. In some processors the xx:node-set() function
is essentially a no-op, all it does it signal to the processor that you
don't want it to enforce the restrictions on use of result tree fragments.

However, you should avoid copying nodes when you don't need to. Many people
make the mistake of using variables-that-create-trees, like the above, when
they could and should be using variables-that-select-nodes, like
<xsl:variable select="//a"/>.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--