Re: xsd:list should allow a 'delimiter' attribute discussion

Also, this approach might give the right yes/no answer from validation, but it won't give you a list as the typed value if you're doing data binding or schema-aware XSLT/XQuery.

Saxon provides as an XSD 1.1 extension a pre-lexical facet called saxon:preprocess, in which you can convert the delimiters to spaces and then process as a standard list type. A specific pre-lexical facet to define the delimiter would be an even better solution. However, extensions like this are not really much use - most people want their schemas to be portable across multiple schema processors.

Michael Kay
Saxonica

> On 29 Mar 2018, at 13:01, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
> 
> Hi all,
>    Referring to this thread, https://lists.w3.org/Archives/Public/www-xml-schema-comments/2002OctDec/0003.html <https://lists.w3.org/Archives/Public/www-xml-schema-comments/2002OctDec/0003.html> a while ago, interestingly I discovered that this is now possible with XSD 1.1 assertions. With assertions we can't specify the attribute 'delimiter' on xsd:list, but we can achieve a very similar effect.
> 
> Here's an example.
> 
> The XML document is,
> 
> <User values="5;6;7" />
> 
> And the XSD 1.1 document would be,
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema>">
>   
>   <xs:element name="User">
>     <xs:complexType>
>       <xs:simpleContent>
>         <xs:extension base="xs:string">
>           <xs:attribute name="values">
>              <xs:simpleType>
> 	        <xs:restriction base="xs:string">
> 	           <xs:assertion test="every $x in tokenize($value, ';') satisfies (number($x) ge 5) and (number($x) le 7)"/>
> 	        </xs:restriction>	              
>              </xs:simpleType>
>           </xs:attribute>
>         </xs:extension>
>       </xs:simpleContent>
>     </xs:complexType>
>   </xs:element>
> 
> </xs:schema>
> 
> In this example, each list item should be a number inclusive between 5 & 7. The XPath semantics after 'satisfies' could be anything that each list item should obey.
> 
> The only drawback I see with this is (at-least with Xerces's XSD 1.1 processor), poorer error diagnostics. The whole assertion is reported as failing, instead of pointing the specific list item that doesn't satisfy the list's itemType specified in this way.
>  
> 
> 
> -- 
> Regards,
> Mukul Gandhi

Received on Thursday, 29 March 2018 12:41:51 UTC