Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating Valid XML

 
Edward Morris
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I generate XML output that conforms to a Schema? I use the DOM architecture and the DocumentBuilderFactory stuff to easily generate XML, but its just not exactly what I expect it to be i.e. its not valid. How do you assign a schema for an XML document and how do we get this schema info added to the root element of the doc. Right now I do it by using setAttribute() method but I know its not right. Any help appreciated.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually that probably IS right. Or at least, it's as right as you can get with DOM. The DOM API was designed before XML Schema even existed, and it doesn't do many other things well either.

That's assuming your question was how to get the schema declaration into the XML document that you are producing from the DOM. Whether the document actually conforms to the schema is a matter for unit testing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic