473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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);

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

document.addContent(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
Jul 17 '05 #1
1 5882
Xortam
1
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 ProcessingInstruction to this empty document
like doc.addContent(pi);

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

And know you have the processing instruction in front of the root Element.
Apr 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
2
by: Praveen Chhangani | last post by:
Folks, I was wondering if it were possible to convert an org.jdom.doc to an org.w3c.doc document. Essentially what I have is an already parsed document using jdom and I would like to use the...
0
by: Marcio DeBarros | last post by:
Hi, This is my first time with XML, and I am using JDOM, on a Java client/server application, where the server will store data in XML files (not using any DBMS). I came across the following...
3
by: Michael | last post by:
hello, I'm a java programmer, and my program will require to parse XML documents and extract data from it, then built a new XML document. Should JDOM or Xerces be the best for me? Please help....
3
by: Bernd Oninger | last post by:
When I run the successfully compiled java source shown at the end I got a runtime error: Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/Content Where is the missing class ?...
1
by: Son KwonNam | last post by:
Hi~ I usually use JDOM for XML Processing. But, when I tried transforming XSL, I could not find the way to pass parameters to XSLT Processor. "parameters" which are defined in XSL document. (...
2
by: john smith | last post by:
hello, I am having to read an XML document and grab some elements and attributes and then convert that to anther XML document. Which should I use? JAX, DOM, JDOM? I don't really understand...
0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
2
by: zhengwt | last post by:
I used JDOM.jar to process xml-based document. Recently, I meet such a problem that I can not solve. First, I use the following code generate xml text: Element root = new Element("Root");...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.