[jdom-interest] Outputting PIs

Galluzzo, Eric EGalluzzo at synchrony.net
Thu Nov 30 10:45:44 PST 2000


It looks like you're adding the PI after you add the element.  According to
the XML spec, PI's can be anywhere in a document, so if you want it at the
top, you have to add it before anything else. :)

    - Eric

> -----Original Message-----
> From: Muhle, Daniel [mailto:Daniel.Muhle at mettenmeier.de]
> Sent: Thursday, November 30, 2000 3:47 AM
> To: 'jdom-interest at jdom.org'
> Subject: [jdom-interest] Outputting PIs
> 
> 
> Hi there,
> 
> I just stumbled about a strange behaviour of the XML-Outputter.
> 
> After I've created a new document with:
>       Namespace ns = Namespace.getNamespace("MM",
> "http://www.mettenmeier.de");
>       Element root = new Element("Data_Model", ns);
>       
>       doc = new Document(root);
> 
>       Hashtable PIValues = new Hashtable();
>       PIValues.put("href", "XSL\\GisModel.html.xsl");
>       PIValues.put("type", "text/xsl");
>       
> and added this PI and a DTD
> 
>       ProcessingInstruction pi = new ProcessingInstruction(
> 					      "xml-stylesheet",
> 					      PIValues
> 					      );
> 
>       doc.addContent(pi);
>      
>       doc.setDocType(new DocType("MM:Data_Model", 
> "DTD/data_model.dtd"));
> 
> Then I'm populating the document with more Elements and 
> finally print it to
> a file using the XMLOutputter:
> 
> 	XMLOutputter fmt = new XMLOutputter("   ", true,"ISO-8859-1");
> 	fmt.output(doc,out);
> 
> But when I take a look at the output I have to see, that the 
> added PI has
> been appended to the end of my document.
> 
> 	<?xml version="1.0" encoding="ISO-8859-1"?>
> 	<!DOCTYPE MM:Data_Model SYSTEM "DTD/data_model.dtd">
> 	<MM:Data_Model xmlns:MM="http://www.mettenmeier.de">
> 
> 		< ... a lot of elements... />
> 	</MM:Data_Model>
> 	<?xml-stylesheet href="XSL\GisModel.html.xsl" type="text/xsl"?>
> 
> The Apache-Coocoon-Framework doesn't like a PI at the end of 
> a document,
> though... ;-)
> 
> > Mit freundlichen Grüßen:
> > Daniel Muhle
> > Mettenmeier GmbH
> > -Abteilung Software-
> > mailto:daniel.muhle at mettenmeier.de
> > http://www.mettenmeier.de
> > 
> > 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list