[Home] [By Thread] [By Date] [Recent Entries]
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
|

Cart



