1

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 Answer 1

3

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>
Sign up to request clarification or add additional context in comments.

5 Comments

@RameshSingh, What does it mean "not working" just copy and paste the transformation from the answer ( as I did when I verified that running the transformation produces the wanted result) and run the transformation -- on any source XML document -- then any compliant XSLT processor produces the result that is provided (again copied from the actual result of running the transformation and pasted into this answer) in this answer. I always test my code and verify that it is actually producing the wanted result.
hi dimitre, i use xslt transformation through biztalk pipeline component . when it parses through parser automatically it is back to actual results .
@RameshSingh, BizTalk is not an XSLT processor. You must read the documentation and see what restrictions/conventions for XSLT transformation do apply. I am not a BizTalk specialist, but know my XSLT stuff. I have verified that all of the 10 different XSLT processors I am working with produce the same wantes, correct result -- MSXML 3,4,6, Saxon 6.5.4, Saxon 9.1.05, AltovaXML (XML-SPY) -- both for XSLT 1.0 and XSLT 2.0, .NET XslCompiledTransform, .NET XslTransform, XQSharp (XMLPrime).
I tested using visual studio iam getting the Actual results
@RameshSingh, I am glad my answer was useful to you. Could you, please, accept it (by clicking the check-mark next to the answer)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.