Hi all,
I was wondering, if anyone could help me with this.
while doing validation with XML schema:

.xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="account">

.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<account xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     
     xsi:noNamespaceSchemaLocation="C:/bea/wlserver6.1/config/mydomain/applications/DefaultWebApp/Account.xsd">


The code:

1. when I do:
org.apache.xerces.parsers.SAXParser p = new org.apache.xerces.parsers.SAXParser();
                  p.setErrorHandler(new MyErrorHandler());
                          p.setFeature("http://xml.org/sax/features/validation", true);
                          p.setFeature("http://xml.org/sax/features/validation/schema", true);
                          p.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
                  p.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);
                  p.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
                                                           "C:/bea/wlserver6.1/config/mydomain/applications/DefaultWebApp/Account.xsd");

                  p.parse(ins); //ins is InputSource
          Document docu = p.getDocument();


I get SAXException as this: http://xml.org/sax/features/validation/schema (from the 'error' function of the ErrorHandler)


2. When I do:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  DocumentBuilderFactoryImpl dbf = new DocumentBuilderFactoryImpl();
                  dbf.setValidating(true);
                  dbf.setNamespaceAware(true);
                  DocumentBuilder db = dbf.newDocumentBuilder();
                  db.setErrorHandler(new MyErrorHandler());
                  Document doc = db.parse(ins); // ins is InputSource

I get error:
element "account" must be declared in

ErrorHandler looks like this:

class MyErrorHandler implements ErrorHandler    {
 MyErrorHandler() {}
  public void fatalError(SAXParseException spe2)  {
      System.out.println("rp: (spe2):"+spe2.getMessage()); }
  public void error(SAXParseException spe1)  {
     System.out.println("rp: (spe1):"+spe1.getMessage());
  }
  public void warning(SAXParseException spe3)  {
                        System.out.println("rp: (spe3):"+spe3.getMessage());
   }
}


Thank you very much for your help!
Paul



© 2002 OpenLink Financial

Copyright in this message and any attachments remains with us.  It is
confidential and may be legally privileged.   If this message is not
intended for you it must not be read, copied or used by you or
disclosed to anyone else.   Please advise the sender immediately if
you have received this message in error.

Although this message and any attachments are believed to be free of
any virus or other defect that might affect any computer system into
which it is received and opened, it is the responsibility of the
recipient to ensure that it is virus free and no responsibility
is accepted by Open Link Financial, Inc. for any loss or damage in any
way arising from its use.