[jdom-interest] Why PI are outputed after the root element?

Peer Haja peerhaja at yahoo.com
Thu Dec 7 12:40:14 PST 2000


Hi all,

I have a problem with my code. All the porcessing
instructions are printed after the root element. And
it seems that the xerces validating parser does not
like it very much. I have searched the archive list
and seems no other people have such problem. So it
must be something wrong with my code. Here it is:

ns = Namespace.getNamespace("ns",
"http://www.my.com");
rootElement = new Element("rootElement", ns);
Attribute attr = 
    new Attribute ("noNamespaceSchemaLocation",
		 "http://www.my.com/schema.xsd", ns);
rootElement.addAttribute(attr);
Document doc = new Document(rootElement);
Map map = new HashMap();
map.put("href", "XSL/html.xsl");
map.put("type", "text/xsl");
ProcessingInstruction pi = new
    ProcessingInstruction("xml-stylesheet", map);
doc.addContent(pi);
map = new HashMap();
map.put("href", "XSL/wml.xsl");
map.put("type", "text/xsl");
map.put("media", "wap");
pi = new
    ProcessingInstruction("xml-stylesheet", map);
doc.addContent(pi);

// add children of the root element here

XMLOutputter fmt = new XMLOutputter(" ", true);
fmt.output(doc, System.out);



The result looks like:

<?xml version="1.0" encoding="UTF-8"?>

<ns:rootElement xmlns:ns="http://www.my.com"
ns:noNamespaceSchemaLocation="http://www.my.com/schema.xsd">
<!-- children are here -->
  <ns:child/>
</ns:rootElement>
<?xml-stylesheet href="XSL/html.xsl" type="text/xsl"?>
<?xml-stylesheet href="XSL/wml.xsl" type="text/xsl"
media="wap"?>



Thanks,

David


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/



More information about the jdom-interest mailing list