in reply to XML to XML
From your question question I assume you haven't used XSLT before, so to help you get started here's an XSLT stylesheet that will do the job to get you started.
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- When matching the root node, create a 'doc' element in the result tree and process all the child nodes of the root node. --> <xsl:template match="/"> <doc> <xsl:apply-templates /> </doc> </xsl:template> <!-- Matching an 'open1' element causes the creation of an element named after the value of the type attribute of the 'open1' element in the result tree. Any child nodes of the current node are processed and inserted below the newly created element. --> <xsl:template match="open1"> <xsl:element name="{@type}"> <xsl:apply-templates /> </xsl:element> </xsl:template> <!-- Matching an 'em' element causes the insertion of an 'emp' element with a child element named after the value of the type attribute of the 'em' element in the result tree. Any child nodes of the 'em' element are processed (and inserted below the newly created element). --> <xsl:template match="em"> <emp> <xsl:element name="{@type}"> <xsl:apply-templates /> </xsl:element> </emp> </xsl:template> <!-- Matching an 'i' element causes the insertion of an 'italic' element. Nodes resulting from processing child nodes of the current node will be inserted below this element. --> <xsl:template match="i"> <italic> <xsl:apply-templates /> </italic> </xsl:template> </xsl:stylesheet>
Of course, this isn't a substitute for reading one or more tutorials or (if you are so inclined) the XSLT spec, but it will give you something to play with in the meantime.
&mdash Arien
|
|---|