>
>    what i have observed is that if the xml file has the same namespace
> as the pre parsed schema then xml is validated against the
> preparsed schema  even though the xml file has a reference to a updated
>  schema(xsd file),errors are thrown here(see below) ,  . But if the
> namespace specified in the  xml file does not match with any in the
> cache, then the schema referred in the xml file is loaded and
> validated..

The FAQ details that the schemas are cached using namespace as key, so
caching works as it should. It is the automatic loading of the schema that
is problematic for me. I think that the actual behaviour contravenes the
described behaviour. I hope somebody who understands the software well can
either explain where I err or confirm that Xerces isn't working as claimed.

Regards,

-a
>
> [Error] BookStore.xml:7:81: cvc-complex-type.3.2.2: Attribute
> 'Category'  is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:7:81: cvc-complex-type.3.2.2: Attribute 'InStock'
>  is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:7:81: cvc-complex-type.3.2.2: Attribute
> 'Reviewer'  is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:14:85: cvc-complex-type.3.2.2: Attribute
> 'Category' is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:14:85: cvc-complex-type.3.2.2: Attribute
> 'InStock'  is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:14:85: cvc-complex-type.3.2.2: Attribute
> 'Reviewer' is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:21:71: cvc-complex-type.3.2.2: Attribute
> 'Category' is not allowed to appear in element 'Book'.
> [Error] BookStore.xml:21:71: cvc-complex-type.3.2.2: Attribute
> 'Reviewer' is not allowed to appear in element 'Book'.
>
> May be some one can throw more light on this.
>
> Regards
> venu
>
>>Regards,
>>
>>-a
>>
>>
>>
>>>Regards
>>>venu
>>>
>>>
>>>
>>>>grammar pool being locked! I know it is loaded because I changed the
>>>>instance document to be incorrect WRT its schema, and the parser
>>>>threw the exception.
>>>>
>>>>-a
>>>>
>>>>
>>>>
>>>>
>>>>>Hi ,
>>>>>
>>>>>  This may not solve your problem or answer your questions , but
>>>>>attached is a small program which i was working on ,  see if it is
>>>>>of any help.
>>>>>
>>>>>Regards
>>>>>venu
>>>>>
>>>>>
>>>>>[EMAIL PROTECTED] wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Hi,
>>>>>>
>>>>>>Perhaps this issue has been discussed on the list but the archives
>>>>>>aren't available, so I have to post. Here goes...
>>>>>>
>>>>>>I am trying to use what is called 'active' schema caching, as
>>>>>>demonstrated by the XMLGrammarBuilder example, except, I want to
>>>>>>use DOMParser and use the DOM of the XML instances that are
>>>>>>successfully validated. This the code I'm using
>>>>>>
>>>>>>  SymbolTable symtab = new SymbolTable();
>>>>>>      XMLGrammarPreparser preparser = new
>>>>>>      XMLGrammarPreparser(symtab);
>>>>>>  XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl();
>>>>>>
>>>>>>      preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA,
>>>>>>      null);
>>>>>>  preparser.setProperty(GRAMMAR_POOL, pool);
>>>>>>  preparser.setFeature(NAMESPACES_FEATURE_ID, true);
>>>>>>      preparser.setFeature(VALIDATION_FEATURE_ID, true);
>>>>>>  preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
>>>>>>  preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
>>>>>>  preparser.setErrorHandler(this);
>>>>>>
>>>>>>  System.out.println("Pre-compiling Schema from file " + xsd);
>>>>>>  Grammar g =
>>>>>>  preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, new
>>>>>>XMLInputSource(null, xsd, null));
>>>>>>  pool.lockPool();
>>>>>>
>>>>>>  XMLParserConfiguration parsercfg = new
>>>>>>  StandardParserConfiguration(symtab,
>>>>>>pool);
>>>>>>  parsercfg.setFeature(NAMESPACES_FEATURE_ID, true);
>>>>>>      parsercfg.setFeature(VALIDATION_FEATURE_ID, true);
>>>>>>  parsercfg.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
>>>>>>  parsercfg.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
>>>>>>  parsercfg.setEntityResolver(new XMLEntityResolver() {
>>>>>>                                  public XMLInputSource
>>>>>>resolveEntity(XMLResourceIdentifier id) throws XNIException {
>>>>>>                                       System.out.println("Resolving 
>>>>>> resource: " +
>>>>>>                                       id.getLiteralSystemId());          
>>>>>>                              throw new
>>>>>>                                       XNIException("Not resolving 
>>>>>> entity..."); //return null;
>>>>>>                                  }
>>>>>>                              });
>>>>>>
>>>>>>First question is about the XMLEntityResolver. The FAQ instructs to
>>>>>>register a "do-nothing" EntityResolver. What does it mean? If I
>>>>>>simply return null (do nothing?) the XML instance document that
>>>>>>should fail validation quietly validates. Does it mean I should
>>>>>>throw exception, as I do? That seems to work but is it
>>>>>>"do-nothing"?
>>>>>>
>>>>>>More importantly, since not only need to validate XML but also get
>>>>>>DOMs of the valid ones, I followed the FAQ again and registered the
>>>>>>DOMParser:
>>>>>>
>>>>>>   parser = new DOMParser(parsercfg);
>>>>>>   parsercfg.setDocumentHandler(parser);
>>>>>>
>>>>>>   ....
>>>>>>   // f is File
>>>>>>   XMLInputSource xis = new XMLInputSource(null, f.getName(),
>>>>>>   null); System.out.println("Parsing instance XML in file " +
>>>>>>   f.getName() + " "
>>>>>>+ xis.getSystemId());
>>>>>>
>>>>>>   parsercfg.parse(xis);
>>>>>>
>>>>>>
>>>>>>But doe not work at all! I get a NullPointerException and the
>>>>>>XMLEntityResolver isn't called at all:
>>>>>>
>>>>>>
>>>>>>Pre-compiling Schema from file 2.xsd
>>>>>>Parsing instance XML in file 2.xml 2.xml
>>>>>>java.lang.NullPointerException
>>>>>>   at
>>>>>>   org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown
>>>>>>Source)
>>>>>>   at
>>>>>>   org.apache.xerces.impl.xs.XMLSchemaValidator.startDocument(Unknown
>>>>>>Source)
>>>>>>   at
>>>>>>   org.apache.xerces.impl.XMLNamespaceBinder.startDocument(Unknown
>>>>>>   Source)     at
>>>>>>   org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown
>>>>>>   Source)     at
>>>>>>   org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown
>>>>>>Source)
>>>>>>   at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown
>>>>>>   Source) at
>>>>>>   org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown
>>>>>>Source)
>>>>>>   at
>>>>>>   org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown
>>>>>>Source)
>>>>>>   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
>>>>>>   Source) [java]     at
>>>>>>   org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
>>>>>>Source)
>>>>>>   at
>>>>>>   
>>>>>> gov.treas.fms.sps.utils.SchemaVerifier.parse(SchemaVerifier.java:189)>>>>>>
>>>>>>    at
>>>>>>   
>>>>>> gov.treas.fms.sps.utils.SchemaVerifier.parse(SchemaVerifier.java:199)>>>>>>]
>>>>>>      at
>>>>>>gov.treas.fms.sps.utils.SchemaVerifier.parse(SchemaVerifier.java:207)
>>>>>>at
>>>>>>gov.treas.fms.sps.utils.SchemaVerifier.main(SchemaVerifier.java:337)
>>>>>>
>>>>>>
>>>>>>I tried to test the entity resolver of the DOMParser but it isn't
>>>>>>called either:    parser.setEntityResolver(new EntityResolver() {
>>>>>>                               public InputSource
>>>>>>                               resolveEntity(String pubid,
>>>>>>String sysid) throws SAXException, IOException {
>>>>>>                                   System.out.println("DOM parser entity 
>>>>>> resolver: pub id
>>>>>>                                   " +
>>>>>>pubid + ", sysid: " + sysid);
>>>>>>                                   return null;
>>>>>>                               }
>>>>>>                           });
>>>>>>
>>>>>>So, can somebody explain me what am I doing something wrong? And
>>>>>>what should I be doing to get what I want. Almost forgot, I'm using
>>>>>>Xerces 2.2.1 and changing parser with my client is very-very-very
>>>>>>difficult - government agency.
>>>>>>Please. lend a helping hand. TIA,
>>>>>>
>>>>>>Regards,
>>>>>>
>>>>>>-a
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] For
>>>>additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to