You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/09/08 04:41:35 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/jaxp/validation ValidatorHandlerImpl.java
mrglavas 2005/09/07 19:41:35
Modified: java/src/org/apache/xerces/jaxp/validation
ValidatorHandlerImpl.java
Log:
If a LexicalHandler has been specified on the SAXResult forward
lexical events from the parser to the application's LexicalHandler.
Revision Changes Path
1.3 +19 -2 xml-xerces/java/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
Index: ValidatorHandlerImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ValidatorHandlerImpl.java 13 Jun 2005 21:57:00 -0000 1.2
+++ ValidatorHandlerImpl.java 8 Sep 2005 02:41:34 -0000 1.3
@@ -78,6 +78,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.ext.Attributes2;
import org.xml.sax.ext.EntityResolver2;
+import org.xml.sax.ext.LexicalHandler;
/**
* <p>Implementation of ValidatorHandler for W3C XML Schemas and
@@ -107,6 +108,10 @@
private static final String ERROR_REPORTER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
+ /** Property identifier: lexical handler. */
+ private static final String LEXICAL_HANDLER =
+ Constants.SAX_PROPERTY_PREFIX + Constants.LEXICAL_HANDLER_PROPERTY;
+
/** Property identifier: namespace context. */
private static final String NAMESPACE_CONTEXT =
Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
@@ -646,8 +651,15 @@
final SAXSource saxSource = (SAXSource) source;
final SAXResult saxResult = (SAXResult) result;
+ LexicalHandler lh = null;
if (result != null) {
- setContentHandler(saxResult.getHandler());
+ ContentHandler ch = saxResult.getHandler();
+ lh = saxResult.getLexicalHandler();
+ /** If the lexical handler is not set try casting the ContentHandler. **/
+ if (lh == null && ch instanceof LexicalHandler) {
+ lh = (LexicalHandler) ch;
+ }
+ setContentHandler(ch);
}
try {
@@ -692,6 +704,11 @@
fResolutionForwarder.setEntityResolver(fComponentManager.getResourceResolver());
reader.setContentHandler(this);
reader.setDTDHandler(this);
+ try {
+ reader.setProperty(LEXICAL_HANDLER, lh);
+ }
+ // Ignore the exception if the lexical handler cannot be set.
+ catch (SAXException exc) {}
InputSource is = saxSource.getInputSource();
reader.parse(is);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org