Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Adding an xml-stylesheet Processing Instruction to a document

 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!