wrong XPath expression

Sebastian Kerekes

Usenet Archive
Joined
Sep 1, 2004
Messages
16
Reaction score
0
Hi,

executing this code ..

<select name="language" class="v1">
<xsl:for-each select="/document/select[@ref = 'language']/item"> <option value="{value/text}"> <xsl:value-of select="text"/> </option> </xsl:for-each> </select>

... results in this:

<select class="v1" name="language">
<option value="de"></option>
<option value="en"></option>
</select>

Obviously <xsl:value-of select="text"/> is wrong. I want to access the text of of the item-nodes. How can I solve that?

Thx in advance,

Sebastian
 

Kenneth Stephen

Usenet Archive
Joined
Dec 29, 2003
Messages
36
Reaction score
0
Sebastian said:
Hi,

executing this code ..

<select name="language" class="v1">
<xsl:for-each select="/document/select[@ref = 'language']/item"> <option value="{value/text}"> <xsl:value-of select="text"/> </option> </xsl:for-each> </select>
Sebastian,

What does the input XML fragment that you are running this on look like?

Regards,
Kenneth
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
[...]

% <xsl:value-of select="text"/>

This will retrieve the value of text nodes which are immediate children of the current node (in this case, the node being considered by the for-each).

What you want to do is cast the current node to a string. As it happens, this is precisely what value-of does, so you could just use

<xsl:value-of select="."/>

but this explicit should also do what you want

<xsl:value-of select="string(.)"/>

In either case, the value that gets copied to the result tree is the concatenation of all text nodes which are descendents of the current node.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top