W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2016

Re: Simple assert on descendant nodes does not throw error

From: Christophe Marchand <cmarchand@oxiane.com>
Date: Fri, 9 Sep 2016 16:04:26 +0200
To: Michael Kay <mike@saxonica.com>
Cc: xmlschema-dev@w3.org
Message-ID: <4dd32ce6-c080-373e-db8d-84a692a11483@oxiane.com>
Well, I can not manage to make it good.

I've clean/simplified schema, to have something that can easily be 
reproduced.
Attached, a schema and a sample file, with 4 cases ; the 3 first are 
expected to be valid, the last one is expected to be invalid.
The assert that causes problem is at lines 24..27

If someone has 10 minutes to loose, I'll appreciate help.

Thanks in advance,
Christophe


Le 07/09/2016 à 10:55, Michael Kay a écrit :
> The fact that you use cfg:TPipe to refer to the type is a clue that the schema has a targetNamespace which you haven't shown us. This would suggest that the pipe element is also in a namespace which you haven't shown us, and if this is the case then my guess is that the xslt element is also in a namespace, in which case the XPath expression in the assertion needs to use a prefixed name to refer to it (or to declare a default XPath namespace).
>
> Michael Kay
> Saxonica
>
>> On 6 Sep 2016, at 17:21, Christophe Marchand <cmarchand@oxiane.com> wrote:
>>
>> Hello,
>>
>> I've just added a simple assert to my schema, and I can not get errors validating wrong documents. I can nto find why.
>> Any help will be much appreciated...
>>
>> Best,
>> Christophe
>>
>> My schema :
>>     <xs:complexType name="TPipe">
>>         <xs:sequence>
>>             <xs:choice maxOccurs="unbounded">
>>                 <xs:element name="xslt" />
>>                 ...
>>             </xs:choice>
>>         </xs:sequence>
>>         <xs:attribute name="nbThreads" type="xs:integer" default="1" use="optional"/>
>>         <xs:attribute name="mutiThreadMaxSourceSize"/>
>>         <xs:attribute name="traceOutput" type="xs:string"/>
>>         <xs:assert test="if(not(./@traceOutput)) then empty(descendant::xslt[@traceActive='true']) else true()"/>
>>     </xs:complexType>
>>     <xs:element name="pipe" type="cfg:TPipe"/>
>>
>> The document I expect an error to be thrown for :
>>     <pipe nbThreads="1" mutiThreadMaxSourceSize="" >
>>                 <xslt href="src/test/resources/identity.xsl" traceActive="true"/>
>>                 <output id="pipe1" >
>>                     <folder absolute="./target/generated-test-files"/>
>>                     <fileName name="${basename}-pipe1.xml"/>
>>                 </output>
>>     </pipe>
>>
>>
>>
>
>


Received on Friday, 9 September 2016 14:04:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:11 UTC