I think the best way to ask this question is: How do I specify a default namespace for the root element in the output? Doing this:
<xsl:template match="/">
<r xmlns:s"http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema" >
....
....
Gives me an error in Oracle:
ORA-31011: XML Parsing Failed ORA-19201: Error occurred in in XML Processing LPX-00604: Invalid attribute 'nIfNotExist', for attribute 'name' ORA-06512: at SYS.XMLType at line 74 ORA-06512: at line 24
where the 'nIfNotExist'
is a template:
<xsl:template name="nIfNotExist" xmlns:scom="http://www.mycomapny.com/s/schema">
<xsl:param name="nodeToTest"/>
<xsl:param name="nodeName"/>
...
I want the resulting document to have the root element look like this:
<r xmlns:s="http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema">
I want "http://www.mycompany.com/default/schema"
as the default namespace so the document can pass XSD validation. Otherwise, I have to add it manually before running validation (not an option for batch processing).
EDIT
I have tried this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="http://www.mycompany.com/schema"
xmlns="http://www.mycompany.com/def_schema">
The result is a document with no data, like this:
<r xmlns:s="http://www.mycompany.com/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/def_schema">
<a></a>
<s:b></s:b>
<c></c>
....
It should have been:
<r xmlns:s="http://www.mycompany.com/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/def_schema">
<a>123</a>
<s:b>ABC34L</s:b>
<c>7.092381</c>
UPDATE
Source data looks something like this (input that I get has no namespaces defined in it):
<ROOT_NODE>
<DATA_A>1234</DATA_A>
<DATA_B>34567</DATA_B>
<OTHER_DATA_C>7.123456</OTHER_DATA_C>
</ROOT_NODE>
Desired output
<r xmlns:s="http://www.mycompany.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.mycompany.com/def_schema">
<a>1234</a>
<s:b>34567</s:b>
<c>7.123456</c>
</r>