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/03/24 08:13:32 UTC

svn commit: r1084861 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: ./ assertion/ util/

Author: mukulg
Date: Thu Mar 24 07:13:31 2011
New Revision: 1084861

URL: http://svn.apache.org/viewvc?rev=1084861&view=rev
Log:
doing further refactoring of schema 1.1 assertions codebase. moved handling of assertions XPath 2.0 dynamic context variable "$value" in a separate interface, and it's implementation.

Added:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java   (with props)
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java   (with props)
Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertAdapter.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertHandler.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java?rev=1084861&r1=1084860&r2=1084861&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java Thu Mar 24 07:13:31 2011
@@ -35,7 +35,6 @@ import org.apache.xerces.impl.dv.xs.XSSi
 import org.apache.xerces.impl.xs.assertion.XMLAssertAdapter;
 import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
 import org.apache.xerces.impl.xs.util.XSTypeHelper;
-import org.apache.xerces.util.XMLChar;
 import org.apache.xerces.xni.Augmentations;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
@@ -44,7 +43,6 @@ import org.apache.xerces.xs.ElementPSVI;
 import org.apache.xerces.xs.ItemPSVI;
 import org.apache.xerces.xs.XSComplexTypeDefinition;
 import org.apache.xerces.xs.XSConstants;
-import org.apache.xerces.xs.XSElementDeclaration;
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSMultiValueFacet;
 import org.apache.xerces.xs.XSObjectList;
@@ -52,19 +50,10 @@ import org.apache.xerces.xs.XSSimpleType
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
 import org.eclipse.wst.xml.xpath2.processor.DynamicError;
-import org.eclipse.wst.xml.xpath2.processor.PsychoPathTypeHelper;
-import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
-import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
 import org.eclipse.wst.xml.xpath2.processor.StaticError;
 import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
-import org.eclipse.wst.xml.xpath2.processor.internal.types.SchemaTypeValueFactory;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * Class implementing an XPath interface for XML Schema 1.1 "assertions" evaluation.
@@ -84,11 +73,11 @@ import org.w3c.dom.NodeList;
  */
 public class XMLAssertPsychopathXPath2Impl extends XMLAssertAdapter {
 
-    // class variable declarations
+    // class fields declarations
+    
     private DynamicContext fXpath2DynamicContext;
     private XSModel fSchema = null;
     private AbstractPsychoPathXPath2Impl fAbstrPsychopathImpl = null;
-
     // the DOM root of assertions tree
     private Document fAssertDocument = null;
 
@@ -263,7 +252,7 @@ public class XMLAssertPsychopathXPath2Im
         initXPathProcessor();
 
         // determine "string value" of XPath2 context variable $value
-        String value = getStringValueOf$value((ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI));
+        String value = computeStringValueOf$value(fCurrentAssertDomNode, (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI));
 
         // evaluate assertions
         if (assertions instanceof XSObjectList) {
@@ -314,10 +303,10 @@ public class XMLAssertPsychopathXPath2Im
         if (simpleTypeDefn.getVariety() == XSSimpleTypeDefinition.VARIETY_ATOMIC) {
             // evaluating assertions for "simpleType -> restriction" (not derived by union)
             if (isAttribute) {
-               setTypedValueFor$value(value, null, simpleTypeDefn, false);
+                setXDMTypedValueFor$value(fCurrentAssertDomNode, value, null, simpleTypeDefn, false, fXpath2DynamicContext);
             }
             else {
-               setTypedValueFor$value(value, null, null, false);
+                setXDMTypedValueFor$value(fCurrentAssertDomNode, value, null, null, false, fXpath2DynamicContext);
             }
             AssertionError assertError = evaluateOneAssertion(element, assertImpl, value, false, false);
             if (assertError != null) {
@@ -356,7 +345,7 @@ public class XMLAssertPsychopathXPath2Im
                 StringTokenizer listStrTokens = new StringTokenizer(value, " \n\t\r");
                 while (listStrTokens.hasMoreTokens()) {
                     String listItemStrValue = listStrTokens.nextToken();
-                    setValueOf$valueForSTVarietyList(listItemStrValue, listItemType, false);                        
+                    setValueOf$valueForSTVarietyList(fCurrentAssertDomNode, listItemStrValue, listItemType, false, fXpath2DynamicContext);                        
                     AssertionError assertError = evaluateOneAssertion(element, itemTypeAssert, listItemStrValue, false, true);                        
                     if (assertError != null) {
                         assertError.setIsTypeDerivedFromList(false);
@@ -378,7 +367,7 @@ public class XMLAssertPsychopathXPath2Im
         AssertionError assertError = null;
         
         if (isTypeDerivedFromList) {
-            setValueOf$valueForSTVarietyList(listStrValue, itemType, isTypeDerivedFromList);
+            setValueOf$valueForSTVarietyList(fCurrentAssertDomNode, listStrValue, itemType, isTypeDerivedFromList, fXpath2DynamicContext);
             assertError = evaluateOneAssertion(element, assertImpl, listStrValue, xpathContextExists, true);
             if (assertError != null) {
                 assertError.setIsTypeDerivedFromList(isTypeDerivedFromList);
@@ -391,7 +380,7 @@ public class XMLAssertPsychopathXPath2Im
             StringTokenizer listStrTokens = new StringTokenizer(listStrValue, " \n\t\r");
             while (listStrTokens.hasMoreTokens()) {
                 String listItemStrValue = listStrTokens.nextToken();
-                setValueOf$valueForSTVarietyList(listItemStrValue, itemType, isTypeDerivedFromList);                        
+                setValueOf$valueForSTVarietyList(fCurrentAssertDomNode, listItemStrValue, itemType, isTypeDerivedFromList, fXpath2DynamicContext);                        
                 assertError = evaluateOneAssertion(element, assertImpl, listItemStrValue, xpathContextExists, true);
                 if (assertError != null) {
                     reportAssertionsError(assertError);    
@@ -425,7 +414,7 @@ public class XMLAssertPsychopathXPath2Im
             } 
          }
          else if (isTypeDerivedFromUnion) {
-             setValueOf$valueForSTVarietyUnion(value, memberTypes);
+             setValueOf$valueForSTVarietyUnion(value, memberTypes, fXpath2DynamicContext);
              AssertionError assertError = evaluateOneAssertion(element, assertImpl, value, false, false);
              if (assertError != null) {
                  isValueValid = false;
@@ -445,10 +434,10 @@ public class XMLAssertPsychopathXPath2Im
         
         if (value != null) {
             // complex type with simple content
-            setTypedValueFor$value(value, null, null, false);
+            setXDMTypedValueFor$value(fCurrentAssertDomNode, value, null, null, false, fXpath2DynamicContext);
         } else {
             // complex type with complex content. set xpath context variable $value to an empty sequence.
-            fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), getXPath2ResultSequence(new ArrayList()));
+            fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XSTypeHelper.getXPath2ResultSequence(new ArrayList()));
         }
         
         XSObjectList assertList = (XSObjectList) assertions;
@@ -565,7 +554,7 @@ public class XMLAssertPsychopathXPath2Im
                         for (Iterator iter = assertFacets.iterator(); iter.hasNext(); ) {
                             XSAssertImpl assertImpl = (XSAssertImpl) iter.next();
                             try {
-                               setTypedValueFor$value(value, memType, null, false);
+                               setXDMTypedValueFor$value(fCurrentAssertDomNode, value, memType, null, false, fXpath2DynamicContext);
                                AssertionError assertError = evaluateOneAssertion(element, assertImpl, value, false, false);
                                if (assertError == null) {
                                    assertsSucceeded++;  
@@ -601,29 +590,6 @@ public class XMLAssertPsychopathXPath2Im
         
     } // isValidationFailedForSTUnion
     
-    
-    /*
-     * Find the actual schema type of "list item" instance if the "item type" of list has variety union. 
-     */
-    private XSSimpleTypeDefinition getActualListItemTypeForVarietyUnion(XSObjectList memberTypes, String listItemStrValue) {
-
-        XSSimpleTypeDefinition listItemType = 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)) {
-              // no more memberTypes need to be checked
-              listItemType = memSimpleType; 
-              break; 
-           }
-        }
-        
-        return listItemType;
-        
-    } // getActualListItemTypeForVarietyUnion
-    
 
     /*
      * (non-Javadoc)
@@ -636,250 +602,6 @@ public class XMLAssertPsychopathXPath2Im
             fCurrentAssertDomNode.appendChild(fAssertDocument.createTextNode(new String(text.ch, text.offset, text.length)));
         }        
     }
-        
-    
-    /*
-     * Determine "string value" of XPath2 context variable $value.
-     */
-    private String getStringValueOf$value(ElementPSVI pElemPSVI) throws DOMException {
-        
-        // there could be adjacent text nodes in a DOM tree. merge them to get the value.
-        NodeList childList = fCurrentAssertDomNode.getChildNodes();
-        StringBuffer textValueContents = new StringBuffer();
-        final int childListLength = childList.getLength();
-        int textChildCount = 0;
-        // we are only interested in text & element nodes. store count of them in this variable.
-        int effectiveChildNodeCount = 0;
-        for (int childNodeIndex = 0; childNodeIndex < childListLength; childNodeIndex++) {
-            Node node = childList.item(childNodeIndex);
-            short nodeType = node.getNodeType();
-            if (nodeType == Node.TEXT_NODE) {
-                textChildCount++;
-                effectiveChildNodeCount++;
-                textValueContents.append(node.getNodeValue());
-            }
-            else if (nodeType == Node.ELEMENT_NODE) {
-                effectiveChildNodeCount++;  
-            }
-        }
-        
-        String strValueOf$value = "";
-        
-        if (textChildCount == effectiveChildNodeCount) {
-            // the DOM tree we are inspecting has simple content. therefore we can find the desired string value. 
-            XSElementDeclaration elemDecl = pElemPSVI.getElementDeclaration();
-            if ((elemDecl.getTypeDefinition()).derivedFrom(SchemaSymbols.URI_SCHEMAFORSCHEMA, SchemaSymbols.ATTVAL_STRING, XSConstants.DERIVATION_RESTRICTION)) {
-                // if element's schema type is derived by restriction from xs:string, white-space normalization is not needed for the
-                // string value for context variable $value.
-                strValueOf$value = textValueContents.toString();  
-            }
-            else {
-                // white-space normalization is needed for the string value of $value in case of derivation from non xs:string atomic types
-                strValueOf$value = XMLChar.trim(textValueContents.toString());
-            }    
-        }
-        else {
-            // the DOM tree we are inspecting has 'mixed/element only' content.
-            strValueOf$value = null; 
-        }
-        
-        return strValueOf$value;
-        
-    } // getStringValueOf$value
-    
-    
-    /*
-     * Find a "schema typed value" (with type annotation xs:anyAtomicType*) to assign to XPath2 context variable $value.
-     */
-    private void setTypedValueFor$value(String value, XSSimpleTypeDefinition listOrUnionType, XSTypeDefinition attrType, boolean isTypeDerivedFromList) throws Exception {
-        
-        // dummy schema short code initializer
-        short xsdTypecode = -100;
-        
-        if (listOrUnionType != null) {
-            if (isTypeDerivedFromList) {
-                // $value is a sequence of atomic values (with type annotation xs:anyAtomicType*)
-                // tokenize the list value by a sequence of white spaces
-                StringTokenizer listStrTokens = new StringTokenizer(value, " \n\t\r");
-                List xdmItemList = new ArrayList();
-                while (listStrTokens.hasMoreTokens()) {
-                    String itemValue = listStrTokens.nextToken();
-                    xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listOrUnionType.getBuiltInKind(), itemValue)); 
-                }
-                fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), getXPath2ResultSequence(xdmItemList));                
-            }
-            else {
-               xsdTypecode = getXercesXSDTypeCodeFor$value(listOrUnionType);
-               setValueOf$valueForSTVarietyAtomic(value, xsdTypecode);
-            }
-        }
-        else {
-           if (attrType != null) {
-              // is value of an attribute
-              xsdTypecode = getXercesXSDTypeCodeFor$value(attrType);
-              setValueOf$valueForSTVarietyAtomic(value, xsdTypecode);
-           }
-           else {
-              // is "simple type" value of an element
-              PSVIElementNSImpl currentAssertPSVINode = (PSVIElementNSImpl) fCurrentAssertDomNode;
-              XSTypeDefinition typeDef = currentAssertPSVINode.getTypeDefinition();
-              if (typeDef instanceof XSComplexTypeDefinition && ((XSComplexTypeDefinition) typeDef).getSimpleType() != null) {
-                  setValueOf$valueForCTWithSimpleContent(value, (XSComplexTypeDefinition) typeDef);
-              }
-              else if (typeDef instanceof XSComplexTypeDefinition && ((XSComplexTypeDefinition) typeDef).getSimpleType() == null) {
-                  // set xpath context variable $value to an empty sequence
-                  fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), getXPath2ResultSequence(new ArrayList())); 
-              }
-              else {
-                  xsdTypecode = getXercesXSDTypeCodeFor$value(typeDef);
-                  setValueOf$valueForSTVarietyAtomic(value, xsdTypecode);
-              }
-           }
-        }
-        
-    } // setTypedValueFor$value
-    
-    
-    /*
-     * Set value of XPath2 context variable $value when variety of it's schema type is "simpleType -> atomic".  
-     */
-    private void setValueOf$valueForSTVarietyAtomic(String value, short xsdTypecode) {
-        AnyType psychoPathType = SchemaTypeValueFactory.newSchemaTypeValue(xsdTypecode, value);
-        fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), (AnyAtomicType) psychoPathType);
-    } // setValueOf$valueForSTVarietyAtomic
-    
-    
-    /*
-     * Set a typed value of XPath2 context variable $value, if the simpleType context is xs:list.
-     */
-    private void setValueOf$valueForSTVarietyList(String listStrValue, XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList) throws Exception {
-        
-        XSObjectList memberTypes = itemType.getMemberTypes();
-        if (memberTypes.getLength() > 0) {
-            // the list's item type has variety 'union'
-            XSSimpleTypeDefinition actualListItemType = getActualListItemTypeForVarietyUnion(memberTypes, listStrValue);
-            // set a schema 'typed value' to variable $value
-            setTypedValueFor$value(listStrValue, actualListItemType, null, false);
-        } 
-        else {
-            setTypedValueFor$value(listStrValue, itemType, null, isTypeDerivedFromList); 
-        }
-
-    } // setValueOf$valueForSTVarietyList
-    
-    
-    /*
-     * Set a typed value of XPath2 context variable $value if an atomic value on which assertion is been evaluated, is validated by a
-     * simpleType with variety union. 
-     */
-    private void setValueOf$valueForSTVarietyUnion(String value, XSObjectList memberTypes) {
-        
-        // check member types of union in order to find that which member type can successfully validate the string value
-        // first, and set value of XPath2 context variable $value using the member type found as its type annotation.
-        for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) {
-            XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx);
-            if (XSTypeHelper.isValueValidForASimpleType(value, simpleTypeDv)) {
-               setValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(simpleTypeDv));
-               break;
-            }            
-        }
-        
-    } // setValueOf$valueForSTVarietyUnion
-
-
-    /*
-     * Set value of XPath2 context variable $value, if element has a complex type with simple content.
-     */
-    private void setValueOf$valueForCTWithSimpleContent(String value, XSComplexTypeDefinition typeDef) {
-        
-        XSComplexTypeDefinition cmplxTypeDef = (XSComplexTypeDefinition)typeDef;
-        XSSimpleTypeDefinition complexTypeSimplContentType = cmplxTypeDef.getSimpleType();
-        if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
-            // simple content type has variety xs:list
-            XSSimpleTypeDefinition listItemType = complexTypeSimplContentType.getItemType();
-            // tokenize the list value by a sequence of white spaces
-            StringTokenizer values = new StringTokenizer(value, " \n\t\r");            
-            // $value is a sequence of atomic values (with type annotation xs:anyAtomicType*)
-            List xdmItemList = new ArrayList();
-            final XSObjectList memberTypes = listItemType.getMemberTypes();
-            if (memberTypes.getLength() > 0) {
-               // 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);
-                   xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue));
-               }                                  
-            }
-            else {
-               // every list item has a same type (the itemType of xs:list)
-               while (values.hasMoreTokens()) {
-                   String itemValue = values.nextToken();
-                   xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemType.getBuiltInKind(), itemValue)); 
-               }                                  
-            }
-
-            // assign an XPath2 sequence to xpath context variable $value
-            fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), getXPath2ResultSequence(xdmItemList));
-        }
-        else if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
-            // simple content type has variety xs:union
-            XSSimpleTypeDefinition simpleContentTypeForUnion = getActualListItemTypeForVarietyUnion(complexTypeSimplContentType.getMemberTypes(), value);
-            fXpath2DynamicContext.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
-            setValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(cmplxTypeDef.getSimpleType()));
-        }
-          
-    } // setValueOf$valueForCTWithSimpleContent
-    
-    
-    /*
-       Find the built-in Xerces schema 'type code' for XPath2 variable $value. This function recursively searches the XML schema type hierarchy navigating
-       up the base types, to find the needed built-in type.
-    */
-    private short getXercesXSDTypeCodeFor$value(XSTypeDefinition elementType) {
-            
-      if (Constants.NS_XMLSCHEMA.equals(elementType.getNamespace())) {
-         short typeCode = -100; // dummy initializer
-         
-         boolean isxsd11Type = false;
-         
-         // the below 'if else' clauses are written to process few special cases handling few of schema types within PsychoPath XPath engine
-         final String elementTypeName = elementType.getName();
-         if ("dayTimeDuration".equals(elementTypeName)) {
-             typeCode = PsychoPathTypeHelper.DAYTIMEDURATION_DT;
-             isxsd11Type = true;
-         }
-         else if ("yearMonthDuration".equals(elementTypeName)) {
-             typeCode = PsychoPathTypeHelper.YEARMONTHDURATION_DT;
-             isxsd11Type = true;
-         }
-         
-         return (isxsd11Type) ? typeCode : ((XSSimpleTypeDefinition) elementType).getBuiltInKind();    
-      }
-      else {
-         return getXercesXSDTypeCodeFor$value(elementType.getBaseType()); 
-      }
-      
-    } // getXercesXSDTypeCodeFor$value
-    
-    
-    /*
-     * Construct an PsychoPath XPath2 "result sequence" given a list of XDM items as input.
-     */
-    private ResultSequence getXPath2ResultSequence(List xdmItems) {
-        
-        ResultSequence xpath2Seq = ResultSequenceFactory.create_new();
-        
-        for (Iterator iter = xdmItems.iterator(); iter.hasNext(); ) {
-            xpath2Seq.add((AnyType) iter.next()); 
-        }
-        
-        return xpath2Seq;
-        
-    } // getXPath2ResultSequence
     
     
     /*

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertAdapter.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertAdapter.java?rev=1084861&r1=1084860&r2=1084861&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertAdapter.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertAdapter.java Thu Mar 24 07:13:31 2011
@@ -33,7 +33,7 @@ import org.apache.xerces.xni.XMLString;
  * @author: Mukul Gandhi, IBM
  * @version $Id$
  */
-public class XMLAssertAdapter implements XMLAssertHandler {
+public class XMLAssertAdapter extends XSAssertionXPath2ValueImpl implements XMLAssertHandler {
     
     // this hashtable contains any implementation specific properties
     private Hashtable properties = null;

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertHandler.java?rev=1084861&r1=1084860&r2=1084861&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertHandler.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XMLAssertHandler.java Thu Mar 24 07:13:31 2011
@@ -23,11 +23,10 @@ import org.apache.xerces.xni.XMLAttribut
 import org.apache.xerces.xni.XMLString;
 
 /**
- * The implementation of this interface will invoke an external XPath engine, that
- * would evaluate the XPath 2.0 expressions, for XML Schema 1.1 assertions.
- * This interface communicates with the XMLSchemaValidator, and accepts information
- * required by the external XPath engine. If assertions evaluation returns 'true',
- * validation would proceed further.
+ * The implementation of this interface will invoke an external XPath engine, that would evaluate the XPath 2.0 expressions
+ * for XML Schema 1.1 assertions. This interface communicates with the XMLSchemaValidator and accepts context information required 
+ * by the external XPath engine. If assertions evaluation would return 'true', validation would proceed further checking the
+ * remaining validation constraints.
  * 
  * @xerces.internal
  * 
@@ -36,7 +35,7 @@ import org.apache.xerces.xni.XMLString;
  * 
  * @version $Id$
  */
-public interface XMLAssertHandler {  
+public interface XMLAssertHandler extends XSAssertionXPath2Value {  
 
     /*
      * A callback method triggered during startElement method call in, XMLSchemaValidator
@@ -77,8 +76,7 @@ public interface XMLAssertHandler {  
      * @exception IllegalArgumentException thrown if the underlying
      * implementation doesn't recognize the property.
      */
-    public void setProperty(String name, Object value)
-                throws IllegalArgumentException;
+    public void setProperty(String name, Object value) throws IllegalArgumentException;
     
     
     /**
@@ -89,7 +87,6 @@ public interface XMLAssertHandler {  
      * @exception IllegalArgumentException thrown if the underlying
      * implementation doesn't recognize the property.
      */
-    public abstract Object getProperty(String name)
-                throws IllegalArgumentException;
+    public abstract Object getProperty(String name) throws IllegalArgumentException;
 
 }

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java?rev=1084861&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java Thu Mar 24 07:13:31 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.xs.assertion;
+
+import org.apache.xerces.xs.ElementPSVI;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+
+/**
+ * An interface defining methods to work with XPath 2.0 dynamic context variable "$value" that is needed for assertions evaluation.
+ * 
+ * @xerces.internal
+ * 
+ * @version $Id$
+ */
+public interface XSAssertionXPath2Value {
+    
+    /*
+     * Determine "string value" of XPath2 context variable $value.
+     */
+    public String computeStringValueOf$value(Element currentAssertDomRootElem, ElementPSVI pElemPSVI) throws DOMException;
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context. This method may
+     * delegate to other methods of this interface for doing its responsibilities.
+     */
+    public void setXDMTypedValueFor$value(Element currentAssertDomRootElem, String value, XSSimpleTypeDefinition listOrUnionType, XSTypeDefinition attrType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception;
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety atomic. 
+     */
+    public void setValueOf$valueForSTVarietyAtomic(String value, short xsdTypecode, DynamicContext xpath2DynamicContext);
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety list. 
+     */
+    public void setValueOf$valueForSTVarietyList(Element currentAssertDomRootElem, String listStrValue, XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception;
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety union. 
+     */
+    public void setValueOf$valueForSTVarietyUnion(String value, XSObjectList memberTypes, DynamicContext xpath2DynamicContext);
+
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2Value.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 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=1084861&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java Thu Mar 24 07:13:31 2011
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.xs.assertion;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.xerces.dom.PSVIElementNSImpl;
+import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.util.XSTypeHelper;
+import org.apache.xerces.util.XMLChar;
+import org.apache.xerces.xs.ElementPSVI;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
+import org.eclipse.wst.xml.xpath2.processor.PsychoPathTypeHelper;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.SchemaTypeValueFactory;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class defines a set of methods to work with XPath 2.0 dynamic context variable "$value" that is needed for assertions evaluation.
+ * 
+ * @xerces.internal
+ * 
+ * @author Mukul Gandhi IBM
+ * 
+ * @version $Id$
+ */
+public class XSAssertionXPath2ValueImpl implements XSAssertionXPath2Value {
+
+    /*
+     * Determine "string value" of XPath2 context variable $value.
+     */
+    public String computeStringValueOf$value(Element currentAssertDomRootElem, ElementPSVI pElemPSVI) throws DOMException {
+        
+        NodeList childNodeList = currentAssertDomRootElem.getChildNodes();
+        // there could be adjacent text nodes in the DOM tree. merge them to get the value.
+        StringBuffer textValueContents = new StringBuffer();
+        final int childListLength = childNodeList.getLength();
+        int textChildCount = 0;
+        // we are only interested in text & element nodes. store count of them in this variable.
+        int effectiveChildNodeCount = 0;
+        for (int childNodeIndex = 0; childNodeIndex < childListLength; childNodeIndex++) {
+            Node node = childNodeList.item(childNodeIndex);
+            short nodeType = node.getNodeType();
+            if (nodeType == Node.TEXT_NODE) {
+                textChildCount++;
+                effectiveChildNodeCount++;
+                textValueContents.append(node.getNodeValue());
+            }
+            else if (nodeType == Node.ELEMENT_NODE) {
+                effectiveChildNodeCount++;  
+            }
+        }
+        
+        String strValueOf$value = "";        
+        if (textChildCount == effectiveChildNodeCount) {
+            // the DOM tree we are inspecting has simple content. therefore we can find the desired string value. 
+            XSElementDeclaration elemDecl = pElemPSVI.getElementDeclaration();
+            if ((elemDecl.getTypeDefinition()).derivedFrom(SchemaSymbols.URI_SCHEMAFORSCHEMA, SchemaSymbols.ATTVAL_STRING, XSConstants.DERIVATION_RESTRICTION)) {
+                // if element's schema type is derived by restriction from xs:string, white-space normalization is not needed for the
+                // string value for context variable $value.
+                strValueOf$value = textValueContents.toString();  
+            }
+            else {
+                // white-space normalization is needed for the string value of $value in case of derivation from non xs:string atomic types
+                strValueOf$value = XMLChar.trim(textValueContents.toString());
+            }    
+        }
+        else {
+            // the DOM tree we are inspecting has 'mixed/element only' content.
+            strValueOf$value = null; 
+        }
+        
+        return strValueOf$value;
+        
+    } // computeStringValueOf$value
+    
+
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context.
+     */
+    public void setXDMTypedValueFor$value(Element currentAssertDomRootElem, String value, XSSimpleTypeDefinition listOrUnionType, XSTypeDefinition attrType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception {
+        
+        // dummy schema short code initializer
+        short xsdTypecode = -100;
+        
+        if (listOrUnionType != null) {
+            if (isTypeDerivedFromList) {
+                // $value is a sequence of atomic values (with type annotation xs:anyAtomicType*)
+                // tokenize the list value by a sequence of white spaces
+                StringTokenizer listStrTokens = new StringTokenizer(value, " \n\t\r");
+                List xdmItemList = new ArrayList();
+                while (listStrTokens.hasMoreTokens()) {
+                    String itemValue = listStrTokens.nextToken();
+                    xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listOrUnionType.getBuiltInKind(), itemValue)); 
+                }
+                xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XSTypeHelper.getXPath2ResultSequence(xdmItemList));                
+            }
+            else {
+               xsdTypecode = getXercesXSDTypeCodeFor$value(listOrUnionType);
+               setValueOf$valueForSTVarietyAtomic(value, xsdTypecode, xpath2DynamicContext);
+            }
+        }
+        else {
+           if (attrType != null) {
+              // is value of an attribute
+              xsdTypecode = getXercesXSDTypeCodeFor$value(attrType);
+              setValueOf$valueForSTVarietyAtomic(value, xsdTypecode, xpath2DynamicContext);
+           }
+           else {
+              // is "simple type" value of an element
+              PSVIElementNSImpl currentAssertPSVINode = (PSVIElementNSImpl) currentAssertDomRootElem;
+              XSTypeDefinition typeDef = currentAssertPSVINode.getTypeDefinition();
+              if (typeDef instanceof XSComplexTypeDefinition && ((XSComplexTypeDefinition) typeDef).getSimpleType() != null) {
+                  setValueOf$valueForCTWithSimpleContent(value, (XSComplexTypeDefinition) typeDef, xpath2DynamicContext);
+              }
+              else if (typeDef instanceof XSComplexTypeDefinition && ((XSComplexTypeDefinition) typeDef).getSimpleType() == null) {
+                  // set xpath context variable $value to an empty sequence
+                  xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XSTypeHelper.getXPath2ResultSequence(new ArrayList())); 
+              }
+              else {
+                  xsdTypecode = getXercesXSDTypeCodeFor$value(typeDef);
+                  setValueOf$valueForSTVarietyAtomic(value, xsdTypecode, xpath2DynamicContext);
+              }
+           }
+        }
+        
+    } // setXDMTypedValueFor$value
+    
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety atomic. 
+     */
+    public void setValueOf$valueForSTVarietyAtomic(String value, short xsdTypecode, DynamicContext xpath2DynamicContext) {
+        AnyType psychoPathType = SchemaTypeValueFactory.newSchemaTypeValue(xsdTypecode, value);
+        xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), (AnyAtomicType) psychoPathType);
+    } // setValueOf$valueForSTVarietyAtomic
+    
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety list. 
+     */
+    public void setValueOf$valueForSTVarietyList(Element currentAssertDomRootElem, String listStrValue, XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception {
+        
+        XSObjectList memberTypes = itemType.getMemberTypes();
+        if (memberTypes.getLength() > 0) {
+            // the list's item type has variety 'union'
+            XSSimpleTypeDefinition actualListItemType = getActualListItemTypeForVarietyUnion(memberTypes, listStrValue);
+            // set a schema 'typed value' to variable $value
+            setXDMTypedValueFor$value(currentAssertDomRootElem, listStrValue, actualListItemType, null, false, xpath2DynamicContext);
+        } 
+        else {
+            setXDMTypedValueFor$value(currentAssertDomRootElem, listStrValue, itemType, null, isTypeDerivedFromList, xpath2DynamicContext); 
+        }
+
+    } // setValueOf$valueForSTVarietyList
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, if element has a complex type with simple content. 
+     */
+    private void setValueOf$valueForCTWithSimpleContent(String value, XSComplexTypeDefinition typeDef, DynamicContext xpath2DynamicContext) {
+        
+        XSComplexTypeDefinition cmplxTypeDef = (XSComplexTypeDefinition)typeDef;
+        XSSimpleTypeDefinition complexTypeSimplContentType = cmplxTypeDef.getSimpleType();
+        if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
+            // simple content type has variety xs:list
+            XSSimpleTypeDefinition listItemType = complexTypeSimplContentType.getItemType();
+            // tokenize the list value by a sequence of white spaces
+            StringTokenizer values = new StringTokenizer(value, " \n\t\r");            
+            // $value is a sequence of atomic values (with type annotation xs:anyAtomicType*)
+            List xdmItemList = new ArrayList();
+            final XSObjectList memberTypes = listItemType.getMemberTypes();
+            if (memberTypes.getLength() > 0) {
+               // 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);
+                   xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue));
+               }                                  
+            }
+            else {
+               // every list item has a same type (the itemType of xs:list)
+               while (values.hasMoreTokens()) {
+                   String itemValue = values.nextToken();
+                   xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemType.getBuiltInKind(), itemValue)); 
+               }                                  
+            }
+
+            // assign an XPath2 sequence to xpath context variable $value
+            xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XSTypeHelper.getXPath2ResultSequence(xdmItemList));
+        }
+        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));
+        }
+        else {
+            // simple content type has variety atomic
+            setValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(cmplxTypeDef.getSimpleType()), xpath2DynamicContext);
+        }
+          
+    } // setValueOf$valueForCTWithSimpleContent
+    
+    
+    /*
+     * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety union. 
+     */
+    public void setValueOf$valueForSTVarietyUnion(String value, XSObjectList memberTypes, DynamicContext xpath2DynamicContext) {        
+        // check member types of union in order to find that which member type can successfully validate the string value
+        // first, and set value of XPath2 context variable $value using the member type found as its type annotation.
+        for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) {
+            XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx);
+            if (XSTypeHelper.isValueValidForASimpleType(value, simpleTypeDv)) {
+               setValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(simpleTypeDv), xpath2DynamicContext);
+               break;
+            }            
+        }        
+    } // setValueOf$valueForSTVarietyUnion
+    
+    
+    /* 
+     * Find the built-in Xerces schema 'type code' for XPath2 variable $value. This function recursively searches the XML schema type hierarchy navigating
+     * up the base types, to find the needed built-in type.
+     */
+    private short getXercesXSDTypeCodeFor$value(XSTypeDefinition elementType) {
+
+        if (Constants.NS_XMLSCHEMA.equals(elementType.getNamespace())) {
+            short typeCode = -100; // dummy initializer
+
+            boolean isxsd11Type = false;
+
+            // the below 'if else' clauses are written to process few special cases handling few of schema types within PsychoPath XPath engine
+            final String elementTypeName = elementType.getName();
+            if ("dayTimeDuration".equals(elementTypeName)) {
+                typeCode = PsychoPathTypeHelper.DAYTIMEDURATION_DT;
+                isxsd11Type = true;
+            }
+            else if ("yearMonthDuration".equals(elementTypeName)) {
+                typeCode = PsychoPathTypeHelper.YEARMONTHDURATION_DT;
+                isxsd11Type = true;
+            }
+
+            return (isxsd11Type) ? typeCode : ((XSSimpleTypeDefinition) elementType).getBuiltInKind();    
+        }
+        else {
+            return getXercesXSDTypeCodeFor$value(elementType.getBaseType()); 
+        }
+
+    } // getXercesXSDTypeCodeFor$value
+    
+    
+    /*
+     * Find the actual schema type of "list item" instance if the "item type" of list has variety union. 
+     */
+    private XSSimpleTypeDefinition getActualListItemTypeForVarietyUnion(XSObjectList memberTypes, String listItemStrValue) {
+
+        XSSimpleTypeDefinition listItemType = 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)) {
+              // no more memberTypes need to be checked
+              listItemType = memSimpleType; 
+              break; 
+           }
+        }
+        
+        return listItemType;
+        
+    } // getActualListItemTypeForVarietyUnion
+
+} // class XSAssertionXPath2ValueImpl

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java?rev=1084861&r1=1084860&r2=1084861&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java Thu Mar 24 07:13:31 2011
@@ -38,6 +38,9 @@ import org.apache.xerces.xs.XSMultiValue
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
 import org.apache.xerces.xs.XSTypeDefinition;
+import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
+import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
+import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
 
 /**
  * Class defining utility/helper methods related to XML schema types.
@@ -260,4 +263,20 @@ public class XSTypeHelper {
         
     } // getSchemaTypeName
     
+    
+    /*
+     * Construct an PsychoPath XPath2 "result sequence" given a list of XDM items as input.
+     */
+    public static ResultSequence getXPath2ResultSequence(List xdmItems) {
+        
+        ResultSequence xpath2Seq = ResultSequenceFactory.create_new();
+        
+        for (Iterator iter = xdmItems.iterator(); iter.hasNext(); ) {
+            xpath2Seq.add((AnyType) iter.next()); 
+        }
+        
+        return xpath2Seq;
+        
+    } // getXPath2ResultSequence
+    
 } // class XSTypeHelper



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org