BTW, this is never needed in a pattern. Just write "topic".
Good to know.
I celebrated too soon. When I apply the stylesheet against my input
file, I get the title, prolog, and body elements on the same level --
which is the desired result -- but title appears below prolog, which
is invalid against the DTD I'm working with. How could I output the
title element above the prolog element?
Input file:
<?xml version="1.0"?>
<topic>
<title>
<indexterm>Software Requirements</indexterm>Software Requirements
</title>
<body>
<p>Some sample text</p>
</body>
</topic>
Current output XML:
<?xml version="1.0"?>
<topic>
<prolog>
<metadata>
<keywords>
<indexterm>
<indexterm>Software Requirements</indexterm>
</indexterm>
</keywords>
</metadata>
</prolog>
<title>
<indexterm>Software Requirements</indexterm>Software Requirements
</title>
<body>
<p>Some sample text</p>
</body>
</topic>
Desired output XML:
<?xml version="1.0"?>
<topic>
<title>
<indexterm>Software Requirements</indexterm>Software Requirements
</title>
<prolog>
<metadata>
<keywords>
<indexterm>
<indexterm>Software Requirements</indexterm>
</indexterm>
</keywords>
</metadata>
</prolog>
<body>
<p>Some sample text</p>
</body>
</topic>
XSL:
<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:apply-templates select="@*"/>
<prolog>
<metadata>
<keywords>
<indexterm>
<xsl:copy-of
select="title/indexterm"/>
</indexterm>
</keywords>
</metadata>
</prolog>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="indexterm[parent::title]"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Thanks,
Mark
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--