joes (archive)
Usenet Archive
- Joined
- Sep 13, 2003
- Messages
- 18
- Reaction score
- 0
Hello there
I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing wrong. Could somebody help me? I didn't find any full example working on the net. Thank you for any hints!
If I run the examples below, the parsers parses the file well, no vlaidation is occuring although the schema and xml file does not match.
I tried with the JAXP standard procedure, it does not work, why ?
File f = new File("dvd.xml");
SAXParserFactory saxFactory = SAXParserFactory.newInstance; saxFactory.setNamespaceAware(true); saxFactory.setValidating(true); SAXParser saxParser = saxFactory.newSAXParser; saxParser.parse(f, new DefaultHandler);
I tried with activating additional SAX Features, does also not work, why ?
File f = new File("dvd.xml");
SAXParserFactory saxFactory = SAXParserFactory.newInstance; saxFactory.setNamespaceAware(true); saxFactory.setValidating(true); saxFactory.setFeature("http://xml.org/sax/features/validation",true); saxFactory.setFeature("http://apache.org/xml/features/validation/schema",true); saxFactory.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true); SAXParser saxParser = saxFactory.newSAXParser; saxParser.parse(f, new DefaultHandler);
Here is my xml:
<?xml version="1.0" encoding="utf-8" ?>
<dvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="dvd.xsd" id="33" available="3">Matrix Revolutions</dvd>
Here is my xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="dvdi" type="xs:string"/> <xs:attribute name="id" type="xs:string"/> <xs:attribute name="available" type="xs:boolean"/> </xs:schema>
I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing wrong. Could somebody help me? I didn't find any full example working on the net. Thank you for any hints!
If I run the examples below, the parsers parses the file well, no vlaidation is occuring although the schema and xml file does not match.
I tried with the JAXP standard procedure, it does not work, why ?
File f = new File("dvd.xml");
SAXParserFactory saxFactory = SAXParserFactory.newInstance; saxFactory.setNamespaceAware(true); saxFactory.setValidating(true); SAXParser saxParser = saxFactory.newSAXParser; saxParser.parse(f, new DefaultHandler);
I tried with activating additional SAX Features, does also not work, why ?
File f = new File("dvd.xml");
SAXParserFactory saxFactory = SAXParserFactory.newInstance; saxFactory.setNamespaceAware(true); saxFactory.setValidating(true); saxFactory.setFeature("http://xml.org/sax/features/validation",true); saxFactory.setFeature("http://apache.org/xml/features/validation/schema",true); saxFactory.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true); SAXParser saxParser = saxFactory.newSAXParser; saxParser.parse(f, new DefaultHandler);
Here is my xml:
<?xml version="1.0" encoding="utf-8" ?>
<dvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="dvd.xsd" id="33" available="3">Matrix Revolutions</dvd>
Here is my xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="dvdi" type="xs:string"/> <xs:attribute name="id" type="xs:string"/> <xs:attribute name="available" type="xs:boolean"/> </xs:schema>