XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
victor pascowSubject: FOR EACH
Author: victor pascow
Date: 07 Mar 2007 11:41 AM
Trying to establish a for-each statement. For example:

<element>
<url>xxx.com</url
<title>xxx</title>
<category>
<thiscategory>one/two/three/four</thiscategory>
</category>
</element>

<element>
<url>xxx.com</url
<title>xxx</title>
<category>
<thiscategory>a/b/c/d</thiscategory>
</category>
</element>



My for-each statement is not working, however.

<xsl:template match="element">
<xsl:for-each select="category/[thiscategory='a/b/c/d']">


I think the slashes are of issue.

I'm getting:
A location step was expected following the '/' or '//' token. [109] null

Any help?



Postnext
(Deleted User) Subject: Re: FOR EACH
Author: (Deleted User)
Date: 07 Mar 2007 11:51 AM
Hi Victor,
the correct XPath is "category[thiscategory='a/b/c/d']" (no / before the [)

Alberto

Postnext
victor pascowSubject: Re: FOR EACH
Author: victor pascow
Date: 07 Mar 2007 12:24 PM
Great! I love those little mistakes.

However, still running into an issue:


My display will now not yield anything.

<xsl:template match="element">
<xsl:for-each select="category[thiscategory='a/b/c/d']">
<xsl:value-of select="URL"/>
</xsl:for-each>
</xsl:template>


Thanks again.

Posttop
(Deleted User) Subject: Re: FOR EACH
Author: (Deleted User)
Date: 07 Mar 2007 12:37 PM
Victor,
once you iterate over all those "category" objects, there is no "URL"
child to select.
If you want to get to the "url" sibling element, you need to write "../url".

Alberto

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.