|
Subject: RE: [xsl] Need test for preceding-sibling From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 23 Apr 2009 19:24:35 -0400 |
Now I see that I over-simplified the problem. The XSLT also has to suppress any <a1> that is not paired with an <a2>.
So, I'm not sure the grouping works in your example since there could be two <a1/> elements that are in the group that ends with <a2/>. But, if you specify:
<xsl:for-each-group select="*" group-starting-with="a1" group-ending-with="a2">
will that consider "<a1/><a1/><a2/>" a group?
T:\ftemp>type hintz.xml <test> <a1/> <a2/> <a1/> <a2/> <b/> <c/> <a2/> <d/> <a1/> <e/> <a1/> <f/> <a2/> <g/> </test>
T:\ftemp>xslt2 hintz.xml hintz.xsl <?xml version="1.0" encoding="UTF-8"?> <a1/> <a2/> <a1/> <a2/> <!--Missing paired a1--> <b/> <c/> <a2/> <d/> <a1/> <e/> <!--Missing paired a2--> <a1/> <f/> <a2/> <g/> T:\ftemp>type hintz.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="test">
<xsl:for-each-group select="*"
group-starting-with="a1">
<xsl:for-each-group select="current-group()"
group-ending-with="a2">
<xsl:choose>
<xsl:when test="exists(current-group()/self::a1) =
exists(current-group()/self::a2)">
<xsl:copy-of select="current-group()"/>
</xsl:when>
<xsl:when test="current-group()/self::a1">
<xsl:copy-of select="current-group()"/>
<xsl:comment>Missing paired a2</xsl:comment><xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Missing paired a1</xsl:comment><xsl:text>
</xsl:text>
<xsl:copy-of select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template></xsl:stylesheet> T:\ftemp>
-- XSLT/XQuery/XSL-FO hands-on training - Los Angeles, USA 2009-06-08 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/m/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/m/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Need test for preceding-s, Hintz, David L | Thread | Re: [xsl] Need test for preceding-s, Lars Huttar |
| RE: [xsl] When *not* to use XLST..., Michael Kay | Date | [xsl] creating of id and refid, Ganesh Babu N |
| Month |