[jdom-interest] setProperty in SAXBuilder to validate

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu Apr 8 04:55:52 PDT 2004


xu003 wrote:
> I've been struglled with this for 6 hours now. 
> Hope someone can help me with it.

Why not using JAXP 1.2 schema validation properties :

     /** JAXP 1.2 schema language property id. */
     private static final String SCHEMA_LANGUAGE_PROPERTY_ID =
        "http://java.sun.com/xml/jaxp/properties/schemaLanguage";

     /** JAXP 1.2 schema location property id. */
     private static final String SCHEMA_LOCATION_PROPERTY_ID =
        "http://java.sun.com/xml/jaxp/properties/schemaSource";

     /** W3C XML Schema language URI. */
     private static final String W3C_XML_SCHEMA_URI =
        "http://www.w3.org/2001/XMLSchema";

...

         SAXBuilder builder = new SAXBuilder(true);
         builder.setProperty(SCHEMA_LANGUAGE_PROPERTY_ID, W3C_XML_SCHEMA_URI);
         builder.setProperty(SCHEMA_LOCATION_PROPERTY_ID, new String[] { 
"file:///C:/ims.xsd" });

         org.jdom.Document doc = builder.build(new File("C:/testing.xml"));

Laurent



More information about the jdom-interest mailing list