Author: mrglavas
Date: Sat Feb 25 13:26:43 2006
New Revision: 380997
URL: http://svn.apache.org/viewcvs?rev=380997&view=rev
Log:
Use the http://apache.org/xml/properties/dom/current-element-node property to
expose the current element node being processed by the validator. This property
can be queried from an ErrorHandler to determine the approximate location of
the error in the DOM.
Modified:
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
Modified:
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
URL:
http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java?rev=380997&r1=380996&r2=380997&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
(original)
+++ xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
Sat Feb 25 13:26:43 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005,2006 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.
@@ -26,6 +26,7 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Validator;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.SAXMessageFormatter;
import org.apache.xerces.xni.parser.XMLConfigurationException;
import org.apache.xerces.xs.AttributePSVI;
@@ -47,6 +48,12 @@
*/
final class ValidatorImpl extends Validator implements PSVIProvider {
+ // property identifiers
+
+ /** Property identifier: Current element node. */
+ private static final String CURRENT_ELEMENT_NODE =
+ Constants.XERCES_PROPERTY_PREFIX +
Constants.CURRENT_ELEMENT_NODE_PROPERTY;
+
//
// Data
//
@@ -173,6 +180,10 @@
if (name == null) {
throw new NullPointerException();
}
+ if (CURRENT_ELEMENT_NODE.equals(name)) {
+ return (fDOMValidatorHelper != null) ?
+ fDOMValidatorHelper.getCurrentElement() : null;
+ }
try {
return fComponentManager.getProperty(name);
}
@@ -190,6 +201,11 @@
throws SAXNotRecognizedException, SAXNotSupportedException {
if (name == null) {
throw new NullPointerException();
+ }
+ if (CURRENT_ELEMENT_NODE.equals(name)) {
+ throw new SAXNotSupportedException(
+ SAXMessageFormatter.formatMessage(Locale.getDefault(),
+ "property-read-only", new Object [] {name}));
}
try {
fComponentManager.setProperty(name, object);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]