Author: mukulg Date: Sun Nov 6 16:12:05 2011 New Revision: 1198396 URL: http://svn.apache.org/viewvc?rev=1198396&view=rev Log: schema 1.1 commit: similar to the assertions behavior when, the XPath expression contains tokens '/' or '//' we used to raise warning for the schema (since an assert XDM tree is rooted at a parentless element), i've implemented the same behavior for CTA while working in XPath full mode (where that's also the case; the CTA XDM tree is also rooted at a parentless element).
there are also few minor refactoring code base changes. Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.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/msg/XMLSchemaMessages.properties URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1198396&r1=1198395&r2=1198396&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Sun Nov 6 16:12:05 2011 @@ -112,7 +112,7 @@ cvc-assertions-valid-union-elem = cvc-assertions-valid-union-elem: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{2}'' on element ''{1}''. cvc-assertions-valid-union-attr = cvc-assertions-valid-union-attr: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{3}'' on attribute ''{2}'/@'{1}''. cvc-xpath.3.13.4.2a = cvc-xpath.3.13.4.2a: XPST0003 - Assertion XPath expression (''{0}'') on the schema type ''{1}'' couldn''t compile successfully. - cvc-xpath.3.13.4.2b = cvc-xpath.3.13.4.2b: An assert XPath expression such as (''{0}'') beginning with / or //, on the schema type ''{1}'', cannot yield a valid node (since an assert tree is rooted at a parentless element). + cvc-xpath.3.13.4.2b = cvc-xpath.3.13.4.2b: An assert XPath expression such as (''{0}'') containing / or //, on the schema type ''{1}'', cannot yield a valid result (since an assert tree is rooted at a parentless element). #schema valid (3.X.3) @@ -349,6 +349,7 @@ c-general-xpath = c-general-xpath: The expression ''{0}'' is not valid with respect to the XPath subset supported by XML Schema. c-general-xpath-ns = c-general-xpath-ns: A namespace prefix in XPath expression ''{0}'' was not bound to a namespace. c-cta-xpath = c-cta-xpath: The XPath expression ''{0}'' couldn''t compile successfully in ''{1}'' mode, during CTA evaluation. + c-cta-xpath-b = c-cta-xpath-b: The CTA XPath expression such as (''{0}'') containing / or //, while in ''{1}'' mode, cannot yield a valid result (since a CTA tree is rooted at a parentless element). c-cta-xpath-serr = c-cta-xpath-serr: The XPath expression ''{0}'' couldn''t compile successfully in ''{1}'' mode, during CTA evaluation. A static error ''{2}'' occured in the XPath expression. c-selector-xpath = c-selector-xpath: The selector value = ''{0}'' is not valid; selector xpaths cannot contain attributes. EmptyTargetNamespace = EmptyTargetNamespace: In schema document ''{0}'', the value of the ''targetNamespace'' attribute cannot be an empty string. Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java?rev=1198396&r1=1198395&r2=1198396&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathXPath2Impl.java Sun Nov 6 16:12:05 2011 @@ -162,8 +162,8 @@ public class AbstractPsychoPathXPath2Imp try { xpathObject = xpathParser.parse("boolean(" + xpathStr + ")", true); } catch (XPathParserException ex) { - // error compiling XPath expression - if (SchemaSymbols.ASSERT_XPATHEXPR_COMPILE_ERR_MESG_1.equals(ex.getMessage())) { + // XPath parser exception + if (SchemaSymbols.XS11_XPATHEXPR_COMPILE_WRN_MESG_1.equals(ex.getMessage())) { fSchemaHandler.reportSchemaWarning("cvc-xpath.3.13.4.2b", new Object[] {assertImpl.getTest().getXPathStr(), XSTypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem); } else { Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java?rev=1198396&r1=1198395&r2=1198396&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java Sun Nov 6 16:12:05 2011 @@ -258,7 +258,7 @@ public final class SchemaSymbols { // a placeholder definition used for assertions error messages public static final String ASSERT_ERRORMSG_PLACEHOLDER_REGEX = "\\{\\$value\\}"; - // compile error message string when an assert XPath expression starts with tokens '/' or '//'. - public static final String ASSERT_XPATHEXPR_COMPILE_ERR_MESG_1 = "Expression starts with / or //"; + // warning message string when an assert or, a CTA XPath expression (in full mode) contains tokens '/' or '//' + public static final String XS11_XPATHEXPR_COMPILE_WRN_MESG_1 = "Expression starts with / or //"; } 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=1198396&r1=1198395&r2=1198396&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 Sun Nov 6 16:12:05 2011 @@ -203,7 +203,7 @@ class XSDTypeAlternativeTraverser extend if (fIsFullXPathModeForCTA) { // 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 + ")"); + XPath xp = xpp.parse("boolean(" + testStr + ")", true); Map psychoPathParams = new HashMap(); psychoPathParams.put(Constants.XPATH2_NAMESPACE_CONTEXT, schemaDoc.fNamespaceSupport); AbstractPsychoPathXPath2Impl abstractPsychoPathInst = new AbstractPsychoPathXPath2Impl(); @@ -212,7 +212,7 @@ class XSDTypeAlternativeTraverser extend 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 + // if XPath subset is enabled for CTA (this is also the default option), use Xerces native XPath parser for CTA testExpr = new Test(new XPath20(testStr, fSymbolTable, new NamespaceSupport(schemaDoc.fNamespaceSupport)), typeAlternative, new NamespaceSupport(schemaDoc.fNamespaceSupport)); } } @@ -222,9 +222,14 @@ class XSDTypeAlternativeTraverser extend reportSchemaError("c-cta-xpath", new Object[] {testStr, fctaXPathModes[0]}, altElement); } catch(XPathParserException ex) { - // if XPath expression couldn't compile, create a "test" without an expression + // XPath parser exception. create a "test" without an expression. testExpr = new Test((XPath20) null, typeAlternative, new NamespaceSupport(schemaDoc.fNamespaceSupport)); - reportSchemaError("c-cta-xpath", new Object[] {testStr, fctaXPathModes[1]}, altElement); + if (SchemaSymbols.XS11_XPATHEXPR_COMPILE_WRN_MESG_1.equals(ex.getMessage())) { + fSchemaHandler.reportSchemaWarning("c-cta-xpath-b", new Object[] {testStr, fctaXPathModes[1]}, altElement); + } + else { + reportSchemaError("c-cta-xpath", new Object[] {testStr, fctaXPathModes[1]}, altElement); + } } catch (StaticError serr) { // if XPath expression couldn't compile, and there's a static error in XPath expression, create a "test" without an expression testExpr = new Test((XPath20) null, typeAlternative, new NamespaceSupport(schemaDoc.fNamespaceSupport)); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org