473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

XPATH2.0 fn:matches() can somebody confirm if my understanding is OK

Dear ALL,

I'm writing some first examples to get a better understanding of XSLT/
XPATH2.0.
Please excute this code, any xml input is OK.
I'm using saxon. The example runs perfect with ALTOVA, but fails with
SAXON.

Please refere to line with element <matcheswhich is quite close to
the error.

Error at choose on line 26 of file:/.....:
No function found matching fn:matches with 2 arguments
Transformation failed: Run-time errors were reported

Any idea ?

Any comments on the rest of the example are very welcome !
(I'm just started to dig into XSLT2.0 stub)

################ xslt #######################
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<output>
<analyze>
<xsl:analyze-string select="'@abcd[123]'" regex="(@|#)?(\w+)\[(\d+)
\]">
<xsl:matching-substring>
<m group="1">
<xsl:value-of select="regex-group(1)"/>
</m>
<m group="2">
<xsl:value-of select="regex-group(2)"/>
</m>
<m group="3">
<xsl:value-of select="regex-group(3)"/>
</m>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</analyze>
<functions>
<xsl:for-each
select="('@param[2]','#define','0','H','L','invalid','##','@@','HL')" >
<matches>
<xsl:choose>
<xsl:when test="fn:matches(.,'^@\w+\[\d+\]$')">
<item Value="{.}" Type="Parameter"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^#\w+$')">
<item Value="{.}" Type="Define"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^[01ZHLX]{1}$')">
<item Value="{.}" Type="Value"/>
</xsl:when>
<xsl:otherwise>
<item Value="{.}" Type="ERROR"/>
</xsl:otherwise>
</xsl:choose>
</matches>
<tokenize>
<xsl:variable name="vTokens" select="fn:tokenize(.,'(@)|(#)|(\[)|
(\])')"/>
<tokens count="{count($vTokens)}">
<xsl:for-each select="$vTokens">
<token value="{.}"/>
</xsl:for-each>
</tokens>
</tokenize>
</xsl:for-each>
</functions>
</output>
</xsl:template>
</xsl:transform>
############################

Dec 18 '07 #1
5 4517

RolfK <Ro*********@eu.necel.comwrote in
<ea**********************************@w56g2000hsf. googlegroups.com>:
Please excute this code, any xml input is OK.
I'm using saxon. The example runs perfect with ALTOVA, but
fails with SAXON.

Please refere to line with element <matcheswhich is
quite close to the error.

Error at choose on line 26 of file:/.....:
No function found matching fn:matches with 2 arguments
Transformation failed: Run-time errors were reported
pavel@debian:~/dev/xslt$ saxon -t matches.xsl matches.xsl
Saxon 8.8J from Saxonica
Java version 1.5.0
Stylesheet compilation time: 767 milliseconds
Processing file:/var/www/dev/xslt/matches.xsl
Building tree for file:/var/www/dev/xslt/matches.xsl using
class net.sf.saxon.tinytree.TinyBuilder
Tree built in 28 milliseconds
Tree size: 86 nodes, 0 characters, 30 attributes
<?xml version="1.0" encoding="UTF-8"?>
<output xmlns:fn="http://www.w3.org/2005/xpath-functions">
<analyze>
<m group="1">@</m>
<m group="2">abcd</m>
<m group="3">123</m>
</analyze>
<functions>
<matches>
<item Value="@param[2]" Type="Parameter"/>
</matches>
<tokenize>
<tokens count="2">
<token value="@param[2"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="#define" Type="Define"/>
</matches>
<tokenize>
<tokens count="1">
<token value="#define"/>
</tokens>
</tokenize>
<matches>
<item Value="0" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="0"/>
</tokens>
</tokenize>
<matches>
<item Value="H" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="H"/>
</tokens>
</tokenize>
<matches>
<item Value="L" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="L"/>
</tokens>
</tokenize>
<matches>
<item Value="invalid" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="1">
<token value="invalid"/>
</tokens>
</tokenize>
<matches>
<item Value="##" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="2">
<token value="#"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="@@" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="2">
<token value="@"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="HL" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="1">
<token value="HL"/>
</tokens>
</tokenize>
</functions>
</output>Execution time: 212 milliseconds
Memory used: 12115968
NamePool contents: 33 entries in 30 chains. 8 prefixes, 8
URIs
pavel@debian:~/dev/xslt$
Any comments on the rest of the example are very welcome !
Right. Parsing a few dozen lines of XSLT2, formatted with
tabs, with no respect for 78 chars rule, AND with some
regexen thrown in as an added bonus, *AND* without having
the slightest idea what the hell it is supposed to do
somehow doesn't fit my idea of fun.

--
....also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
Dec 18 '07 #2
RolfK wrote:
I'm running the non comercial version 8.0.
Any recommendation to change ?
As far as I know 8.9 is the first release to implement the XSLT/XPath
2.0 standard released the beginning of 2007 so I would not bother with
8.0. And 9.0 is the current release thus if you download a new version I
would directly choose the latest version 9 from
<URL:http://saxon.sourceforge.net/>

The namespace for XPath functions was changed during the development of
the XSLT and XPath standards so that is probably why your attempt with
version 8 fails.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 18 '07 #3
On 18 Dez., 15:09, Pavel Lepin <p.le...@ctncorp.comwrote:
RolfK <Rolf.Kem...@eu.necel.comwrote in
<eaf67b01-1caa-4623-8a62-414b88797...@w56g2000hsf.googlegroups.com>:
Please excute this code, any xml input is OK.
I'm using saxon. The example runs perfect with ALTOVA, but
fails with SAXON.
Please refere to line with element <matcheswhich is
quite close to the error.
Error at choose on line 26 of file:/.....:
No function found matching fn:matches with 2 arguments
Transformation failed: Run-time errors were reported

pavel@debian:~/dev/xslt$ saxon -t matches.xsl matches.xsl
Saxon 8.8J from Saxonica
Java version 1.5.0
Stylesheet compilation time: 767 milliseconds
Processing file:/var/www/dev/xslt/matches.xsl
Building tree for file:/var/www/dev/xslt/matches.xsl using
class net.sf.saxon.tinytree.TinyBuilder
Tree built in 28 milliseconds
Tree size: 86 nodes, 0 characters, 30 attributes
<?xml version="1.0" encoding="UTF-8"?>
<output xmlns:fn="http://www.w3.org/2005/xpath-functions">
<analyze>
<m group="1">@</m>
<m group="2">abcd</m>
<m group="3">123</m>
</analyze>
<functions>
<matches>
<item Value="@param[2]" Type="Parameter"/>
</matches>
<tokenize>
<tokens count="2">
<token value="@param[2"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="#define" Type="Define"/>
</matches>
<tokenize>
<tokens count="1">
<token value="#define"/>
</tokens>
</tokenize>
<matches>
<item Value="0" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="0"/>
</tokens>
</tokenize>
<matches>
<item Value="H" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="H"/>
</tokens>
</tokenize>
<matches>
<item Value="L" Type="Value"/>
</matches>
<tokenize>
<tokens count="1">
<token value="L"/>
</tokens>
</tokenize>
<matches>
<item Value="invalid" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="1">
<token value="invalid"/>
</tokens>
</tokenize>
<matches>
<item Value="##" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="2">
<token value="#"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="@@" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="2">
<token value="@"/>
<token value=""/>
</tokens>
</tokenize>
<matches>
<item Value="HL" Type="ERROR"/>
</matches>
<tokenize>
<tokens count="1">
<token value="HL"/>
</tokens>
</tokenize>
</functions>
</output>Execution time: 212 milliseconds
Memory used: 12115968
NamePool contents: 33 entries in 30 chains. 8 prefixes, 8
URIs
pavel@debian:~/dev/xslt$
Any comments on the rest of the example are very welcome !

Right. Parsing a few dozen lines of XSLT2, formatted with
tabs, with no respect for 78 chars rule, AND with some
regexen thrown in as an added bonus, *AND* without having
the slightest idea what the hell it is supposed to do
somehow doesn't fit my idea of fun.

--
...also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
Pavel,
thank you for the answer and running the code. As you and others could
excute it ,
It shows that I have most probably a saxon version problem.
Concerning your input on 78chars rule, how do you create such
messages ?
Usually I'm working with Altova and its pretty print. And hate
everything is warpped (makes it unreadable for me).
At all I do not want to annoy the community. So how to make it
better ?

Thanks
Rolf
Dec 18 '07 #4
On 18 Dez., 16:57, Martin Honnen <mahotr...@yahoo.dewrote:
RolfK wrote:
I'm running the non comercial version 8.0.
Any recommendation to change ?

As far as I know 8.9 is the first release to implement the XSLT/XPath
2.0 standard released the beginning of 2007 so I would not bother with
8.0. And 9.0 is the current release thus if you download a new version I
would directly choose the latest version 9 from
<URL:http://saxon.sourceforge.net/>

The namespace for XPath functions was changed during the development of
the XSLT and XPath standards so that is probably why your attempt with
version 8 fails.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Martin, thanks a lot for quick reply.
I used the name space found in the W3C recommendation for XPATH chater
1.2
Which shows this:
The URIs of the namespaces and the default prefixes associated with
them are:

http://www.w3.org/2001/XMLSchema for constructors -- associated with
xs.

http://www.w3.org/2005/xpath-functions for functions -- associated
with fn.

http://www.w3.org/2005/xqt-errors -- associated with err.

Is this already old / wrong ?

Rolf
Dec 18 '07 #5
RolfK wrote:
I used the name space found in the W3C recommendation for XPATH chater
1.2
Which shows this:
The URIs of the namespaces and the default prefixes associated with
them are:

http://www.w3.org/2001/XMLSchema for constructors -- associated with
xs.

http://www.w3.org/2005/xpath-functions for functions -- associated
with fn.

http://www.w3.org/2005/xqt-errors -- associated with err.

Is this already old / wrong ?
Your version of Saxon is old and probably implements a different
namespace from the one finalized later. What prevents you from updating
your Saxon to the latest version?
And as already said, you do not need a namespace/prefix at all to access
the predefined XPath functions.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
2
by: Mark Szlazak | last post by:
All files that I will be referring to are in the same file folder. I need my javascipt file to write or save the contents of a textarea to other local files. This is for local use only on one...
2
by: scparker62 | last post by:
I'm writing a C# app that needs to know when the user presses the laptop's Fn key and another key, say F6 (Fn+F6). From the research I've done it seems as though I can check the...
8
by: rubbishemail | last post by:
Hello, I need your help understanding lambda (and doing it a better way without). f = lambda x : x*x # this is a list of functions
11
by: MLH | last post by:
I have 2 lines in a procedure that assign MyVariant a value - line #238 and line #491. When line #238 runs, the value is 152. When line #491 runs, the DLookup function returns Null. I would expect...
4
by: apriebe47 | last post by:
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass ...
4
by: OhKyu Yoon | last post by:
Hi! I have a really long binary file that I want to read. The way I am doing it now is: for i in xrange(N): # N is about 10,000,000 time = struct.unpack('=HHHH', infile.read(8)) # do...
2
by: VJ | last post by:
I tried to write sample code to get understanding of javascript's prototypal inheritance (along with the variety of function calling choices.. ) During the process, I got myself throughly...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.