1 Reply Latest reply on Apr 4, 2007 7:53 PM by starksm64

    JBXB-101, disabling validation

    starksm64

      I cannot disable validation against a document dtd currently for use with the ObjectModelFactory/Unmarshaller apis. The Unmarshaller.setValidation(boolean) call has no affect.

      The problem would seem to be this static initialization of the parser factory and setting the validating flag to true:

      public class SaxJBossXBParser
       implements JBossXBParser
      {
       private static final Logger log = Logger.getLogger(SaxJBossXBParser.class);
      
       private static final SAXParserFactory saxFactory = SAXParserFactory.newInstance();
       static
       {
       saxFactory.setValidating(true);
       saxFactory.setNamespaceAware(true);
       enableXInclude();
       }
      


      The Unmarshaller.setValidation(boolean) call maps to setting a feature of the parser. I'm not sure why this is not getting picked up on the resulting parser.


        • 1. Re: JBXB-101, disabling validation
          starksm64

          After digging into the xerces code, both the VALIDATION and DYNAMIC_VALIDATION features need to be false to avoid validation of docs with DOCTYPEs. The UnmarshallerImpl.setValidation(boolean) was therefore updated to:

           public void setValidation(boolean validation) throws JBossXBException
           {
           parser.setFeature(VALIDATION, validation);
           parser.setFeature(DYNAMIC_VALIDATION, false);
           }
          


          With this change the test passes.