XSD Recursive just one time..why

This should cover W3C XML Schema, Relax NG and DTD related problems.
Akangel
Posts: 2

XSD Recursive just one time..why

Mon Sep 17, 2012 1:00 pm

Hey guys,

I'm trying to build a schema with a recursive element inside that call's itself.
What happens is that is just recursive one time and not unlimited as I was expecting. :(
Can anyone help me ?!

Code: Select all

   <xs:element name="Response" type="Response"/>
   <xs:complexType name="Response">
      <xs:sequence>
         <xs:element name="Asset" type="Recursive" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Recursive">
      <xs:sequence>
         <xs:element name="Id" type="xs:long" minOccurs="0"/>
         <xs:element name="CreatedBy" type="xs:string" minOccurs="0"/>
         <xs:element name="CreatedOn" type="xs:dateTime" minOccurs="0"/>
         <xs:element name="ModifiedBy" type="xs:string" minOccurs="0"/>
         <xs:element name="ModifiedOn" type="xs:dateTime" minOccurs="0"/>
         <xs:element name="VersionNr" type="xs:long" minOccurs="0"/>
         <xs:element name="AcctId" type="xs:long" minOccurs="0"/>
         <xs:element name="AssetChild" type="Recursive" minOccurs="0" maxOccurs="unbounded"/>   <------ Unlimited times
      </xs:sequence>
   </xs:complexType>


Means that by click on the list AssetChild it opens another list, so far so good, but then if click on the next AssetChild it is not recursive anymore :(, why is just limited to one call?
Akangel
Posts: 2

Re: XSD Recursive just one time..why

Mon Sep 17, 2012 2:16 pm

It's solved :), that way works perfectly.
The thing was that I was viewing the xsd on an editor that has limited capacity for extension.

Thanks anyway.
Regards,
Joao
adrian
Posts: 2384

Re: XSD Recursive just one time..why

Mon Sep 17, 2012 2:20 pm

Hi,

The schema looks fine to me. If I create an XML instance with recursive AssetChild elements, it validates.
e.g.

Code: Select all

<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="recursive.xsd">
    <Asset>
        <AssetChild>
            <AssetChild>
                <AssetChild></AssetChild>
            </AssetChild>
        </AssetChild>
    </Asset>
</Response>

If you edit the schema in Oxygen, in the Design mode, it will show you a loop icon next to the Recursive type of the AssetChild.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests