Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JDOM + stylesheet : how to have the xsl on top of xml code ?

  Asked By: Harry    Date: Dec 05    Category: Java    Views: 864

I have this code that create an xml with JDOM.

Element xmlRoot = new org.jdom.Element("xml");
xmlRoot.addContent(new Element("params"));
xmlRoot.addContent(new Element("files"));
xmlRoot.addContent(new Element("folders"));

ProcessingInstruction pi = new ProcessingInstruction("xml-
stylesheet","type=\"text/xsl\" href=\"file:///c:/temp/myxsl.xsl\" ");
LinkedList piList=new LinkedList();

Document xmlOutput = new Document(xmlRoot);

the point is that when outputting this into a browser I get
<!-- XML OUTPUT // -->
<?xml version="1.0" encoding="UTF-8" ?>
<params />
<files />
<folders />
<?xml-stylesheet type="text/xsl" href="file:///c:/temp/myxsl.xsl" ?>
<!-- /XML OUTPUT // -->

and I need to have the
"<?xml-stylesheet type="text/xsl" href="file:///c:/temp/myxsl.xsl" ?
right after the
"<?xml version="1.0" encoding="UTF-8" ?>"
not at the end of the xml!!!

Any help welcome !
(REMINDER : you can not create a "Document" from a
ProcessingInstruction, and the ProcessingInstruction is NOT an
element. )



No Answers Found. Be the First, To Post Answer.