[339025] [xpath2] ability to find distinct values on node items (fixes to fn:distinct-values function)
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xml b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xml
new file mode 100644
index 0000000..e3f33ed
--- /dev/null
+++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xml
@@ -0,0 +1,12 @@
+<X>
+   <!-- a sequence -->
+   <a>1</a>
+   <a>2</a>
+   <a>3</a>
+   <a>4</a>
+   <!-- b sequence -->
+   <b>1</b>
+   <b>2</b>
+   <b>2</b>
+   <b>3</b>
+</X>
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xsd b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xsd
new file mode 100644
index 0000000..9e86423
--- /dev/null
+++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug339025.xsd
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="X">
+        <xs:complexType>
+            <xs:sequence>
+               <xs:element name="a" type="xs:integer" maxOccurs="unbounded" />
+               <xs:element name="b" type="xs:integer" maxOccurs="unbounded" />
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java b/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
index 04f2d30..dfac2b2 100644
--- a/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
+++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
@@ -51,7 +51,8 @@
  *  Mukul Gandhi    - bug 334842 - improving support for the data types Name, NCName, ENTITY, 
  *                                 ID, IDREF and NMTOKEN.
  *  Mukul Gandhi    - bug 338494 - prohibiting xpath expressions starting with / or // to be parsed.
- *  Mukul Gandhi    - bug 338999 - improving compliance of function 'fn:subsequence'. implementing full arity support.                                
+ *  Mukul Gandhi    - bug 338999 - improving compliance of function 'fn:subsequence'. implementing full arity support.
+ *  Mukul Gandhi    - bug 339025 - fixes to fn:distinct-values function. ability to find distinct values on node items.                                
  *******************************************************************************/
 package org.eclipse.wst.xml.xpath2.processor.test;
 
@@ -2223,6 +2224,41 @@
 		assertEquals("true", actual);
 	}
 	
+	public void testBug339025_distinctValuesOnNodeSequence() throws Exception {
+		// bug 339025
+		URL fileURL = bundle.getEntry("/bugTestFiles/bug339025.xml");
+		URL schemaURL = bundle.getEntry("/bugTestFiles/bug339025.xsd");
+
+		loadDOMDocument(fileURL, schemaURL);
+
+		// Get XSModel object for the Schema
+		XSModel schema = getGrammar(schemaURL);
+		
+		DynamicContext dc = setupDynamicContext(schema);;		
+		Evaluator eval = new DefaultEvaluator(dc, domDoc);
+		
+		// test a)
+		String xpath = "count(//a) = count(distinct-values(//a))";
+		XPath path = compileXPath(dc, xpath);		
+		ResultSequence rs = eval.evaluate(path);
+		String actual = ((XSBoolean) rs.first()).string_value();
+		assertEquals("true", actual);
+		
+		// test b)
+		xpath = "count(X/a) = count(distinct-values(X/a))";
+		path = compileXPath(dc, xpath);		
+		rs = eval.evaluate(path);
+		actual = ((XSBoolean) rs.first()).string_value();
+		assertEquals("true", actual);
+		
+		// test c)
+		xpath = "count(//b) = count(distinct-values(//b))";
+		path = compileXPath(dc, xpath);		
+		rs = eval.evaluate(path);
+		actual = ((XSBoolean) rs.first()).string_value();
+		assertEquals("false", actual);
+	}
+	
 	private CollationProvider createLengthCollatorProvider() {
 		return new CollationProvider() {
 			@SuppressWarnings("unchecked")