|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: move tag up to level
Don't think in terms of "closing tags" or "moving tags" anywhere. XSLT does not work with tags, and thinking in those terms just makes it harder to use XSLT. What you want to do is take the children of a and group them into groups of adjacent nodes that are either b elements or not b elements. b elements you just want to copy, and each group of not-b elements you want to place as a child of an a element. So you use for-each-group gruping on a boolean test for a node being a b element, like so: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="a"> <xsl:for-each-group select="node()" group-adjacent="exists(self::b)"> <xsl:choose> <xsl:when test="self::b"> <xsl:apply-templates select="current-group()"/> </xsl:when> <xsl:otherwise> <a> <xsl:copy-of select="../@*"/> <xsl:apply-templates select="current-group()"/> </a> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







