private void sendCharactersToValidator(String str) { if (str != null) { final int length = str.length(); final int remainder = length & CHUNK_MASK; if (remainder > 0) { str.getChars(0, remainder, fCharBuffer, 0); fTempString.setValues(fCharBuffer, 0, remainder); fSchemaValidator.characters(fTempString, null); } int i = remainder; while (i < length) { str.getChars(i, i += CHUNK_SIZE, fCharBuffer, 0); fTempString.setValues(fCharBuffer, 0, CHUNK_SIZE); fSchemaValidator.characters(fTempString, null); } } }
public void endDocument() throws SAXException { try { schemaValidator.endDocument(null); } catch (XNIException e) { throw toSAXException(e); } }
/** Do processing for the end of a node. */ private void finishNode(Node node) { if (node.getNodeType() == Node.ELEMENT_NODE) { fCurrentElement = node; // end element fillQName(fElementQName, node); fSchemaValidator.endElement(fElementQName, null); // pop namespace context fNamespaceContext.popContext(); } }
/** Configures the pipeline. */ protected void configurePipeline() { super.configurePipeline(); if ( getFeature(XMLSCHEMA_VALIDATION )) { // If schema validator was not in the pipeline insert it. if (fSchemaValidator == null) { fSchemaValidator = new XMLSchemaValidator(); // add schema component fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator); addComponent(fSchemaValidator); // add schema message formatter if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) { XSMessageFormatter xmft = new XSMessageFormatter(); fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft); } } fLastComponent = fSchemaValidator; fNamespaceBinder.setDocumentHandler(fSchemaValidator); fSchemaValidator.setDocumentHandler(fDocumentHandler); fSchemaValidator.setDocumentSource(fNamespaceBinder); } } // configurePipeline()
storeLocations(sLocation, nsLocation); fElementDepth++; if (fAugPSVI) augs = getEmptyAugs(augs); if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) { assertionValidatorStartElementDelegate(element, attributes, augs); if (ctype.fParticle != null && (next = fCurrentCM.whatCanGoHere(fCurrCMState)).size() > 0) { String expected = expectedStr(next); final int[] occurenceInfo = fCurrentCM.occurenceInfo(fCurrCMState); String elemExpandedQname = (element.uri != null) ? "{"+'"'+element.uri+'"'+":"+element.localpart+"}" : element.localpart; final int required = minOccurs - count; if (required > 1) { reportSchemaError("cvc-complex-type.2.4.h", new Object[] { element.rawname, fCurrentCM.getTermName(occurenceInfo[3]), Integer.toString(minOccurs), Integer.toString(required) }); reportSchemaError("cvc-complex-type.2.4.g", new Object[] { element.rawname, fCurrentCM.getTermName(occurenceInfo[3]), Integer.toString(minOccurs) }); reportSchemaError("cvc-complex-type.2.4.e", new Object[] { element.rawname, expected, Integer.toString(maxOccurs) }); reportSchemaError("cvc-complex-type.2.4.a", new Object[] { elemExpandedQname, expected }); reportSchemaError("cvc-complex-type.2.4.a", new Object[] { elemExpandedQname, expected });
fSchemaValidator.startDocument(fStAXLocationWrapper, null, fNamespaceContext, null); do { switch (eventType) { fillDeclaredPrefixes(reader); fNamespaceContext.setNamespaceContext(reader.getNamespaceContext()); fSchemaValidator.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: fillDeclaredPrefixes(reader); fNamespaceContext.setNamespaceContext(reader.getNamespaceContext()); fSchemaValidator.endElement(fElementQName, null); --fDepth; break; fTempString.setValues(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()); fSchemaValidator.characters(fTempString, null); break; case XMLStreamConstants.CDATA: fSchemaValidator.startCDATA(null); fTempString.setValues(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()); fSchemaValidator.characters(fTempString, null); fSchemaValidator.endCDATA(null); break; case XMLStreamConstants.START_DOCUMENT:
fSchemaValidator = new XMLSchemaValidator(); fSchemaValidator.reset(this); fSchemaValidator.setDocumentSource(fLastComponent); fSchemaValidator.setDocumentHandler(fDocumentHandler); if (fDocumentHandler != null) { fDocumentHandler.setDocumentSource(fSchemaValidator);
fSchemaValidator.startElement(fElementQName, fAttributes, null); break; case Node.TEXT_NODE: if (fDOMValidatorHandler != null) { fDOMValidatorHandler.setIgnoringCharacters(true); fSchemaValidator.startCDATA(null); sendCharactersToValidator(node.getNodeValue()); fSchemaValidator.endCDATA(null); fDOMValidatorHandler.setIgnoringCharacters(false); fDOMValidatorHandler.cdata((CDATASection) node); fSchemaValidator.startCDATA(null); sendCharactersToValidator(node.getNodeValue()); fSchemaValidator.endCDATA(null); fSchemaValidator.processingInstruction(node.getNodeName(), fTempString, null); fSchemaValidator.comment(fTempString, null);
processOneAttribute(element, attributes, index, attrDecl, null, attrPSVI); continue; reportSchemaError( "cvc-type.3.1.1", new Object[] { element.rawname, fTempQName.rawname }); ? null : findSchemaGrammar( XSDDescription.CONTEXT_ATTRIBUTE, fTempQName.uri, element, fTempQName, attributes); if (attrWildcard == null || !allowAttribute(attrWildcard, fTempQName, grammar)) { reportSchemaError( "cvc-complex-type.3.2.2", new Object[] { element.rawname, fTempQName.rawname }); findSchemaGrammar( XSDDescription.CONTEXT_ATTRIBUTE, fTempQName.uri, reportSchemaError( "cvc-complex-type.3.2.2", new Object[] { element.rawname, fTempQName.rawname }); && ((XSSimpleType) currDecl.fType).isIDType()) { if (wildcardIDName != null) { reportSchemaError( "cvc-complex-type.5.1", new Object[] { element.rawname, currDecl.fName, wildcardIDName });
fSchemaValidator.startDocument(fXMLLocator, null, fDOMNamespaceContext, null); validate(node); fSchemaValidator.endDocument(null);
public void startDocument() throws SAXException { fComponentManager.reset(); fSchemaValidator.setDocumentHandler(this); fValidationManager.setEntityState(this); fTypeInfoProvider.finishStartElement(); // cleans up TypeInfoProvider fNeedPushNSContext = true; if (fUnparsedEntities != null && !fUnparsedEntities.isEmpty()) { // should only clear this if the last document contained unparsed entities fUnparsedEntities.clear(); } fErrorReporter.setDocumentLocator(fSAXLocatorWrapper); try { fSchemaValidator.startDocument(fSAXLocatorWrapper, fSAXLocatorWrapper.getEncoding(), fNamespaceContext, null); } catch (XMLParseException e) { throw Util.toSAXParseException(e); } catch (XNIException e) { throw Util.toSAXException(e); } }
fComponents.put(NAMESPACE_CONTEXT, fNamespaceContext); fSchemaValidator = new XMLSchemaValidator(); fXSDVersion = grammarContainer.getXMLSchemaVersion(); fSchemaValidator.setProperty(XML_SCHEMA_VERSION, fXSDVersion); fComponents.put(SCHEMA_VALIDATOR, fSchemaValidator);
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { try { schemaValidator.ignorableWhitespace(new XMLString(ch, start, length), null); } catch (XNIException e) { throw toSAXException(e); } }
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { try { if (!pushedContext) namespaceContext.pushContext(); else pushedContext = false; for (int i = 0, len = atts.getLength(); i < len; i++) attributes.addAttribute(makeQName(atts.getURI(i), atts.getLocalName(i), atts.getQName(i)), symbolTable.addSymbol(atts.getType(i)), atts.getValue(i)); schemaValidator.startElement(makeQName(namespaceURI, localName, qName), attributes, null); attributes.removeAllAttributes(); } catch (XNIException e) { throw toSAXException(e); } }
public void startDocument() throws SAXException { try { schemaValidator.startDocument(locator == null ? null : this, null, namespaceContext, null); } catch (XNIException e) { throw toSAXException(e); } }
validatorComponent = new XMLSchemaValidator(); fSchemaValidationManager = new ValidationManager(); fUnparsedEntityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
fSchemaValidator.startDocument(fStAXLocationWrapper, null, fNamespaceContext, null); loop : while (reader.hasNext()) { fCurrentEvent = reader.nextEvent(); fNamespaceContext.setNamespaceContext(start.getNamespaceContext()); fStAXLocationWrapper.setLocation(start.getLocation()); fSchemaValidator.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: fillDeclaredPrefixes(end); fStAXLocationWrapper.setLocation(end.getLocation()); fSchemaValidator.endElement(fElementQName, null); if (--fDepth <= 0) { break loop; Characters chars = fCurrentEvent.asCharacters(); fStAXValidatorHandler.setIgnoringCharacters(true); fSchemaValidator.startCDATA(null); sendCharactersToValidator(fCurrentEvent.asCharacters().getData()); fSchemaValidator.endCDATA(null); fStAXValidatorHandler.setIgnoringCharacters(false); fStAXValidatorHandler.cdata(chars); fSchemaValidator.startCDATA(null); sendCharactersToValidator(fCurrentEvent.asCharacters().getData()); fSchemaValidator.endCDATA(null); final ProcessingInstruction pi = (ProcessingInstruction) fCurrentEvent;
fSchemaValidator = new XMLSchemaValidator(); fSchemaValidator.reset(this); fSchemaValidator.setDocumentSource(fLastComponent); fSchemaValidator.setDocumentHandler(fDocumentHandler); if (fDocumentHandler != null) { fDocumentHandler.setDocumentSource(fSchemaValidator);
fSchemaValidator = new XMLSchemaValidator(); fSchemaValidator.setDocumentSource(fLastComponent); fSchemaValidator.setDocumentHandler(fDocumentHandler); if (fDocumentHandler != null) { fDocumentHandler.setDocumentSource(fSchemaValidator);
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { try { schemaValidator.ignorableWhitespace(new XMLString(ch, start, length), null); } catch (XNIException e) { throw toSAXException(e); } }