A JAXP parser
- If you are using SAX and obtained this parser from the SAXParserFactory:
javax.xml .parsers.SAXParser parser
- To
validate d using a schema (xsd) add this line of code to your parser setup:
parser.setProperty("http://java.sun.com/xml /jaxp/properties/schemaLanguage",
XML Constants.W3C_XML _SCHEMA_NS_URI);
parser.setProperty("http://java.sun.com/xml /jaxp/properties/schemaS ource",
new File("checkers.xsd"));
SL-385.B: add to code 3-2 after line 17
- The source can be a File, InputStream, InputSource or an Object array containing these types
- If you are using DOM, and you created this DocumentBuilderFactory instance :
javax.xml .parsers.DocumentBuilderFactory builder
- To
validate d using a schema (xsd) add this line of code to your parser setup:
builder.setAttribute("http://java.sun.com/xml /jaxp/properties/schemaLanguage",
XML Constants.W3C_XML _SCHEMA_NS_URI);
XML Constants.W3C_XML _SCHEMA_NS_URI =http://www.w3.org/2001/
XML Schema
The corresponding constant for DTD (the default) in these cases is
=
XML Constants.XML _DTD_NS_URIhttp://www.w3.org/TR/REC-
xml
builder.setAttribute("http://java.sun.com/xml /jaxp/properties/schemaS ource",
new File("checkers.xsd"));
No comments:
Post a Comment