use of com.sun.enterprise.tools.verifier.util.XMLValidationHandler in project Payara by payara.
the class TagLibFactory method init.
/**
* this method is called once to create the Documentbuilder required for
* creating documen objects from tlds
*/
private void init() {
if (!uninitialised) {
synchronized (this) {
if (!uninitialised) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// NOI18N
String W3C_XML_SCHEMA = "http://www.w3c.org/2001/XMLSchema";
// NOI18N
String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute(// NOI18N
"http://apache.org/xml/features/validation/schema", Boolean.TRUE);
factory.setAttribute(// NOI18N
"http://xml.org/sax/features/validation", Boolean.TRUE);
factory.setAttribute(// NOI18N
"http://apache.org/xml/features/allow-java-encodings", Boolean.TRUE);
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
logger.log(Level.SEVERE, e.getMessage());
}
EntityResolver dh = new XMLValidationHandler(true);
ErrorHandler eh = new XMLValidationHandler(true);
builder.setErrorHandler(eh);
builder.setEntityResolver(dh);
uninitialised = true;
}
}
}
}
use of com.sun.enterprise.tools.verifier.util.XMLValidationHandler in project Payara by payara.
the class BaseVerifier method createDOMObject.
protected void createDOMObject(InputSource source, String dd) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
EntityResolver dh = new XMLValidationHandler(false);
builder.setEntityResolver(dh);
Document document = builder.parse(source);
if ((dd.indexOf("sun-")) < 0) {
// NOI18N
if ((dd.indexOf("webservices")) < 0) {
// NOI18N
context.setDocument(document);
} else {
context.setWebServiceDocument(document);
}
} else
context.setRuntimeDocument(document);
}
use of com.sun.enterprise.tools.verifier.util.XMLValidationHandler in project Payara by payara.
the class NameToken method isNMTOKEN.
/**
* Determine is value is legal NMToken type
*
* @param value xml element to be checked
* @return <code>boolean</code> true if xml element is legal NMToken,
* false otherwise
*/
public static boolean isNMTOKEN(String value) {
/*
com.sun.enterprise.util.LocalStringManagerImpl smh =
StringManagerHelper.getLocalStringsManager();
*/
String XMLdoc = XMLtop + value + XMLbottom;
logger.log(Level.FINE, // NOI18N
"com.sun.enterprise.tools.verifier.NameToken.print", new Object[] { XMLdoc });
try {
InputSource source = new InputSource(new ByteArrayInputStream(XMLdoc.getBytes()));
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(true);
// ValidatingParser p = new ValidatingParser();
XMLReader p = spf.newSAXParser().getXMLReader();
// XMLErrorHandler eh = new XMLErrorHandler(null);
p.setErrorHandler(new XMLValidationHandler());
p.parse(source);
return true;
} catch (Exception e) {
return false;
}
}
Aggregations