You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2011/09/09 19:29:56 UTC
svn commit: r1167302 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs:
alternative/Test.java traversers/XSDTypeAlternativeTraverser.java
Author: sandygao
Date: Fri Sep 9 17:29:55 2011
New Revision: 1167302
URL: http://svn.apache.org/viewvc?rev=1167302&view=rev
Log:
Fixing a potential NPE. When a CTA XPath is invalid, we store "null" in the Test object, whose toString() method would produce an NPE in this case.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java?rev=1167302&r1=1167301&r2=1167302&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/Test.java Fri Sep 9 17:29:55 2011
@@ -44,6 +44,9 @@ public class Test extends AbstractPsycho
/** The type alternative to which the test belongs */
protected final XSTypeAlternativeImpl fTypeAlternative;
+
+ /** String representation of the XPath */
+ protected final String fExpression;
/** XPath 2.0 expression. Xerces-J native XPath 2.0 subset. */
protected final XPath20 fXPath;
@@ -57,6 +60,7 @@ public class Test extends AbstractPsycho
/** Constructs a "test" for type alternatives */
public Test(XPath20 xpath, XSTypeAlternativeImpl typeAlternative, NamespaceSupport namespaceContext) {
fXPath = xpath;
+ fExpression = xpath == null ? "" : xpath.getXPathStrValue();
fXPathPsychoPath = null;
fTypeAlternative = typeAlternative;
fXPath2NamespaceContext = namespaceContext;
@@ -65,8 +69,9 @@ public class Test extends AbstractPsycho
/*
* Constructs a "test" for type alternatives. An overloaded constructor, for PsychoPath XPath processor.
*/
- public Test(XPath xpath, XSTypeAlternativeImpl typeAlternative, NamespaceSupport namespaceContext) {
+ public Test(XPath xpath, String expression, XSTypeAlternativeImpl typeAlternative, NamespaceSupport namespaceContext) {
fXPath = null;
+ fExpression = expression == null ? "" : expression;
fXPathPsychoPath = xpath;
fTypeAlternative = typeAlternative;
fXPath2NamespaceContext = namespaceContext;
@@ -109,7 +114,7 @@ public class Test extends AbstractPsycho
}
public String toString() {
- return fXPath.getXPathStrValue();
+ return fExpression;
}
/*
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java?rev=1167302&r1=1167301&r2=1167302&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java Fri Sep 9 17:29:55 2011
@@ -196,7 +196,7 @@ class XSDTypeAlternativeTraverser extend
// if full XPath 2.0 support is enabled for CTA, use PsychoPath XPath 2.0 engine for XPath evaluation
XPathParser xpp = new JFlexCupParser();
XPath xp = xpp.parse("boolean(" + testStr + ")");
- testExpr = new Test(xp, typeAlternative, schemaDoc.fNamespaceSupport);
+ testExpr = new Test(xp, testStr, typeAlternative, schemaDoc.fNamespaceSupport);
}
else {
// if XPath subset is enabled for CTA (this is also the default option), use Xerces's native XPath parser for CTA
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org