5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk//
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.6-b27-fcs
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// Any modifications to this file will be lost upon recompilation of the source schema.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// Generated on: 2012.06.11 at 10:34:07 AM PDT
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk//
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpackage com.sun.identity.saml2.jaxb.assertion.impl.runtime;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport javax.xml.bind.JAXBException;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport javax.xml.bind.ValidationEvent;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport org.iso_relax.verifier.impl.ForkContentHandler;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport org.xml.sax.Attributes;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport org.xml.sax.SAXException;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport org.xml.sax.helpers.AttributesImpl;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport com.sun.msv.grammar.Grammar;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport com.sun.msv.verifier.Verifier;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport com.sun.msv.verifier.VerifierFilter;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport com.sun.msv.verifier.regexp.REDocumentDeclaration;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport com.sun.xml.bind.validator.Locator;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/**
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Filter implementation of SAXUnmarshallerHandler.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * <p>
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This component internally uses a VerifierFilter to validate
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * SAX events that goes through this component.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Discovered error information is just passed down to the next component.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * <p>
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This will enable the implementation to validate all sources of SAX events
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * in the RI - XMLReader, DOMScanner
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * SAX events will go the VerifierFilter and then to the SAXUnmarshaller...
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpublic class ValidatingUnmarshaller extends ForkContentHandler
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk implements SAXUnmarshallerHandler {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /**
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Creates a new instance of ValidatingUnmarshaller.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk public static ValidatingUnmarshaller create( Grammar grammar,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk SAXUnmarshallerHandler _core,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Locator locator ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // create a VerifierFilter and configure it
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // so that error messages will be sent to the core,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Verifier v = new Verifier(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk new REDocumentDeclaration(grammar),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk new ErrorHandlerAdaptor(_core,locator) );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk v.setPanicMode( true );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return new ValidatingUnmarshaller(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk new VerifierFilter( v ), _core );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private ValidatingUnmarshaller( VerifierFilter filter,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk SAXUnmarshallerHandler _core ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk super( filter, _core );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.core = _core;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // delegate to the next component
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public Object getResult() throws JAXBException, IllegalStateException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return core.getResult();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // SAXUnmarshallerHandler already checks for RuntimeExceptions, so
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // there is no need to wrap this call in a try/catch
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk core.handleEvent(event,canRecover);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private final SAXUnmarshallerHandler core;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private final AttributesImpl xsiLessAtts = new AttributesImpl();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void startElement( String nsUri, String local, String qname, Attributes atts ) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // create an attributes set for MSV that doesn't contains xsi:schemaLocation
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xsiLessAtts.clear();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int len = atts.getLength();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk for( int i=0; i<len; i++ ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String aUri = atts.getURI(i);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String aLocal = atts.getLocalName(i);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if(aUri.equals("http://www.w3.org/2001/XMLSchema-instance")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk && (aLocal.equals("schemaLocation") ||
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk aLocal.equals("noNamespaceSchemaLocation") //||
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /*aLocal.equals("type")*/))
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk continue;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // we do handle xsi:nil.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xsiLessAtts.addAttribute( aUri, aLocal,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk atts.getQName(i), atts.getType(i), atts.getValue(i) );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk super.startElement(nsUri,local,qname,xsiLessAtts);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk}
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk