Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schema

Discussion in 'Java' started by Markus, Nov 23, 2005.

  1. Markus

    Markus Guest

    I hava an applet/application which can validate an XML.
    But there are some problems because the schemaLocation

    In the xml-file the schemaLocation = "mySchema.xsd".
    But if I start my app in a browser as applet the parser searches on the
    local drive for mySchema.xsd.
    This is not really the problem beacause I found out, that I can set the
    Property
    "http://apache.org/xml/properties/schema/external-schemaLocation" to
    "myNameSpace url_to_mySchema.xsd"

    The problem occours because mySchema.xsd (which is not really my schema
    ;-) )includes some "sub-schemas" in that way:

    mySchema.xsd
    ....
    <xsd:include schemaLocation = "mySchema_a.xsd"/>
    <xsd:include schemaLocation = "mySchema_b.xsd"/>
    ...

    The parses found mySchema.xsd on the given URL but searches mySchema_a
    and _b under local driver anyway. :-/

    Does anybody know a solution to configure the parser to load all XSDs
    from a given URL?
    -> I'm using JDOM and Xerces.

    Kind regards

    Markus
     
    Markus, Nov 23, 2005
    #1
    1. Advertising

  2. Markus

    Markus Guest

    Here is the (a better) solution:

    //Creating a ErrorHandler
    m_SAXErrorHandler = new SPSCSAXErrorHandler();
    //Setting the parser
    m_builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
    //activate validation
    m_builder.setValidation(a_b_validate);
    //setting Errorhandler
    m_builder.setErrorHandler(m_SAXErrorHandler);
    //activate schema-validation
    m_builder.setFeature("http://apache.org/xml/features/validation/schema",
    a_b_validate);
    m_builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
    a_b_validate);
    m_builder.setFeature("http://xml.org/sax/features/validation",
    a_b_validate);
    //buidling document - all relative paths are relative to a_st_base
    m_document = m_builder.build(a_inputStreamXML, a_st_base);

    Markus
     
    Markus, Nov 23, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    987
  2. Gerben
    Replies:
    3
    Views:
    787
    Alexey Dmitriev
    Oct 11, 2003
  3. Replies:
    4
    Views:
    644
    Joseph Kesselman
    Aug 10, 2006
  4. PerlFAQ Server
    Replies:
    0
    Views:
    724
    PerlFAQ Server
    Feb 3, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    734
    PerlFAQ Server
    Apr 4, 2011
Loading...

Share This Page