Bug 280554 - [xpath2] fn:string-to-codepoints returns XPST0017
Summary: [xpath2] fn:string-to-codepoints returns XPST0017
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xpath (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 3.2 M2   Edit
Assignee: Mukul Gandhi CLA
QA Contact: David Carver CLA
URL:
Whiteboard:
Keywords:
Depends on: 280553 282096
Blocks: 262765
  Show dependency tree
 
Reported: 2009-06-16 22:09 EDT by David Carver CLA
Modified: 2010-08-11 17:08 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2009-06-16 22:09:05 EDT
+++ This bug was initially created as a clone of Bug #280553 +++

Psychopath currently does not implement fn:string-to-codepoints function. 

http://www.w3.org/TR/xpath-functions/#func-string-to-codepoints
Comment 1 David Carver CLA 2009-06-16 22:18:10 EDT
Needs to implement -1 for arity.
Comment 2 David Carver CLA 2009-06-27 10:59:12 EDT
Mukul this is similar to the 280555
Comment 3 Mukul Gandhi CLA 2009-06-27 13:47:49 EDT
I have made improvements to this function implementation, and have checked in the code to HEAD. I am not closing this bug, as still few tests fail for this function. But largely, this function seems to be ok now.

Out of 22 tests for this function, 3 are failing at the moment.
Comment 4 David Carver CLA 2009-06-29 22:43:05 EDT
I've corrected the two tests that were failing.   These weren't putting the Expected Error code in the expectedResult string.  This value has been hardcoded, according to the XQueryInterop Catalog.xml file rules.

Test suite now passes...Mukul, you'll want to verify and then determine if this one can be closed.  I've checked the test changes into head.

Comment 5 Jesper Moller CLA 2009-08-06 05:58:36 EDT
I've checked it and it has one bug still, related to how codePointAt() works.

fn:string-to-codepoints(fn:codepoints-to-string(112233)) would currently return a seqence (112233 56937)  (i.e. the high surrogate at index 0 is caught and paired with the low one, but the the low surrogate at index 1 is also converted to and int).
The fix is to replace:

		for (int i = 0; i < str.length(); i++) {
			// Character.codePointAt API, is introduced in Java 1.5 
            int codePointValue = Character.codePointAt(str, i);
            	rs.add(new XSInteger(BigInteger.valueOf(codePointValue)));
		}

with

		for (int i = 0; i < str.length(); i++) {
			// Character.codePointAt API, is introduced in Java 1.5 
            int codePointValue = Character.codePointAt(str, i);
            
            // codepoint at will also return the low surrogate - omit this
            if (! Character.isLowSurrogate((char)codePointValue)) {
            	  rs.add(new XSInteger(BigInteger.valueOf(codePointValue)));
            }
		}

This isn't caught in the W3C test suite.
Comment 6 David Carver CLA 2009-08-07 09:44:31 EDT
Retargeting to 3.2M2 for completion.
Comment 7 Jesper Moller CLA 2009-08-09 19:16:19 EDT
The fix for this is included in the patch for bug 282096, since it relies on a shared utility class.
Comment 8 David Carver CLA 2009-08-14 00:26:41 EDT
This is now fixed with the latest commits to head.  Thanks jesper and mukul.