I am having a problem validating personal.xml as found in the xerces
distribution for java.

Although this file produces no errors using sun's jaxp parser, the
org.apache.xerces.parsers.SAXParser gives me the following error -- every
element fails. I can't see anything wrong with personal.xml.

******** PARSE ERROR ********
org.xml.sax.SAXParseException: Document root element "personnel", must match
DOCTYPE root "personnel".
Entity id (Public) = null
Entity id (System) = file:/d:/xerces/103/data/personal.xml
(line,col) = (3, 12)
*****************************
******** PARSE ERROR ********
org.xml.sax.SAXParseException: The content of element type "name" must match
"((family,given)|(given,family))".
Entity id (Public) = null
Entity id (System) = file:/d:/xerces/103/data/personal.xml
(line,col) = (6, 61)
*****************************

and so on ...

here's my setup. ( the handlers simply print out a message and call the
default handler )

   static final String features[] = new String[]
   {
     "http://xml.org/sax/features/validation";,
     "http://xml.org/sax/features/external-general-entities";,
     "http://xml.org/sax/features/external-parameter-entities";,
     "http://xml.org/sax/features/namespaces";,
     "http://apache.org/xml/features/validation/dynamic";,
     "http://apache.org/xml/features/validation/default-attribute-values";,
     "http://apache.org/xml/features/validation/validate-content-models";,
     "http://apache.org/xml/features/validation/validate-datatypes";,
     "http://apache.org/xml/features/validation/warn-on-duplicate-attdef";,
     "http://apache.org/xml/features/validation/warn-on-undeclared-elemdef";,
     "xxxhttp://apache.org/xml/features/allow-java-encodings";,
     "xxxhttp://apache.org/xml/features/continue-after-fatal-error";,
     "http://xml.org/sax/features/namespace-prefixes";,
     "xxxhttp://xml.org/sax/features/string-interning";
   };

  public Test( String filename )
    throws Exception
  {
    XMLReader reader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");


    for ( int i=0;i<features.length; i++ )
    {
      if ( !features[i].startsWith("xxx") )
      {
        try
        {
          reader.setFeature( features[i], true );
        }
        catch ( SAXNotRecognizedException nrx )
        {
          System.out.println( nrx.toString() );
        }
        catch ( SAXNotSupportedException nsx )
        {
          System.out.println( nsx.toString() );
        }
      }
    }

    reader.setDTDHandler( new TestDTDHandler( reader.getDTDHandler() ) );
    reader.setErrorHandler( new TestErrorHandler( System.out ) );
    reader.setContentHandler( new
estContentHandler( reader.getContentHandler() ) );
    reader.setEntityResolver( new
estEntityResolver( reader.getEntityResolver() ) );

    reader.parse( filename );
....



Reply via email to