aspose file tools
The moose likes XML and Related Technologies and the fly likes Adding an xml-stylesheet Processing Instruction to a document Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Adding an xml-stylesheet Processing Instruction to a document" Watch "Adding an xml-stylesheet Processing Instruction to a document" New topic
Author

Adding an xml-stylesheet Processing Instruction to a document

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
I need to set a stylesheet processing instruction to an XML document at the time of creation, before the root tag. I've considered ingesting a "template" xml document that would have the stylesheet and root already defined, but I was wondering if there is a way to do this when the file is actually generated instead.
I've looked through the API and see the ProcessingInstruction interface, as well as the fact that Node has a PROCESSING_INSTRUCTION_NODE field, but I can't seem to figure out how to create a ProcessingInstruction Node and associated to a Document object.
Any pointers to either a tutorial or code example would be great.
Thanks!
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Answered my own question... isn't that fun!
Just in case anyone else has the problem, here is my sample code:

Not sure if this is the "correct" way, but it works.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Adding an xml-stylesheet Processing Instruction to a document
 
Similar Threads
basic doubt: doc element and doc root
JDOM -- addProcessingInstruction doesn't work correctly with IE6
XML on the fly using servlets
DOM doc is not adding a ProcessingInstruction
processing instruction target matching "[xX][mM][lL]