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


In reply to Re: XML to XML by Arien
in thread XML to XML by jdinesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.