src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java
Print this page
@@ -1,15 +1,15 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,21 +20,23 @@
package com.sun.org.apache.xerces.internal.jaxp.validation;
import java.io.IOException;
-import javax.xml.XMLConstants;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stax.StAXResult;
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Validator;
import com.sun.org.apache.xerces.internal.impl.Constants;
+import static com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.ENTITY_RESOLVER;
+import static com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.ERROR_HANDLER;
+import com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper;
+import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.Status;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
@@ -81,16 +83,24 @@
/** Flag for tracking whether the resource resolver changed since last reset. */
private boolean fResourceResolverChanged = false;
/** Support current-element-node property */
- private static final String CURRENT_ELEMENT_NODE = Constants.XERCES_PROPERTY_PREFIX + Constants.CURRENT_ELEMENT_NODE_PROPERTY;
+ private static final String CURRENT_ELEMENT_NODE =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.CURRENT_ELEMENT_NODE_PROPERTY;
public ValidatorImpl(XSGrammarPoolContainer grammarContainer) {
fComponentManager = new XMLSchemaValidatorComponentManager(grammarContainer);
- setErrorHandler(null);
- setResourceResolver(null);
+ ErrorHandlerWrapper ehWrapper =
+ (ErrorHandlerWrapper)grammarContainer.getProperty(ERROR_HANDLER);
+ ErrorHandler eh = (ehWrapper == null) ? null : ehWrapper.getErrorHandler();
+ setErrorHandler(eh);
+
+ DOMEntityResolverWrapper erWrapper =
+ (DOMEntityResolverWrapper)grammarContainer.getProperty(ENTITY_RESOLVER);
+ LSResourceResolver er = (erWrapper == null) ? null : erWrapper.getEntityResolver();
+ setResourceResolver(er);
}
public void validate(Source source, Result result)
throws SAXException, IOException {
if (source instanceof SAXSource) {