Re: regular expression matching in <assert>

Dawid Chodura <[email protected]>
Newsgroups gmane.text.xml.xerces-j.user
Message-ID <[email protected]>
I have no easy way to test it, but I think your expression could be simplified, ie.

test="if (matches(string(@target), '.*')) then true() else false()"

seems to be the same as

test="matches(string(@target), '.*'))"

I've checked the following URL:

http://www.w3.org/TR/xquery-operators/#func-matches

and it seems that "matches" returns xs:boolean:

fn:matches($input as xs:string?, $pattern as xs:string) as xs:boolean
Summary: The function returns true if $input matches the regular expression supplied as $pattern as influenced by the value of $flags, if present; otherwise, it returns false.

Best regards,
Dawid


W dniu 17.04.2013 19:28, Jim Barnett pisze:
> Mukul,
>    Yes, that fixed it.  Thank you for your prompt reply.
>
> - Jim
>
> -----Original Message-----
> From: Mukul Gandhi [mailto:[email protected]]
> Sent: Wednesday, April 17, 2013 12:26 PM
> To: [email protected]
> Subject: Re: regular expression matching in <assert>
>
> Hi Jim,
>      Thanks for sending across the schema and XML instance documents. I looked at the schema document you've shared.
>
> The following fix seems to work for your problem <assert>,
>
> <xsd:assert test="if (matches(string(@target), '.*')) then true() else false()"  xpathDefaultNamespace="##targetNamespace"/>
>
> i.e, we use a string() function around attribute node @target. The 'target' attribute within your schema has type annotation of xsd:IDREFS, therefore we seem to need this workaround.
>
> On Wed, Apr 17, 2013 at 9:06 PM, Jim Barnett <[email protected]> wrote:
>> Mukul,
>>    Thanks for your response.  I've attached a sample schema and test file (the schema is edited down from a much larger document, so it's structure may not make much sense.)   The problem is in the <assert> in line 74 of the schema.  (The simpler <assert> in line 73 works properly.)
>>
>> I suspect that you may be right about there being a namespace problem,
>> because the <assert> in line 74 fails even if I wrap not() around it.
>> So both
>>
>> <xsd:assert test="if (matches(@target, '.*')) then true() else
>> false()"  xpathDefaultNamespace="##targetNamespace"/>
>> And
>> <xsd:assert test="if not((matches(@target, '.*'))) then true() else
>> false()"  xpathDefaultNamespace="##targetNamespace"/>
>>
>> both fail, which makes it look like the processor is not finding the matches() function.
>>
>> The 'xpathDefaultNamespace="##targetNamespace"' attribute is something I stumbled across when trying to get some other assertions to work, but I admit that I don't really understand what effects it may be having.
>>
>> Thank you for your help.
>>
>> - Jim
>
>
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.