Monday, January 25, 2010

Ward Lab Five Answers

When accessing elements of a nodeset by [x] data type of x eighth

sometimes hide mistakes very well. In the following code to such an error has hidden:

...
\u0026lt;xsl:variable name="position">
\u0026lt;xsl: value-of select = "count (preceding:: bar) +1" / xsl>
\u0026lt;/: variable>
\u0026lt;xsl:apply-templates select="$my-node-set[$position]"/>
...

The code above is to count the number of bar elements, and then from the node set $ node-set my-element process, that at the position is equal to the number of bar elements.

of the variable "position" might be assumed initially that it would represent a figure. As you notice when you run the code ', but this is not the case. It is from the variable $ my-node-set is always the first node selected.

fact, position of type string and must be before it can be used with [] are transformed into a number. This is right:

...

\u0026lt;xsl:variable name="position">
\u0026lt;xsl: value-of select = "count (preceding:: bar) +1 "/>
\u0026lt;/ xsl: variable>
\u0026lt;xsl:apply-templates select="$my-node-set[ number($position) ]"/>
. ..


with number () is from the string a number and then flips up to access the node in the nodeset at the desired location.

0 comments:

Post a Comment