• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Inserting a DOCTYPE declaration into DOM

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm creating an XML file by building up a DOM document in some java code and then writing out the file. But I would like to know how to associate a DTD file with the XML file by inserting the DOCTYPE declaration. So that I end up with some similar to the following when I finally write the DOM Document out to a file:-

Any help gratefully received!
Kathy
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi kathy,
i don't know if you are using any ibm packages,if so use com.ibm.xml.parser.TXDoument doc = new com.ibm.xml.parser.TXDoument();
doc.createDTD(String,new ExternalID("aaa.dtd"));
i think this would help.
regards,
lavanya
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathy ,
i had found out including external dtd in the dom.
see if this works,
//from package oracle.xml.parser.v2.XMLDocument and XMLDeclPI
XMLDocument doc = new XMLDocument();

XMLDeclPI decl = new XMLDeclPI("1.0",null,null,false);//version,encoding and standalone parameters
doc.appendChild(decl);
doc.setDoctype("rootelement","full path of the external dtd",null);// not sure of the last parameter.
bye,
lavanya
 
Kathy Rogers
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help, Lavanya. The problem is that I'm not using the IBM parser - I'm using a parser that comes packaged with an application we use for B2B transactions and we haven't really been given any API information for it despite requests. Finally I fell back on this:-

Not a very elegant solution as it involves creating and then immediately trashing a dom object just to get the implementation but it works well enough.
Thanks again,
Kathy
[ January 08, 2002: Message edited by: Kathy Rogers ]
 
Have you no shame? Have you no decency? Have you no tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic