RE: regular expression matching in <assert>

Jim Barnett <[email protected]>
Newsgroups gmane.text.xml.xerces-j.user
Message-ID <57A15FAF9E58F841B2B1651FFE16D281038B19@GENSJZMBX02.msg.int.genesyslab.com>
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]
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.