String match

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

String match

Christian Lebe-2

Hi all,

 

Just a quick question, does anyone know how to put a constraint for string pattern in a bind nodeset?

 

From an example in this mailing list, there is an example of doing it by simply using matches… eg:

 

<xforms:bind nodeset="/form/last-name" type:xs-string constraint="matches(.,'[A-Z]{1,}')" />

 

Apparently it doesn’t work as I thought. It spits an error says stylesheet error, and if I remove the constraint, it works fine. I removed type:xs-string, and still doesn’t work. If I put another constraint, for example: constraint="string-length(.) > 1" It works fine, I think method matches doesn’t exist. Does anyone have any suggestion?

 

Christian



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: String match

Erik Bruchez
Administrator
Christian Lebe wrote:

 > <xforms:bind nodeset="/form/last-name" type:xs-string
 > constraint="matches(.,'[A-Z]{1,}')" />

One comment about the above: type:xs-string is not even XML and will
cause a parsing error. The correct syntax is:

   type="xs:string"

 > Apparently it doesn’t work as I thought. It spits an error says
 > stylesheet error, and if I remove the constraint, it works fine. I
 > removed type:xs-string, and still doesn’t work. If I put another
 > constraint, for example: constraint="string-length(.) > 1" It works
 > fine, I think method matches doesn’t exist. Does anyone have any
 > suggestion?

I think this is due to the way the XPath 2.0 function matches() works. See:

   http://www.w3.org/TR/xpath-functions/#func-matches

   "Unless the metacharacters ^ and $ are used as anchors, the string
    is considered to match the pattern if any substring matches the
    pattern. But if anchors are used, the anchors must match the
    start/end of the string (in string mode), or the start/end of a
    line (in multiline mode).

    Note: This is different from the behavior of patterns in [XML
    Schema Part 2: Datatypes Second Edition], where regular expressions
    are implicitly anchored."

So you need to write:

   constraint="matches(., '^[A-Z]{1,}$')"

You learn every day ;-)

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: String match

Christian Lebe-2
In reply to this post by Christian Lebe-2
Hi Erick,

Thanks for your help. I really appreciate it. Still the same error,
stylesheet error detected, isn't that weird. I'll probably need to read
the xpath-functions.

Thanks for the pointer :)


Cheers,
 
Christian

-----Original Message-----
From: Erik Bruchez [mailto:[hidden email]]
Sent: Monday, 16 July 2007 10:27 PM
To: [hidden email]
Subject: Re: [ops-users] String match

Christian Lebe wrote:

 > <xforms:bind nodeset="/form/last-name" type:xs-string
 > constraint="matches(.,'[A-Z]{1,}')" />

One comment about the above: type:xs-string is not even XML and will
cause a parsing error. The correct syntax is:

   type="xs:string"

 > Apparently it doesn't work as I thought. It spits an error says
 > stylesheet error, and if I remove the constraint, it works fine. I
 > removed type:xs-string, and still doesn't work. If I put another
 > constraint, for example: constraint="string-length(.) > 1" It works
 > fine, I think method matches doesn't exist. Does anyone have any
 > suggestion?

I think this is due to the way the XPath 2.0 function matches() works.
See:

   http://www.w3.org/TR/xpath-functions/#func-matches

   "Unless the metacharacters ^ and $ are used as anchors, the string
    is considered to match the pattern if any substring matches the
    pattern. But if anchors are used, the anchors must match the
    start/end of the string (in string mode), or the start/end of a
    line (in multiline mode).

    Note: This is different from the behavior of patterns in [XML
    Schema Part 2: Datatypes Second Edition], where regular expressions
    are implicitly anchored."

So you need to write:

   constraint="matches(., '^[A-Z]{1,}$')"

You learn every day ;-)

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/







--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: String match

Daniel E. Renfer-2
Christian,

What is the exact error that the XSL processor is returning? If you have
your server set to log errors you should be able to see a line at the
beginning of the stack trace that explains exactly what token the XSL
parser is choking at as well as the line number.

Other than that, if you run your server from a command line as opposed
to a service, (ie. tomcat.bat) you should see that same error displayed
on the console.

One tip I've found useful: Keep a bookmark to your log files in your web
browser next to your bookmarks for your application. If you open your
log in a second tab, you can just mash on the F5 to see new things
posted to the log. Your browser should reload the file and automatically
scroll down to where you were last.

For instance, my logs are at
file:///C:/Program%20Files/xampp/tomcat/logs/stdout.log
--
Daniel E. Renfer
http://kronkltd.net/

Christian Lebe wrote:

> Hi Erick,
>
> Thanks for your help. I really appreciate it. Still the same error,
> stylesheet error detected, isn't that weird. I'll probably need to read
> the xpath-functions.
>
> Thanks for the pointer :)
>
>
> Cheers,
>  
> Christia


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

signature.asc (258 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: String match

Alessandro Vernet
Administrator
Daniel,

On 7/17/07, Daniel E. Renfer <[hidden email]> wrote:
> One tip I've found useful: Keep a bookmark to your log files in your web
> browser next to your bookmarks for your application. If you open your
> log in a second tab, you can just mash on the F5 to see new things
> posted to the log. Your browser should reload the file and automatically
> scroll down to where you were last.

I never thought about doing this; this is a good suggestion :). And of
course another way of doing this is to use tail on UNIX or Mac OS X,
and a software like Tail for Win32 on Windows
(http://tailforwin32.sourceforge.net/).

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws