|
Subject: [xsl] Moving (promoting) XML elements through XSL From: "Mark Peters" <flickrmeister@xxxxxxxxx> Date: Thu, 29 Jun 2006 16:41:56 -0400 |
1. Promote the indexterm elements in my XML doc to the same level as my title and body elements. 2. Wrap the indexterm element in additional elements.
<topic id="i267011">
<title>
<indexterm>Hardware Requirements</indexterm>
<indexterm>Software Requirements</indexterm>Software Requirements
</title>
<body>
..
</body>
</topic><topic id="i267011">
<title>Software Requirements
</title>
<prolog>
<metadata>
<keywords>
<indexterm>Hardware Requirements</indexterm>
<indexterm>Software Requirements</indexterm>
</keywords>
</metadata>
</prolog>
<body>
..
</body>
</topic>
Based on XSL I've studied in the archive, the FAQ, and in other lists, I created the following stylesheet, which *should* at least promote the indexterm elements (I haven't figured gotten as far as wrapping the indexterm elements yet):
<xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" version=" 1.0"> <xsl:output indent="yes"/> <xsl:template match="/topic"> <xsl:copy> <xsl:copy-of select="/title/indexterm"/> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="indexterm"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- Copy any nodes not covered above. --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
When I apply the stylesheet to my input XML doc, my indexterm elements disappear.
<topic id="i267011">
<title>Software Requirements
</title>
<body>
..
</body>
</topic>Mark Peters Senior Technical Writer Saba Software
Mark Peters Senior Technical Writer Saba Software
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] [XSLT2] Some common, gene, omprakash . v | Thread | Re: [xsl] Moving (promoting) XML el, David Carlisle |
| [xsl] [XSLT2] Some common, generic , Christian Roth | Date | Re: [xsl] Moving (promoting) XML el, David Carlisle |
| Month |