Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362026

Summary: [xpath2] "instance of" must not atomize the LHS before the comparison check
Product: [WebTools] WTP Source Editing Reporter: Mukul Gandhi <mukul.gandhi>
Component: wst.xpathAssignee: Project Inbox <wst.xsl-inbox>
Status: NEW --- QA Contact: Jesper Moller <jesper>
Severity: normal    
Priority: P3 CC: d_a_carver
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Mukul Gandhi CLA 2011-10-26 01:05:50 EDT
Build Identifier: 20110615-0604

If there's an XML instance document like following,

<X att1="x1">
  <Y>100</Y>
</X>

and it's validated by the following schema,

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <xs:element name="X">
     <xs:complexType>
	<xs:sequence>
	   <xs:element name="Y" type="xs:integer"/>
	</xs:sequence>
	<xs:attribute name="att1" type="xs:string"/>
     </xs:complexType>
  </xs:element>

</xs:schema>

If we evaluate following XPath2 expressions (with context node as element X),

Y instance of xs:integer

OR

@att1 instance of xs:string

then these expressions should return boolean 'false', as per current rules of XPath 2.0 "instance of" checks.

(the current implementation before this commit, returns 'true' for these checks)

Whereas, following checks should give us 'true' result,

Y instance of element(*, xs:integer)

OR

@att1 instance of attribute(*, xs:string)

This behavior is governed by the section "2.4.2 Atomization" of XPath 2.0 spec, that says,

<quote>

Atomization is used in processing the following types of expressions:

* Arithmetic expressions
* Comparison expressions
* Function calls and returns
* Cast expressions

</quote>

This doesn't cover "instance of" checks.

I'm committing a fix for this requirement to the service branch, and would contribute test cases for this a little later.

Reproducible: Always
Comment 1 Jesper Moller CLA 2012-09-21 18:46:03 EDT
Did you add the test case?
Comment 2 Mukul Gandhi CLA 2012-09-21 23:02:42 EDT
@ Jesper: when I try to commit test case files for this, I get following errors

The server reported an error while performing the "cvs commit" command.
org.eclipse.wst.xml.xpath2.processor.tests_1.4: cvs commit: ERROR: cannot write file /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/Attic/bug362026.xsd,v: Permission denied
org.eclipse.wst.xml.xpath2.processor.tests_1.4: cvs commit: ERROR: cannot write file /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/Attic/bug362026.xml,v: Permission denied
org.eclipse.wst.xml.xpath2.processor.tests_1.4: cvs [commit aborted]: could not open lock file `/cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/,TestBugs.java,': Permission denied

Do you know, how to fix these? I remember, there were few configuration changes lately wrt the movement of code base, but couldn't keep pace with those announcements (perhaps, my inability to make this commit is related to that).
Comment 3 Jesper Moller CLA 2012-09-22 05:04:43 EDT
Progress happened: The CVS repository is marked read-only and moved to Git. Please see http://wiki.eclipse.org/WTP_Git_Workflows for a guide.
You can attach the patches here, and assign me the bug, if you prefer.
Comment 4 Mukul Gandhi CLA 2012-09-23 05:04:31 EDT
Thanks for the pointers. I'll try to configure Git, and check-in files there.
Comment 5 Mukul Gandhi CLA 2012-09-28 23:51:54 EDT
I committed few test cases for this bug today. I work on the following branches,

R3_2_maintenance (for processor enhancements)
R3_2_xpath2_14unittests (for unit tests)