How to set ProcessingInstruction in jdom Document?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mali djuro

    #1

    How to set ProcessingInstruction in jdom Document?

    Hi all,
    i try to make xml file with jdom, and also i made xsl file for presenting
    xml in browser.
    because of that i need to add processing instuction in xml file
    ....
    <?xml-stylesheet type="text/xml" href="test.xsl" ?>
    <root>
    ....
    </root>

    i did :

    Element root = new Element("root") ;
    Document document = new Document(root);

    ProcessingInstr uction pi = new ProcessingInstr uction("xml-stylesheet",
    "type='text/xsl' href='test.xsl' ");

    document.addCon tent(pi);

    ....

    i got xml file like this

    <?xml version=1.0 ?>
    <root>
    ....
    </root>
    <?xml-stylesheet type="text/xsl" href="test.xsl" ?>

    how to put this line
    <?xml-stylesheet type="text/xsl" href="test.xsl" ?>
    in front of <root>

    thanks


  • Xortam
    New Member
    • Apr 2006
    • 1

    #2
    RE : XSL processing instructions

    Hi,
    I don't know If you find your answer... If you don't, I've found it :)
    you must create an empty document like :

    Document doc = new Document();

    then add your ProcessingInstr uction to this empty document
    like doc.addContent( pi);

    and finally set the root element of the document :
    doc.setRootElem ent(root);

    And know you have the processing instruction in front of the root Element.

    Comment

    Working...