Logo 
Search:

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: 906
  

I have this code that create an xml with JDOM.

<code>
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();
piList.add(pi);

Document xmlOutput = new Document(xmlRoot);
xmlOutput.setProcessingInstructions(piList);
</code>


the point is that when outputting this into a browser I get
<!-- XML OUTPUT // -->
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<params />
<files />
<folders />
</xml>
<?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. )

Share: 

 

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

 




Tagged: