Subject: [xsl] First positional grouping From: "I-Lin Kuo" <ikuoikuo@xxxxxxxxxxx> Date: Wed, 07 May 2003 17:13:19 +0000 |
This is my first attempt at positional grouping and I'm almost there. I'd like to transform
<!-- source.xml --> <root> <var VGID="AA" label="Families"/> <var label="Fathers"/> <var label="Mothers"/> <var VGID="AB" label="Relatives"/> <var label="Inlaws/> </root>
into <!-- desiredResult.xml --> <varList VGID="AA" label="Families"/> <var label="Fathers"/> <var label="Mothers"/> </varList> <varList VGID="AB" label="Relatives"/> <var label="Inlaws/> </varList>
by promoting all <vars> with a @VGID. I'm following the example at http://www.dpawson.co.uk/xsl/sect2/N4486.html#d4085e229 Using the following style sheet,
<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="root"> <root> <xsl:for-each select="var[@VGID]"> <varList> <xsl:apply-templates select="@*"/> <xsl:for-each select="following-sibling::var[ count(preceding-sibling::var[@VGID][1] | current()) = 1]"> <xsl:copy-of select="."/> </xsl:for-each> </varList> </xsl:for-each> </root> </xsl:template>
<xsl:template match="@*|node()" priority="-1"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template>
I get this result: <!-- ActualResult.xml --> <root> <varList VGID="AA" label="Families"> <var label="Fathers" /> <var label="Mothers" /> <var VGID="AB" label="Relatives" /> </varList> <varList VGID="AB" label="Relatives"> <var label="Inlaws" /> </varList> </root>
which has an extra third node under the first <varList>. Can someone help me get rid of the extra node? It should be a matter of just amending the XPATH in the inner for-each.
I-Lin Kuo, Ann Arbor, MI Macromedia Certified ColdFusion 5.0 Advanced Developer Sun Certified Java 2 Programmer Ann Arbor Java Users Group (http://www.aajug.org)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XPath problem: figured it out, Ben Trafford | Thread | Re: [xsl] First positional grouping, I-Lin Kuo |
[xsl] Seeking HTML Encoding XSL tem, Gary Cornelius | Date | RE: [xsl] Matching a series of elem, Doug Howell (IT) |
Month |