• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

parsing confusion

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something is not clear to me...
For validating an xml against a schema I have used the following code (xerces is the implementation parser) which uses the XMLReader to validate.



I have seen another example of validating using the SAXParser which is obtained from the SAXParserFactory to parse the file and do the validation without using the XMLReader directly but this does not do any validation at all, well at least it doesn't work in my sample :-)


Now the question what is the difference between using an XMLReader to parse and using the SAXParser directly ?
And another question why is the second sample not validating ?

Thanks.

Kristof
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property was introduced in JAXP 1.2 -- which version of JAXP does your parser support?
 
Kristof Camelbeke
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I believe the "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property was introduced in JAXP 1.2 -- which version of JAXP does your parser support?


I use the "Xerces2 Java Parser 2.6.2 " which follows the JAXP 1.2 standard..

But my confusion is whether you should use the abstract class SAXParser which wraps an XMLReader or use the XMLReader directly in your code.

What is the best way ? Or is there no best way ?

Thanks,

Kristof
[ August 19, 2004: Message edited by: Kristof Camelbeke ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, I would stick to javax.xml.parsers.SAXParser since it's a "standard" way of using the SAX API.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
Personally, I would stick to javax.xml.parsers.SAXParser since it's a "standard" way of using the SAX API.


Although I would probably settle for the XMLReader if I had a problem I couldn't solve after a while...
 
Kristof Camelbeke
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Although I would probably settle for the XMLReader if I had a problem I couldn't solve after a while...



Yep you are right... I think I'll let the SAXParser for what it is
But I still find it strange that it doesn't work...
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kristof Camelbeke:

Yep you are right... I think I'll let the SAXParser for what it is
But I still find it strange that it doesn't work...



Why not use the simple DOM parser validation quoted here ?
http://faq.javaranch.com/view?HowToValidateXmlAgainstSchema
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic