1
votes

I want to create root node in xslt 1.0 in custom fashion

Expected

" < TESTROOT xmlns="http://www.example.org/TESTXMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/TESTXMLSchema TESTEntry.xsd">

Actual

" < TESTROOT xsi:schemaLocation="http://www.example.org/TESTXMLSchema TESTEntry.xsd" xmlns="xmlns="http://www.example.org/TESTXMLSchema"" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Thanks for your help in advance

Regards Rameshkumar singh

1

1 Answers

3
votes

As simple as this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/">
  <TESTROOT xmlns="http://www.example.org/TESTXMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://www.example.org/TESTXMLSchema TESTEntry.xsd">
    The results of your processing here ...
  </TESTROOT>
 </xsl:template>
</xsl:stylesheet>

When this transformation is applied on any XML document (not used), the wanted result is produced:

<TESTROOT xmlns="http://www.example.org/TESTXMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/TESTXMLSchema TESTEntry.xsd">
    The results of your processing here ...
  </TESTROOT>