This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi can any body tell me how to validate a XML file while parsing with an DTD file,I m getting the XML file dynamically ,so i m not getting the DOCTYPE line in the XML and i dont wanna include that. so is there any facility so seperately mention the DTD File???
Before a document can be validated against a DTD, the document itself must contain a document type declaration pointing to the DTD it should be validated against. You cannot easily receive a document from a third party and validate it against your own DTD. You have to validate it against the DTD that the document's author specified. This is excessively limiting. For example, imagine you're running an e-commerce business that accepts orders for products using SOAP or XML-RPC. Each order comes to you over the Internet as an XML document. Before accepting that order the first thing you want to do is check that it's valid against a DTD you've defined to make sure that it contains all the necessary information. However, if DTDs are all you have to validate with, then there's nothing to prevent a hacker sending you a document whose DOCTYPE declaration points to a different DTD. Then your system may report that the document is valid according to the hacked DTD, even though it would be invalid when compared to the correct DTD. If your system accepts the invalid document, it could introduce corrupt data that crashes the system or lets the hacker order goods they haven’t paid for, all because the person authoring the document got to choose which DTD to validate against rather than the person validating the document. Schemas are more flexible. The schema specification specifically allows for a variety of different means for associating documents with schemas. For instance, one possibility is that both the name of the document to validate and the name of the schema to validate it against could be passed to the validator program on the command line like this: C:\>validator greeting.xml greeting.xsd
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
I am also trying to validate an input XML to my servlet against XML Schema. If anybody could please tell me how to do it in Java. I came to know that it can be done only through the parsers which support JAXP version 1.2. If anybody can suggest me which version of Xerces supports the above specifications. Thanks in advance,
Pradeep<br />Consultant - Enterprise Solutions,<br />Infosys Technologies Ltd,<br />Bangalore, India
Joined: Sep 26, 2002
hi i know that validation of XML can be done against a DTD when the DOCTYPE declaration(DTD path) is inside an XML . But my problem is that i m getting the XML from some 3rd party and i want to process that only if it is validated by my DTD . so i dont have the DOctype declaration in mY XML please help in in knowing how can i validate the XML against the DTD in this case thx