private boolean findIncludeNode(Node checkNode, String mtomElement) { boolean ret = false; NodeList nList = checkNode.getChildNodes(); for (int i = 0; i < nList.getLength(); i++) { Node nNode = nList.item(i); if (nNode.getLocalName() != null && nNode.getLocalName().equals(mtomElement)) { NodeList subNodeList = nNode.getChildNodes(); for (int j = 0; j < subNodeList.getLength(); j++) { Node subNode = subNodeList.item(j); if ("http://www.w3.org/2004/08/xop/include".equals(subNode.getNamespaceURI()) && "Include".equals(subNode.getLocalName())) { // This is the Mtom element which break the SchemaValidation so ignore this return true; } } } else { ret = findIncludeNode(nNode, mtomElement); } } return ret; } }
Validator schemaValidator = schema.newValidator(); schemaValidator.setErrorHandler( new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), domSource.getNode())); schemaValidator.validate(domSource); StaxUtils.copy(domSource, writer); Validator schemaValidator = schema.newValidator(); schemaValidator.setErrorHandler( new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), (Node)obj)); schemaValidator.validate(new DOMSource((Node)obj)); new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), ((DOMSource)s).getNode())); schemaValidator.validate(s);
Validator schemaValidator = schema.newValidator(); schemaValidator.setErrorHandler( new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), domSource.getNode())); schemaValidator.validate(domSource); StaxUtils.copy(domSource, writer); Validator schemaValidator = schema.newValidator(); schemaValidator.setErrorHandler( new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), (Node)obj)); schemaValidator.validate(new DOMSource((Node)obj)); new MtomValidationErrorHandler(schemaValidator.getErrorHandler(), ((DOMSource)s).getNode())); schemaValidator.validate(s);
private boolean findIncludeNode(Node checkNode, String mtomElement) { boolean ret = false; NodeList nList = checkNode.getChildNodes(); for (int i = 0; i < nList.getLength(); i++) { Node nNode = nList.item(i); if (nNode.getLocalName() != null && nNode.getLocalName().equals(mtomElement)) { NodeList subNodeList = nNode.getChildNodes(); for (int j = 0; j < subNodeList.getLength(); j++) { Node subNode = subNodeList.item(j); if ("http://www.w3.org/2004/08/xop/include".equals(subNode.getNamespaceURI()) && "Include".equals(subNode.getLocalName())) { // This is the Mtom element which break the SchemaValidation so ignore this return true; } } } else { ret = findIncludeNode(nNode, mtomElement); } } return ret; } }
@Override public void error(SAXParseException exception) throws SAXException { if (this.isCVC312Exception(exception)) { String elementName = this.getAttachmentElementName(exception); if (node != null && this.findIncludeNode(node, elementName)) { return; } } if (this.origErrorHandler != null) { this.origErrorHandler.error(exception); } else { throw exception; } }
@Override public void error(SAXParseException exception) throws SAXException { if (this.isCVC312Exception(exception)) { String elementName = this.getAttachmentElementName(exception); if (node != null && this.findIncludeNode(node, elementName)) { return; } } if (this.origErrorHandler != null) { this.origErrorHandler.error(exception); } else { throw exception; } }