[Home] [By Thread] [By Date] [Recent Entries]

  • To: xml-dev <xml-dev@l...>
  • Subject: dom4j set properties
  • From: Laura Hatcher <lhatcher@a...>
  • Date: Fri, 25 Jan 2002 17:19:12 -0500

I am attempt to use the Xerces 1.4.3 external schema location property
by setting it using the dom4j method setProperty.  My code compiles, but
when I run my code validation isn't working correctly.  The error that I
get is not that it can not locate the schema that it is suppose to
validate against, but that the root element will not validate
correctly.  I know that the instances that I am using validate correctly
against the schemas, but not when using the setProperty method.  My
parse method looks like this:

   public boolean parse()
   {

        //probably won't need this check for null input since there is
        //currently no default constructor
        if (_input == null) {
            StringBuffer msg = new StringBuffer()
                .append("No input was detected for validation.");
            return false;
        }

        try
        {
            // building the Document object of JDOM
            SAXReader xmlReader = new SAXReader(_validation);

xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);

            if (this._validation == true) {

xmlReader.setFeature("http://xml.org/sax/features/validation", true);

xmlReader.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
true);
                xmlReader.setProperty(

"http://apache.org/xml/properties/schema/external-schemaLocation",
                        "http://www.argoneng.com/lh
/products/baseline/tasking_unclass/interfaces/taskingObjects.xsd");
                xmlReader.setProperty(

"http://apache.org/xml/properties/schema/external-schemaLocation",
                        "http://www.argoneng.com/lh
/products/baseline/tasking_unclass/interfaces/taskingDefs.xsd");
                xmlReader.setProperty(

"http://apache.org/xml/properties/schema/external-schemaLocation",
                        "http://www.argoneng.com/lh
/products/baseline/tasking_unclass/interfaces/detTasking.xsd");
                xmlReader.setProperty(

"http://apache.org/xml/properties/schema/external-schemaLocation",
                        "http://www.argoneng.com/lh
/products/baseline/tasking_unclass/interfaces/ratTasking.xsd");

            }

            _doc = xmlReader.read(_input);
            return true;

        }
        catch (DocumentException e)
        {
            StringBuffer msg2 = new StringBuffer()
                .append("The Document that is needed for validation is
incorrect");
            e.printStackTrace(DebugPrint.getPrintStream(9,
SRT_PRODUCT));
            return false;
        }
        catch (SAXException sax)
        {
            StringBuffer msg3 = new StringBuffer()
                .append("The Document was not validated correctly");
            sax.printStackTrace(DebugPrint.getPrintStream(9,
SRT_PRODUCT));
            return false;
        }
    }

Has anyone had experience with this?

Thanks in advance,
Laura Hatcher


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member