|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Moving (promoting) XML elements through XSL
Hi folks,
I'm trying to apply XSL to my input XML document to accomplish two tasks: 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. Input XML: <topic id="i267011">
<title>
<indexterm>Hardware Requirements</indexterm>
<indexterm>Software Requirements</indexterm>Software Requirements
</title>
<body>
..
</body>
</topic>Output XML: <topic id="i267011">
<title>Software Requirements
</title>
<prolog>
<metadata>
<keywords>
<indexterm>Hardware Requirements</indexterm>
<indexterm>Software Requirements</indexterm>
</keywords>
</metadata>
</prolog>
<body>
..
</body>
</topic>
<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>
Current result: <topic id="i267011">
<title>Software Requirements
</title>
<body>
..
</body>
</topic>I'd be grateful for any assistance. Thanks in advance! Mark -- Mark Peters Senior Technical Writer Saba Software -- Mark Peters Senior Technical Writer Saba Software
|
Back To School Sale!Save 30% off all Stylus Studio 2008 Products when you purchase from our Online Shop. 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
|






