Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > wrong XPath expression

Reply
Thread Tools

wrong XPath expression

 
 
Sebastian Kerekes
Guest
Posts: n/a
 
      09-13-2004
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
 
Reply With Quote
 
 
 
 
Kenneth Stephen
Guest
Posts: n/a
 
      09-13-2004
Sebastian Kerekes wrote:

> 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
 
Reply With Quote
 
 
 
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      09-14-2004
In article <(E-Mail Removed)>,
Sebastian Kerekes <(E-Mail Removed)> wrote:

[...]

% <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.
--

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
What am I doing wrong in this XPath expression? steve bull XML 7 06-20-2005 09:27 AM
using variable as attribute in xpath expression - wrong group? KathyB ASP .Net 0 06-30-2003 11:05 PM



Advertisments