[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Trying to select sibling nodes between two nodes
At 2010-01-08 16:12 -0600, Ylvisaker, Steve wrote:
I have some unfortunate xml that I am trying to parse: This has come up before and it comes up in the classroom. What you need to use here is grouping, creating new groups for every <br> and encapsulating everything in the group except <br> elements (which are the first in those groups that have a <br> and possibly not present in the very first group, as is true with your data). I hope the working answer below helps. . . . . . . . . . Ken T:\ftemp>type steve.xml <label>first text<br/>second<emphasis>bold</emphasis> text<br/>third text</label > T:\ftemp>xslt2 steve.xml steve.xsl <?xml version="1.0" encoding="UTF-8"?> <label> <flowPara>first text</flowPara> <flowPara>second<emphasis>bold</emphasis> text</flowPara> <flowPara>third text</flowPara> </label> T:\ftemp>type steve.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="label"> <label> <xsl:for-each-group select="node()" group-starting-with="br"> <flowPara> <xsl:copy-of select="current-group()[not(self::br)]"/> </flowPara> </xsl:for-each-group> </label> </xsl:template> </xsl:stylesheet> T:\ftemp>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! 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
|