コード例 #1
0
 /** Setup for validation. * */
 final void setup(Location location, StAXResult result, boolean stringsInternalized) {
   fDepth = 0;
   fComponentManager.reset();
   setupStAXResultHandler(result);
   fValidationManager.setEntityState(this);
   if (fEntities != null && !fEntities.isEmpty()) {
     // should only clear this if the last document contained unparsed entities
     fEntities.clear();
   }
   fStAXLocationWrapper.setLocation(location);
   fErrorReporter.setDocumentLocator(fStAXLocationWrapper);
   fStringsInternalized = stringsInternalized;
 }
コード例 #2
0
 public void validate(Source source, Result result) throws SAXException, IOException {
   if (result instanceof StAXResult || result == null) {
     StAXSource staxSource = (StAXSource) source;
     StAXResult staxResult = (StAXResult) result;
     try {
       XMLStreamReader streamReader = staxSource.getXMLStreamReader();
       if (streamReader != null) {
         // Hand off to XMLStreamReader helper.
         if (fStreamHelper == null) {
           fStreamHelper = new StreamHelper();
         }
         fStreamHelper.validate(streamReader, staxResult);
       } else {
         // Hand off to XMLEventReader helper.
         if (fEventHelper == null) {
           fEventHelper = new EventHelper();
         }
         fEventHelper.validate(staxSource.getXMLEventReader(), staxResult);
       }
     } catch (XMLStreamException e) {
       throw new SAXException(e);
     } catch (XMLParseException e) {
       throw Util.toSAXParseException(e);
     } catch (XNIException e) {
       throw Util.toSAXException(e);
     } finally {
       // Release references to application objects
       fCurrentEvent = null;
       fStAXLocationWrapper.setLocation(null);
       fXMLStreamReaderLocation.setXMLStreamReader(null);
       if (fStAXValidatorHandler != null) {
         fStAXValidatorHandler.setStAXResult(null);
       }
     }
     return;
   }
   throw new IllegalArgumentException(
       JAXPValidationMessageFormatter.formatMessage(
           fComponentManager.getLocale(),
           "SourceResultMismatch",
           new Object[] {source.getClass().getName(), result.getClass().getName()}));
 }