- From: Michael Kay <mike@saxonica.com>
- Date: Fri, 10 Feb 2012 14:20:03 +0000
- To: xmlschema-dev@w3.org
- Message-ID: <4F352793.8010701@saxonica.com>
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 > >
Received on Friday, 10 February 2012 14:20:34 UTC