Author: mrglavas
Date: Thu Aug 7 21:12:37 2008
New Revision: 683837
URL: http://svn.apache.org/viewvc?rev=683837&view=rev
Log:
JIRA Issue #1316:
http://issues.apache.org/jira/browse/XERCESJ-1316
JAXP 1.4 now allows applications to call getElementTypeInfo() during an
endElement()
callback. Modifying the implementation of TypeInfoProvider to allow it.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/msg/JAXPValidationMessages.properties
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/msg/JAXPValidationMessages.properties
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/msg/JAXPValidationMessages.properties?rev=683837&r1=683836&r2=683837&view=diff
==============================================================================
---
xerces/java/trunk/src/org/apache/xerces/impl/msg/JAXPValidationMessages.properties
(original)
+++
xerces/java/trunk/src/org/apache/xerces/impl/msg/JAXPValidationMessages.properties
Thu Aug 7 21:12:37 2008
@@ -31,18 +31,20 @@
SchemaSourceArrayNull = The Source array parameter cannot be null.
SchemaSourceArrayMemberNull = The Source array parameter cannot contain any
items that are null.
SchemaFactorySourceUnrecognized = Source parameter of type ''{0}'' is not
recognized by this SchemaFactory.
+SAXSourceNullInputSource = The SAXSource specified contains no InputSource.
# Validator error messages
SourceParameterNull = Source parameter cannot be null.
SourceNotAccepted = Source parameter of type ''{0}'' is not accepted by this
validator.
SourceResultMismatch = Source parameter of type ''{0}'' is not compatible with
result parameter of type ''{1}''.
StAXIllegalInitialState = Expecting the initial state to be start document or
start element.
+StreamResultNotInitialized = The StreamResult contains no OutputStream,
Writer, or system ID.
# TypeInfoProvider error messages
-TypeInfoProviderIllegalState = A TypeInfoProvider cannot be queried outside of
a startElement callback.
+TypeInfoProviderIllegalStateElement = Element type information cannot be
queried from a TypeInfoProvider outside of a startElement or endElement
callback.
+TypeInfoProviderIllegalStateAttribute = Attribute type information cannot be
queried from a TypeInfoProvider outside of a startElement callback.
# General error messages
FeatureNameNull = The feature name cannot be null.
ProperyNameNull = The property name cannot be null.
-SAXSourceNullInputSource = The SAXSource specified contains no InputSource.
Modified:
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java?rev=683837&r1=683836&r2=683837&view=diff
==============================================================================
---
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
(original)
+++
xerces/java/trunk/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
Thu Aug 7 21:12:37 2008
@@ -233,7 +233,7 @@
return fTypeInfoProvider;
}
- public boolean getFeature(String name)
+ public boolean getFeature(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (name == null) {
throw new NullPointerException();
@@ -834,6 +834,7 @@
/** In start element. **/
private boolean fInStartElement = false;
+ private boolean fInEndElement = false;
/** Initializes the TypeInfoProvider with type information for the
current element. **/
void beginStartElement(Augmentations elementAugs, XMLAttributes
attributes) {
@@ -851,72 +852,92 @@
/** Initializes the TypeInfoProvider with type information for the
current element. **/
void beginEndElement(Augmentations elementAugs) {
+ fInEndElement = true;
fElementAugs = elementAugs;
}
/** Cleanup at the end of end element. **/
void finishEndElement() {
+ fInEndElement = false;
fElementAugs = null;
}
/**
* Throws a [EMAIL PROTECTED] IllegalStateException} if we are not in
* the startElement callback. the JAXP API requires this
- * for most of the public methods.
+ * for most of the public methods which access attribute
+ * type information.
*/
- private void checkState() {
- if( !fInStartElement ) {
+ private void checkStateAttribute() {
+ if (!fInStartElement) {
throw new
IllegalStateException(JAXPValidationMessageFormatter.formatMessage(Locale.getDefault(),
- "TypeInfoProviderIllegalState", null));
+ "TypeInfoProviderIllegalStateAttribute", null));
+ }
+ }
+
+ /**
+ * Throws a [EMAIL PROTECTED] IllegalStateException} if we are not in
+ * the startElement or endElement callbacks. the JAXP API requires
+ * this for the public methods which access element type information.
+ */
+ private void checkStateElement() {
+ if (!fInStartElement && !fInEndElement) {
+ throw new
IllegalStateException(JAXPValidationMessageFormatter.formatMessage(Locale.getDefault(),
+ "TypeInfoProviderIllegalStateElement", null));
}
}
public TypeInfo getAttributeTypeInfo(int index) {
- checkState();
+ checkStateAttribute();
return getAttributeType(index);
}
private TypeInfo getAttributeType( int index ) {
- checkState();
- if( index<0 || fAttributes.getLength()<=index )
+ checkStateAttribute();
+ if (index < 0 || fAttributes.getLength() <= index) {
throw new IndexOutOfBoundsException(Integer.toString(index));
+ }
Augmentations augs = fAttributes.getAugmentations(index);
- if (augs == null) return null;
+ if (augs == null) {
+ return null;
+ }
AttributePSVI psvi =
(AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
return getTypeInfoFromPSVI(psvi);
}
public TypeInfo getAttributeTypeInfo(String attributeUri, String
attributeLocalName) {
- checkState();
+ checkStateAttribute();
return
getAttributeTypeInfo(fAttributes.getIndex(attributeUri,attributeLocalName));
}
public TypeInfo getAttributeTypeInfo(String attributeQName) {
- checkState();
+ checkStateAttribute();
return getAttributeTypeInfo(fAttributes.getIndex(attributeQName));
}
public TypeInfo getElementTypeInfo() {
- checkState();
- if (fElementAugs == null) return null;
+ checkStateElement();
+ if (fElementAugs == null) {
+ return null;
+ }
ElementPSVI psvi =
(ElementPSVI)fElementAugs.getItem(Constants.ELEMENT_PSVI);
return getTypeInfoFromPSVI(psvi);
}
- private TypeInfo getTypeInfoFromPSVI( ItemPSVI psvi ) {
- if(psvi==null) return null;
-
+ private TypeInfo getTypeInfoFromPSVI(ItemPSVI psvi) {
+ if (psvi == null) {
+ return null;
+ }
// TODO: make sure if this is correct.
// TODO: since the number of types in a schema is quite limited,
// TypeInfoImpl should be pooled. Even better, it should be a part
// of the element decl.
- if( psvi.getValidity()== ElementPSVI.VALIDITY_VALID ) {
+ if (psvi.getValidity() == ItemPSVI.VALIDITY_VALID) {
XSTypeDefinition t = psvi.getMemberTypeDefinition();
if (t != null) {
return (t instanceof TypeInfo) ? (TypeInfo) t : null;
}
}
-
XSTypeDefinition t = psvi.getTypeDefinition();
// TODO: can t be null?
if (t != null) {
@@ -926,14 +947,16 @@
}
public boolean isIdAttribute(int index) {
- checkState();
+ checkStateAttribute();
XSSimpleType type = (XSSimpleType)getAttributeType(index);
- if(type==null) return false;
+ if (type == null) {
+ return false;
+ }
return type.isIDType();
}
public boolean isSpecified(int index) {
- checkState();
+ checkStateAttribute();
return fAttributes.isSpecified(index);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]