473,782 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set ProcessingInstr uction 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
Jul 17 '05 #1
1 5918
Xortam
1 New Member
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.
Apr 12 '06 #2

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

Similar topics

6
3944
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 have "Hi" in database, i will have &quot;Hi&quot; in content of element. And it is ok, because in xml does not exist ", at least i think that. After it i want to make convert from document to string. I used XMLOutputter serializer = new...
2
6121
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 document object in another application that is expecting a DOM (w3c) document. If someone could perhaps, show me an example that would be very much
0
1197
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 problem. My server class will have a method to receive an XML document, let's say user.xml, detach its root element and attach to an XML document build in the server called usersfile.xml. I am using a SAXBuilder to validate both documents when...
3
3023
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. Thank you very much, Michael
3
15204
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 ? I copied the newest jdom.jar from newest JDOM release b10 to the folder jdk\jre\lib\endorsed
1
2018
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. ( <xsl:param name="blah.."/> ) Is it possible to use JDOM XSL Transform with parameters? Thanks,
2
1556
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 the difference and when to use the above. Thanks so much.
0
1426
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 the common type definitions from 1 or more of the component XML schemas rather than just explicitly adding the common definitions in every XML schema we create. This works great from a definition and validation point of view, but I
2
5860
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"); Document doc = new Document(root); ... // add some elements appended to root XMLOutputter out = new XMLOutputter();
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.