You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2011/05/02 01:29:23 UTC
svn commit: r1098441 -
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
Author: mukulg
Date: Sun May 1 23:29:22 2011
New Revision: 1098441
URL: http://svn.apache.org/viewvc?rev=1098441&view=rev
Log:
solving a potential null pointer exception.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java?rev=1098441&r1=1098440&r2=1098441&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java Sun May 1 23:29:22 2011
@@ -173,7 +173,7 @@ public class XSAssertionXPath2ValueImpl
XSObjectList memberTypes = itemType.getMemberTypes();
if (memberTypes.getLength() > 0) {
// the list's item type has variety 'union'
- XSSimpleTypeDefinition actualListItemType = getActualListItemTypeForVarietyUnion(memberTypes, listStrValue);
+ XSSimpleTypeDefinition actualListItemType = getActualXDMItemTypeForSTVarietyUnion(memberTypes, listStrValue);
// set a schema 'typed value' to variable $value
setXDMTypedValueOf$value(rootNodeOfAssertTree, listStrValue, actualListItemType, null, false, xpath2DynamicContext);
}
@@ -219,7 +219,7 @@ public class XSAssertionXPath2ValueImpl
// itemType of xs:list has variety 'union'. here list items may have different types which are determined below.
while (values.hasMoreTokens()) {
String itemValue = values.nextToken();
- XSSimpleTypeDefinition listItemTypeForUnion = getActualListItemTypeForVarietyUnion(memberTypes, itemValue);
+ XSSimpleTypeDefinition listItemTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(memberTypes, itemValue);
xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue));
}
}
@@ -236,9 +236,10 @@ public class XSAssertionXPath2ValueImpl
}
else if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
// simple content type has variety xs:union
- XSSimpleTypeDefinition simpleContentTypeForUnion = getActualListItemTypeForVarietyUnion(complexTypeSimplContentType.getMemberTypes(), value);
- xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"),
- SchemaTypeValueFactory.newSchemaTypeValue(simpleContentTypeForUnion.getBuiltInKind(), value));
+ XSSimpleTypeDefinition simpleContentTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(complexTypeSimplContentType.getMemberTypes(), value);
+ if (simpleContentTypeForUnion != null) {
+ xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), SchemaTypeValueFactory.newSchemaTypeValue(simpleContentTypeForUnion.getBuiltInKind(), value));
+ }
}
else {
// simple content type has variety atomic
@@ -280,25 +281,25 @@ public class XSAssertionXPath2ValueImpl
/*
- * Find the actual schema type of "list item" instance if the "item type" of list has variety union.
+ * Find the actual schema type of XDM item instance, if source schema type is simpleType with variety union.
*/
- private XSSimpleTypeDefinition getActualListItemTypeForVarietyUnion(XSObjectList memberTypes, String listItemStrValue) {
+ private XSSimpleTypeDefinition getActualXDMItemTypeForSTVarietyUnion(XSObjectList memberTypes, String xdmItemStrValue) {
- XSSimpleTypeDefinition listItemType = null;
+ XSSimpleTypeDefinition xdmItemType = null;
// iterate the member types of union in order, to find that which schema type can successfully validate an atomic value first
final int memberTypesLength = memberTypes.getLength();
for (int memTypeIdx = 0; memTypeIdx < memberTypesLength; memTypeIdx++) {
XSSimpleType memSimpleType = (XSSimpleType) memberTypes.item(memTypeIdx);
- if (XSTypeHelper.isValueValidForASimpleType(listItemStrValue, memSimpleType)) {
+ if (XSTypeHelper.isValueValidForASimpleType(xdmItemStrValue, memSimpleType)) {
// no more memberTypes need to be checked
- listItemType = memSimpleType;
+ xdmItemType = memSimpleType;
break;
}
}
- return listItemType;
+ return xdmItemType;
- } // getActualListItemTypeForVarietyUnion
+ } // getActualXDMItemTypeForSTVarietyUnion
} // class XSAssertionXPath2ValueImpl
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org