Re: Query reg Recursion

Michael Kay <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
In XSD 1.1 you can write

<xsd:assert test="empty(Ety/Ety/Ety)"/>

if you want to allow two levels of nesting but not three.

There's no equivalent in XSD 1.0.

Michael Kay
Saxonica

On 09/02/2012 07:17, kamal krishna wrote:
> hi team,
>
> I was wondering if you could help me in understanding and designing 
> the recursion in the XSD. My question is regarding defining the max 
> depth of the recursion at the time of definition of the schema. For 
> ex, if I refer to a recursive element, I want to define the number of 
> times the element can be called recursively.
>
> This way I can avoid infinite recursion or creating duplicate objects 
> for calling an object within itself. Please find below the sample 
> schema that I prepared to explain this issue:
>
> /<?xml version="1.0" encoding="UTF-8"?>/
> /<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> elementFormDefault="qualified"/
> /    attributeFormDefault="unqualified">/
> /
> /
> /<xsd:element name="Ety" type="Entity"/>/
> /<xsd:complexType name="Entity">/
> /<xsd:sequence>/
> /<xsd:element name="A" type="xsd:string" minOccurs="0"/>/
> /<xsd:element name="B" type="xsd:string" minOccurs="0"/>/
> /<xsd:element name="C" type="xsd:string" minOccurs="0"/>/
> /<xsd:element name="EntityAssoc" type="EntityAssoc" minOccurs="0"/>/
> /</xsd:sequence>/
> /</xsd:complexType>/
> /<xsd:complexType name="EntityAssoc">/
> /<xsd:sequence>/
> /<xsd:element name="C" type="xsd:string" minOccurs="0"/>/
> /<xsd:element name="D" type="xsd:string" minOccurs="0"/>/
> /<xsd:element type="Entity" name="Entity" minOccurs="0"/>/
> /</xsd:sequence>/
> /</xsd:complexType>/
> /</xsd:schema>/
>
> I want only one iteration of the EntityAssoc within Entity. Could you 
> please let me know if this is possible?
>
> Thanks a lot for your help,
>
> Regards,
> Krishna Kamal
>
>
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.