[341862] [xpath2] improvements to computation of typed value of xs:boolean nodes
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xml b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xml new file mode 100644 index 0000000..d8227f8 --- /dev/null +++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xml
@@ -0,0 +1,6 @@ +<X> + <a att="1">1</a> + <a att="true">true</a> + <a att="0">0</a> + <a att="false">false</a> +</X> \ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xsd b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xsd new file mode 100644 index 0000000..e535124 --- /dev/null +++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug341862.xsd
@@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="X"> + <xs:complexType> + <xs:sequence> + <xs:element maxOccurs="unbounded" name="a" type="A_TYPE"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:complexType name="A_TYPE"> + <xs:simpleContent> + <xs:extension base="xs:boolean"> + <xs:attribute name="att" type="xs:boolean"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</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 35b4d1e..435918d 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,10 +51,11 @@ * 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 280798 - PsychoPath support for JDK 1.4 + * Mukul Gandhi - bug 280798 - PsychoPath support for JDK 1.4 * 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 339025 - fixes to fn:distinct-values function. ability to find distinct values on node items. + * Mukul Gandhi - bug 339025 - fixes to fn:distinct-values function. ability to find distinct values on node items. + * Mukul Gandhi - bug 341862 - improvements to computation of typed value of xs:boolean nodes. *******************************************************************************/ package org.eclipse.wst.xml.xpath2.processor.test; @@ -2260,6 +2261,76 @@ assertEquals("false", actual); } + public void testBug341862_TypedBooleanNode() throws Exception { + // bug 341862 + URL fileURL = bundle.getEntry("/bugTestFiles/bug341862.xml"); + URL schemaURL = bundle.getEntry("/bugTestFiles/bug341862.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 = "/X/a[1] = true()"; + XPath path = compileXPath(dc, xpath); + ResultSequence rs = eval.evaluate(path); + String actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test b) + xpath = "/X/a[1]/@att = true()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test c) + xpath = "/X/a[2] = true()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test d) + xpath = "/X/a[2]/@att = true()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test e) + xpath = "/X/a[3] = false()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test f) + xpath = "/X/a[3]/@att = false()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test g) + xpath = "/X/a[4] = false()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + + // test h) + xpath = "/X/a[4]/@att = false()"; + path = compileXPath(dc, xpath); + rs = eval.evaluate(path); + actual = ((XSBoolean) rs.first()).string_value(); + assertEquals("true", actual); + } + private CollationProvider createLengthCollatorProvider() { return new CollationProvider() { public Comparator get_collation(String name) {