I am processing a Schema document, and the default namespace is vanishing:
In:
====
<schema
xmlns='http://www.w3.org/2000/10/XMLSchema'
targetNamespace='http://www.w3.org/namespace/'
xmlns:t='http://www.w3.org/namespace/'>
<element name='ex1'>
<complexType>
<sequence>
<element ref='t:x'/>
</sequence>
</complexType>
</element>
<element name='x'>
<complexType mixed='true'>
</complexType>
</element>
</schema>
====
Out:
====
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:t="http://www.w3.org/namespace/"
targetNamespace="http://www.w3.org/namespace/">
<element name="ex1">
<complexType>
<sequence>
<element ref="t:x"/>
</sequence>
</complexType>
</element>
<element name="x">
<complexType mixed="true"></complexType>
</element>
</schema>
====
Code:
====
package test;
import java.io.*;
import org.dom4j.io.*;
import org.dom4j.*;
import org.dom4j.tree.*;
class ParseTest {
static public void main (String args[]) {
try {
if (args.length == 0) {
System.out.println ("Error: must specify XML file.");
}
else {
SAXReader reader = new SAXReader (false); // No validation.
Document doc = reader.read (args[0]);
XMLWriter writer = new XMLWriter(new BufferedOutputStream (new
FileOutputStream ("ParseTest.out")), OutputFormat.createPrettyPrint());
writer.write (doc);
writer.flush();
// System.out.println (doc.asXML());
}
}
catch (Exception e) {
System.out.println ("Exception: " + e.getMessage());
}
}
}
====
Note that the following has vanished:
xmlns='http://www.w3.org/2000/10/XMLSchema'
Am I doing something wrong here? Do I have to explicitly set the default
namespace, and if so, how?
Thanks,
Thomas.
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user