• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml validation using dtd's

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently using JAXP....and could some one tell me how to validate an incoming xmlstring using it's corresponding DTD???
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried to answer your question here.
Where is your DTD? If it is an external resource, then your XML file should have a reference to it. If it is internal to the XML document then it should be a part of your XML string. As long as one of these two conditions are satisfied, a validating parser will be able to locate your DTD and validate the document against the definition.
Does that help?
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The dtd is internal and comes in with the xml string,and since i am using JAXP,i can set validating to true
<!DOCTYPE CRMDataExchange SYSTEM "customersearchrequest.dtd">
is there some other code i should include for it to be validated
what if it fails???as you can see i dont understand how the validation takes place....please educate
 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should i use sax error handler for validatinf an xml against a DTD,if so how should i do this???
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your DOCTYPE tag
<!DOCTYPE CRMDataExchange SYSTEM "customersearchrequest.dtd">

says that DTD is not internal! Internal DTDs are inline DTDs and they are embeded in the XML document. In your case the DTD is external and is defined in the customersearchrequest.dtd file.
Can you please clarify?
 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you are right,it is in an external file
do i have to turn the validation on??? in JAXP .....
if so do i have to have sax errorhandlers set???how do i exactly go about doing the validation???thanks in advance
 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have set validation to true..i get the error message back saying customerSearchrequest.dtd cannot be resolved without a document URI...i cannot understand wehat to do
<!DOCTYPE CRMDataExchange SYSTEM \"c:\\CustomerSearchRequest.dtd\">
I have given an abssolute path here for my dtd( and my document builder accepts an xml string as an input to parse).....
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can you please clarify where your coping the DOCTYPE line from?
If it is directly from the xml document then it should NOT have the '\' escape character. So this
<!DOCTYPE CRMDataExchange SYSTEM \"c:\\CustomerSearchRequest.dtd\">
should be like this
<!DOCTYPE CRMDataExchange SYSTEM "c:\CustomerSearchRequest.dtd">
 
Mark Savory
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot something:
Don't forget the protocol: 'file:'
<!DOCTYPE CRMDataExchange SYSTEM "file:c:\CustomerSearchRequest.dtd">
 
reply
    Bookmark Topic Watch Topic
  • New Topic