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 2009/09/19 18:45:28 UTC
svn commit: r816941 - in /xerces/java/branches/xml-schema-1.1-dev:
src/org/apache/xerces/impl/xs/ src/org/apache/xerces/impl/xs/alternative/
src/org/apache/xerces/impl/xs/assertion/
src/org/apache/xerces/impl/xs/traversers/ tools/
Author: mukulg
Date: Sat Sep 19 16:45:27 2009
New Revision: 816941
URL: http://svn.apache.org/viewvc?rev=816941&view=rev
Log:
implemented xpathDefaultNamespace attribute on XML Schema 1.1 assertions. updated PsychoPath JAR as well (with JRE 1.3 level), to handle xpathDefaultNamespace.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
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/assertion/Test.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java
xerces/java/branches/xml-schema-1.1-dev/tools/org.eclipse.wst.xml.xpath2.processor_1.0.0.jar
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AbstractPsychoPathImpl.java Sat Sep 19 16:45:27 2009
@@ -42,7 +42,6 @@
* A base class, providing common services for XPath 2.0 evaluation, with PsychoPath.
*
* @author Mukul Gandhi, IBM
- *
* @version $Id: AbstractPsychoPathImpl.java 814163 2009-09-12 13:43:19Z mukulg $
*/
public class AbstractPsychoPathImpl {
@@ -50,7 +49,8 @@
private DynamicContext fDynamicContext = null;
private Document domDoc = null;
- protected DynamicContext initDynamicContext(XSModel schema, Document document) {
+ protected DynamicContext initDynamicContext(XSModel schema,
+ Document document) {
fDynamicContext = new DefaultDynamicContext(schema, document);
fDynamicContext.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
fDynamicContext.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
@@ -61,17 +61,23 @@
return fDynamicContext;
} //initDynamicContext
- protected boolean evaluatePsychoPathExpr(XPath xp, Element contextNode)
- throws StaticError, DynamicError {
+ protected boolean evaluatePsychoPathExpr(XPath xp,
+ String xPathDefaultNamespace,
+ Element contextNode)
+ throws StaticError, DynamicError {
+ if (xPathDefaultNamespace != null) {
+ fDynamicContext.add_namespace(null, xPathDefaultNamespace);
+ }
StaticChecker sc = new StaticNameResolver(fDynamicContext);
sc.check(xp);
-
+
Evaluator eval = new DefaultEvaluator(fDynamicContext, domDoc);
// change focus to the top most element
ResultSequence nodeEvalRS = ResultSequenceFactory.create_new();
nodeEvalRS.add(new ElementType(contextNode,
fDynamicContext.node_position(contextNode)));
+
fDynamicContext.set_focus(new Focus(nodeEvalRS));
ResultSequence rs = eval.evaluate(xp);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java Sat Sep 19 16:45:27 2009
@@ -230,11 +230,13 @@
}
try {
- boolean result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp, currentAssertDomNode);
+ boolean result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp,
+ assertImpl.getXPathDefaultNamespace(),
+ currentAssertDomNode);
if (!result) {
- // assertion evaluation is false
- reportError("cvc-assertion.3.13.4.1", element, assertImpl);
+ // assertion evaluation is false
+ reportError("cvc-assertion.3.13.4.1", element, assertImpl);
}
} catch (Exception ex) {
reportError("cvc-assertion.3.13.4.1", element, assertImpl);
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=816941&r1=816940&r2=816941&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 Sat Sep 19 16:45:27 2009
@@ -122,7 +122,9 @@
document.appendChild(elem);
initDynamicContext(null, document);
- result = evaluatePsychoPathExpr(fXPathPsychoPath, elem);
+ result = evaluatePsychoPathExpr(fXPathPsychoPath,
+ fTypeAlternative.fXPathDefaultNamespace,
+ elem);
} catch(ParserConfigurationException ex) {
result = false;
} catch (StaticError ex) {
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/Test.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/Test.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/Test.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/Test.java Sat Sep 19 16:45:27 2009
@@ -21,7 +21,7 @@
import org.apache.xerces.xs.XSAssert;
/**
- * XML schema assertion 'test' attribute
+ * Representation of XML Schema 1.1 assertion "test" attribute.
*
* @author Mukul Gandhi, IBM
* @version $Id$
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java Sat Sep 19 16:45:27 2009
@@ -24,7 +24,7 @@
import org.apache.xerces.xs.XSTypeDefinition;
/**
- * XML Schema 1.1 assertion component
+ * XML Schema 1.1 'assertion' component
*
* @author Mukul Gandhi, IBM
* @version $Id$
@@ -34,7 +34,7 @@
/** The type definition associated with the assertion component */
protected XSTypeDefinition fTypeDefinition;
- /** An XPath 2.0 expression that represents the test attribute */
+ /** An XPath 2.0 expression that represents the 'test' attribute */
protected Test fTestExpr = null;
/** Optional annotations */
@@ -115,7 +115,7 @@
}
/*
- * Tests if two asserts are equal
+ * Tests if two assert components are equal
*/
public boolean equals(XSAssertImpl assertComponent) {
boolean returnVal = false;
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java Sat Sep 19 16:45:27 2009
@@ -282,7 +282,7 @@
}
/*
- * Helper method to find all assertions up in the type hierarchy
+ * Method to find all assertions up in the type hierarchy
*/
private void getAssertsFromBaseTypes(XSSimpleType baseValidator) {
XSObjectList multiValFacetsOfBaseType = baseValidator.getMultiValueFacets();
@@ -290,7 +290,7 @@
for (int i = 0; i < multiValFacetsOfBaseType.getLength(); i++) {
XSMultiValueFacet mvFacet = (XSMultiValueFacet) multiValFacetsOfBaseType.item(i);
if (mvFacet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
- // add asserts of this type to the global Vector object
+ // add asserts to the global Vector object
Vector assertsToAdd = mvFacet.getAsserts();
for (int j = 0; j < assertsToAdd.size(); j++) {
// add assertion to the list, only if it's already not present
@@ -305,8 +305,8 @@
// invoke the method recursively. go up the type hierarchy.
if (baseValidator.getBaseType() != null) {
getAssertsFromBaseTypes((XSSimpleType)baseValidator.getBaseType());
- }
- }
+ }
+ } // getAssertsFromBaseTypes
/*
* Check if an assertion already exists in the buffer
@@ -321,8 +321,8 @@
}
}
- return assertExists;
- } // end of method, assertExists
+ return assertExists;
+ } // assertExists
@@ -428,12 +428,15 @@
reportSchemaError("s4s-elt-must-match.1", new Object[]{"pattern", "(annotation?)", DOMUtil.getLocalName(child)}, child);
}
}
- // process 'assertion' facet. introduced in XML Schema 1.1.
+ // process 'assertion' facet. introduced in XML Schema 1.1
else if (facet.equals(SchemaSymbols.ELT_ASSERTION)) {
attrs = fAttrChecker.checkAttributes(content, false, schemaDoc);
String test = (String) attrs[XSAttributeChecker.ATTIDX_XPATH];
- String defaultNamespace = (String) attrs[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
-
+ String xpathDefaultNamespace = (String) attrs[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
+ if (xpathDefaultNamespace == null) {
+ xpathDefaultNamespace = schemaDoc.fXpathDefaultNamespace;
+ }
+
if (test != null) {
// get 'annotation'
Element childNode = DOMUtil.getFirstChildElement(content);
@@ -474,7 +477,7 @@
Test testExpr = new Test(new XPath20Assert(test, fSymbolTable,
schemaDoc.fNamespaceSupport), assertImpl);
assertImpl.setTest(testExpr);
- assertImpl.setXPathDefauleNamespace(defaultNamespace);
+ assertImpl.setXPathDefauleNamespace(xpathDefaultNamespace);
if (assertData == null) {
assertData = new Vector();
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Sat Sep 19 16:45:27 2009
@@ -1288,7 +1288,7 @@
private void getAssertsFromBaseTypes(XSTypeDefinition baseValidator) {
if (baseValidator != null && baseValidator instanceof XSComplexTypeDefinition) {
XSObjectList assertList = ((XSComplexTypeDefinition) baseValidator)
- .getAssertions();
+ .getAssertions();
for (int i = 0; i < assertList.size(); i++) {
// add assertion to the list, only if it's already not present
if (!assertExists((XSAssertImpl) assertList.get(i))) {
@@ -1548,8 +1548,11 @@
Object[] attrValues = fAttrChecker.checkAttributes(assertElement,
false, schemaDoc);
String test = (String) attrValues[XSAttributeChecker.ATTIDX_XPATH];
- String defaultNamespace = (String) attrValues[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
-
+ String xpathDefaultNamespace = (String) attrValues[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
+ if (xpathDefaultNamespace == null) {
+ xpathDefaultNamespace = schemaDoc.fXpathDefaultNamespace;
+ }
+
if (test != null) {
// get 'annotation'
Element childNode = DOMUtil.getFirstChildElement(assertElement);
@@ -1574,7 +1577,7 @@
String text = DOMUtil.getSyntheticAnnotation(childNode);
if (text != null) {
annotation = traverseSyntheticAnnotation(childNode, text,
- attrValues, false, schemaDoc);
+ attrValues, false, schemaDoc);
}
}
@@ -1591,8 +1594,9 @@
Test testExpr = new Test(new XPath20Assert(test, fSymbolTable,
schemaDoc.fNamespaceSupport), assertImpl);
assertImpl.setTest(testExpr);
- assertImpl.setXPathDefauleNamespace(defaultNamespace);
+ assertImpl.setXPathDefauleNamespace(xpathDefaultNamespace);
+ // add assertion object to an array buffer
addAssertion(assertImpl);
Element sibling = DOMUtil.getNextSiblingElement(assertElement);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java Sat Sep 19 16:45:27 2009
@@ -33,7 +33,7 @@
import org.w3c.dom.Element;
/**
- * Objects of this class hold all information pecular to a
+ * Objects of this class hold all information peculiar to a
* particular XML Schema document. This is needed because
* namespace bindings and other settings on the <schema/> element
* affect the contents of that schema document alone.
@@ -62,6 +62,9 @@
// targetNamespace
String fTargetNamespace;
+
+ // xpathDefaultNamespace
+ String fXpathDefaultNamespace;
// represents whether this is a chameleon schema (i.e., whether its TNS is natural or comes from without)
protected boolean fIsChameleonSchema;
@@ -134,6 +137,9 @@
(String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
if (fTargetNamespace != null)
fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);
+
+ fXpathDefaultNamespace =
+ (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);
Modified: xerces/java/branches/xml-schema-1.1-dev/tools/org.eclipse.wst.xml.xpath2.processor_1.0.0.jar
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/tools/org.eclipse.wst.xml.xpath2.processor_1.0.0.jar?rev=816941&r1=816940&r2=816941&view=diff
==============================================================================
Binary files - no diff available.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org