Subject: Re: [xsl] two nodes are iterating From: Mike Brown <mike@xxxxxxxx> Date: Mon, 16 Dec 2002 17:56:34 -0700 (MST) |
NIENKE, Bill P. - ACCOR-NA wrote: > Almost everything works as it should, except the geo:name > and the geo:url nodes aren't iterating as they should. The meat of your stylesheet is this (I've added line #s): 1 <xsl:template match="/"> 2 <xsl:apply-templates select="/geo:gpx/geo:wpt/geo:desc"> 3 <xsl:sort select="geo:desc" data-type="text" order="ascending"/> 4 <xsl:apply-templates> 5 </xsl:template> 6 7 <xsl:template match="/geo:gpx/geo:wpt/geo:desc"> 8 <a> 9 <xsl:attribute name="href"> 10 <xsl:value-of select="/geo:gpx/geo:wpt/geo:url"/> 11 </xsl:attribute> 12 <xsl:value-of select="."/> 13 </a> 14 <xsl:text> - </xsl:text> 15 <xsl:value-of select="/geo:gpx/geo:wpt/geo:name"/> 16 <br/> 17 </xsl:template> On line 2, you're saying "find all geo:desc elements that are children of geo:wpt elements that are children of geo:gpx elements that are children of the root node, and go process them". You're already processing the root node, so I'd omit the leading '/' from the expression, just to save a few bytes. But wait, don't change anything yet. On line 3, you're saying to process the nodes identified in line 2 as if they were sorted in ascending order by the string-value of their first geo:desc child. If this is working for you, then it means your geo:desc elements have geo:desc children, like (pardon my syntax)... <geo:gpx> <geo:wpt> <geo:desc> <geo:desc> ... ...if this isn't right, and you only have one level of geo:desc, you probably wanted select="." in the xsl:sort. But wait, don't change anything yet. On line 7, you're saying this template is a good match for any geo:desc element that is a child of a geo:wpt element that is a child of a geo:gpx element that is a child of the root node. Since there are no xsl:apply-templates instructions that mandate the processing of any geo:desc elements that wouldn't match that pattern, you should change this to match="geo:desc", for efficiency. But wait, don't change anything yet. On line 10, you're saying create a text node using the string-value of all geo:url elements that are children of geo:wpt elements that are children of geo:gpx elements that are children of the root node. The string-value of a node-set is the string-value of the first node in the set. So here's where part of your 'iteration' problem is. I'm getting the impression that your XML looks like this: <geo:gpx> <geo:wpt> <geo:name>...</geo:name> <geo:desc>...</geo:url> <geo:url>...</geo:url> </geo:wpt> ... </geo:gpx> (It really would've helped if you had posted a sample) If that's the case, then here's what you should do: 1. change line 2 to select geo:gpx/geo:wpt 2. leave line 3 the way it is 3. change line 7 to match geo:wpt 4. change line 10 to select geo:url 5. change line 12 to select geo:desc, and 6. change line 15 to select geo:name. The idea is that when processing a geo:wpt element, you look at its geo:url, geo:desc, and geo:name child elements. Mike -- Mike J. Brown | http://skew.org/~mike/resume/ Denver, CO, USA | http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] two nodes are iterating, Joerg Heinicke | Thread | [xsl] Extending Xhtml2fo.xsl to han, Graham Hannington |
Re: [xsl] two nodes are iterating, Joerg Heinicke | Date | RE: [xsl] SVG Businesses?, bryan |
Month |