- From: <bugzilla@wiggum.w3.org>
- Date: Thu, 12 May 2005 17:47:23 +0000
- To: public-qt-comments@w3.org
- Cc:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=1394
Summary: Improvement to fn:tokenize function
Product: XPath / XQuery / XSLT
Version: Last Call drafts
Platform: PC
OS/Version: Windows 2000
Status: NEW
Severity: enhancement
Priority: P2
Component: Functions and Operators
AssignedTo: ashok.malhotra@oracle.com
ReportedBy: mukul_gandhi@yahoo.com
QAContact: public-qt-comments@w3.org
I was reading the latest working draft of "XQuery 1.0 and XPath 2.0 Functions
and Operators" at http://www.w3.org/TR/xpath-functions/ ..
I felt a need for improvement of fn:tokenize function (described in section
7.6.4) .
Just now tokenize function breaks the input string into a sequence of strings ..
I'll illustrate the problem I am facing with an example (this is tested with
Saxon 8.4)..
I want to tokenize a string by "any capital letter". So A,B,C .... Z will be
possible delimeters. I can solve this problem as below with the tokenize
function (using a regular expression) ..
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="tempstr" select="'HelloThere'" />
<xsl:template match="/">
<xsl:for-each select="tokenize($tempstr, '[A-Z]')">
<xsl:value-of select="." /><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This gives output ello here
Its fine.. But I have no access to the current delimeter (it is variable for
each iteration) ..
I propose a function like "fn:delim() as xs:string" which will return the
delimeter in context .. (it will be conceptually similar to position() function)
For example, I would be able to modify the above example to like ..
<xsl:for-each select="tokenize($tempstr, '[A-Z]')">
<xsl:value-of select="delim()" /><xsl:value-of select="." /><xsl:text>
</xsl:text>
</xsl:for-each>
This will return output Hello There
I guess it will be useful..
Regards,
Mukul
Received on Thursday, 12 May 2005 17:47:28 UTC