|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Help on XSL to tranform simple flat xml sequential
Christian Oshiro wrote:
This seems like a pretty simple thing to do, but I usually rely on nested xml. How can I tranform xml that looks like this: Here is an XSLT 2.0 stylesheet:
<xsl:output indent="yes"/> <xsl:template match="doc"> <xsl:copy> <xsl:for-each-group select="*" group-starting-with="para[@role = 'title']"> <paragraph> <xsl:apply-templates select="current-group()"/> </paragraph> </xsl:for-each-group> </xsl:copy> </xsl:template> <xsl:template match="para[@role = 'title']">
<title><xsl:apply-templates/></title>
</xsl:template> <xsl:template match="para[@role = 'subtitle']">
<subtitle><xsl:apply-templates/></subtitle>
</xsl:template> <xsl:template match="para[not(@role)]">
<body><xsl:apply-templates/></body>
</xsl:template> <xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|






