Author: mukulg
Date: Wed Jul 29 12:01:25 2009
New Revision: 798866
URL: http://svn.apache.org/viewvc?rev=798866&view=rev
Log:
cleaned up assertions code a bit
Modified:
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/assertion/XSAssertImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertAdapter.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertHandler.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java
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=798866&r1=798865&r2=798866&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
Wed Jul 29 12:01:25 2009
@@ -62,9 +62,10 @@
* The implementation of the XPath interface. This class interfaces with the
* PsychoPath XPath 2.0 engine.
*
- * @version $Id$
* @author Mukul Gandhi, IBM
* @author Ken Cai, IBM
+ *
+ * @version $Id$
*/
public class XMLAssertPsychopathImpl extends XMLAssertAdapter {
@@ -96,12 +97,16 @@
*/
public XMLAssertPsychopathImpl() {
// initializing the class variables
+ // we use the PSVI enabled DOM implementation, so as to have typed
+ // XDM nodes.
this.assertDocument = new PSVIDocumentImpl();
this.assertRootStack = new Stack();
this.assertListStack = new Stack();
}
-
+ /*
+ * Initialize the PsychoPath XPath processor
+ */
private void initXPathProcessor() throws Exception {
validator = (XMLSchemaValidator)
getProperty("http://apache.org/xml/properties/assert/validator");
fDynamicContext = new DefaultDynamicContext(fSchema, assertDocument);
@@ -304,6 +309,9 @@
}
+ /*
+ * Method to report assertions error messages
+ */
private void reportError(String key, QName element, XSAssertImpl
assertImpl) {
XSTypeDefinition typeDef = assertImpl.getTypeDefinition();
String typeString = "";
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=798866&r1=798865&r2=798866&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
Wed Jul 29 12:01:25 2009
@@ -24,9 +24,10 @@
import org.apache.xerces.xs.XSTypeDefinition;
/**
- * XML Schema assertion component
+ * XML Schema 1.1 assertion component
*
* @author Mukul Gandhi, IBM
+ * @version $Id$
*/
public class XSAssertImpl implements XSAssert {
@@ -55,52 +56,16 @@
fTestExpr = expr;
}
+ /** Sets the assertion annotations */
public void setAnnotations(XSObjectList annotations) {
fAnnotations = annotations;
}
+ /** Sets the xpath default namespace */
public void setXPathDefauleNamespace(String namespace) {
fXPathDefaultNamespace = namespace;
}
-
- public String getXPathDefaultNamespace() {
- return fXPathDefaultNamespace;
- }
-
- /** Returns a String representation of this object */
- public String toString() {
- String s = super.toString();
- int index1 = s.lastIndexOf('$');
- if (index1 != -1) {
- return s.substring(index1 + 1);
- }
- int index2 = s.lastIndexOf('.');
- if (index2 != -1) {
- return s.substring(index2 + 1);
- }
- return s;
- }
-
- /*
- * Tests if two asserts are equal
- */
- public boolean equals(XSAssertImpl assertComponent) {
- boolean returnVal = false;
-
- String typeNameP = assertComponent.getTypeDefinition().getName();
- String xpathStrP = assertComponent.getTest().getXPath().toString();
- String typeNameThis = this.fTypeDefinition.getName();
- String xpathStrThis = this.getTest().getXPath().toString();
-
- // if type and the xpath string are same, the asserts are equal
- if (typeNameThis.equals(typeNameP) && xpathStrThis.equals(xpathStrP)) {
- returnVal = true;
- }
-
- return returnVal;
- }
-
- /** Get the optional annotations */
+
public XSObjectList getAnnotations() {
return fAnnotations;
}
@@ -112,10 +77,14 @@
public Test getTest() {
return fTestExpr;
}
-
+
public XSTypeDefinition getTypeDefinition() {
return fTypeDefinition;
}
+
+ public String getXPathDefaultNamespace() {
+ return fXPathDefaultNamespace;
+ }
/**
* @see org.apache.xerces.xs.XSObject#getName()
@@ -144,4 +113,23 @@
public short getType() {
return XSConstants.ASSERTION;
}
+
+ /*
+ * Tests if two asserts are equal
+ */
+ public boolean equals(XSAssertImpl assertComponent) {
+ boolean returnVal = false;
+
+ String typeNameP = assertComponent.getTypeDefinition().getName();
+ String xpathStrP = assertComponent.getTest().getXPath().toString();
+ String typeNameThis = this.fTypeDefinition.getName();
+ String xpathStrThis = this.getTest().getXPath().toString();
+
+ // if type and the xpath string are same, the asserts are equal
+ if (typeNameThis.equals(typeNameP) && xpathStrThis.equals(xpathStrP)) {
+ returnVal = true;
+ }
+
+ return returnVal;
+ }
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertAdapter.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertAdapter.java?rev=798866&r1=798865&r2=798866&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertAdapter.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertAdapter.java
Wed Jul 29 12:01:25 2009
@@ -28,8 +28,8 @@
* A convenience implementation of the assertions interface. All compliant
assertions
* processors (using a specific XPath 2.0 engine), should extend this class.
*
- * @version $Id$
* @author: Mukul Gandhi, IBM
+ * @version $Id$
*/
public class XMLAssertAdapter implements XMLAssertHandler {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertHandler.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertHandler.java?rev=798866&r1=798865&r2=798866&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertHandler.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/parser/XMLAssertHandler.java
Wed Jul 29 12:01:25 2009
@@ -33,7 +33,6 @@
* @author Ken Cai, IBM
*
* @version $Id$
- *
*/
public interface XMLAssertHandler {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java?rev=798866&r1=798865&r2=798866&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java
Wed Jul 29 12:01:25 2009
@@ -20,7 +20,7 @@
import org.apache.xerces.impl.xs.assertion.Test;
/**
- * This interface represents the XML Schema assertion component. Assertion
+ * This interface represents the XML Schema 1.1 assertion component. Assertion
* components were first introduced in the XML Schema structures 1.1
* specification, as a means of constraining the existence and values of
* related elements and attributes.
@@ -31,12 +31,12 @@
public interface XSAssert extends XSObject {
/**
- * A sequence of [annotations] or an empty <code>XSObjectList</code>.
+ * A sequence of [annotations] or an empty <code>XSObjectList</code>
*/
public XSObjectList getAnnotations();
/**
- * [test]: an XPath 2.0 expression.
+ * [test]: an XPath 2.0 expression
*/
public Test getTest();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]