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 -----Original Message----- From: Mukul Gandhi [mailto:muk...@apache.org] Sent: Wednesday, April 17, 2013 10:55 AM To: j-users@xerces.apache.org Subject: Re: regular expression matching in <assert> Hi Jim, Our XSD 1.1 <assert> implementation can use XPath 2.0 matches() and tokenize() functions fine. Our <assert> XPath 2.0 processor passes all W3C XPath 2.0 tests. I've checked your example with current Xerces SVN, and I don't find any bug wrt your example. I can see, that you use the xpathDefaultNamespace attribute on <assert> which may be causing issues. If you can post a complete XSD schema document along with an XML instance document, we could debug better. On Wed, Apr 17, 2013 at 12:12 AM, Jim Barnett <jim.barn...@genesyslab.com> wrote: > Are matches() and tokenize() supported inside <assert> when doing > schema validation? I am applying an assertion to an element with a 'target' > attribute whose value is "s1 s2", yet the following assertion is failing: > > > > <xsd:assert test="if (matches(@target, '.*')) then true() else false()" > xpathDefaultNamespace="##targetNamespace"/> > > > > Any guidance would be appreciated. > > > > Thanks, > > Jim -- Regards, Mukul Gandhi --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2005/07/scxml" xmlns="http://www.w3.org/2005/07/scxml" elementFormDefault="qualified"> <!-- scxml --> <xsd:attributeGroup name="scxml.scxml.attlist"> <xsd:attribute name="initial" type="xsd:IDREFS"/> </xsd:attributeGroup> <xsd:group name="scxml.scxml.mix"> <xsd:choice> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.scxml.content"> <xsd:sequence> <xsd:group ref="scxml.scxml.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.scxml.type"> <xsd:group ref="scxml.scxml.content"/> <xsd:attributeGroup ref="scxml.scxml.attlist"/> </xsd:complexType> <xsd:element name="scxml" type="scxml.scxml.type"/> <!-- state --> <xsd:attributeGroup name="scxml.state.attlist"> <xsd:attribute name="id" type="xsd:ID"/> <xsd:attribute name="initial" type="xsd:IDREFS"/> </xsd:attributeGroup> <xsd:group name="scxml.state.mix"> <xsd:choice> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.state.content"> <xsd:sequence> <xsd:group ref="scxml.state.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.state.type"> <xsd:sequence> <xsd:group ref="scxml.state.content"/> </xsd:sequence> <xsd:attributeGroup ref="scxml.state.attlist"/> </xsd:complexType> <xsd:element name="state" type="scxml.state.type"/> <!-- transition --> <xsd:attributeGroup name="scxml.transition.attlist"> <xsd:attribute name="target" type="xsd:IDREFS"/> </xsd:attributeGroup> <xsd:group name="scxml.transition.mix"> <xsd:choice> <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:group> <xsd:group name="scxml.transition.content"> <xsd:sequence> <xsd:group ref="scxml.transition.mix" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:group> <xsd:complexType name="scxml.transition.type"> <xsd:sequence> <xsd:group ref="scxml.transition.content"/> </xsd:sequence> <xsd:attributeGroup ref="scxml.transition.attlist"/> <xsd:assert test="(@event or @cond or @target)" xpathDefaultNamespace="##targetNamespace"/> <xsd:assert test="if (matches(@target, '.*')) then true() else false()" xpathDefaultNamespace="##targetNamespace"/> </xsd:complexType> <xsd:element name="transition" type="scxml.transition.type"/> </xsd:schema>
sample.scxml
Description: sample.scxml
--------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org