Page 1 of 1

XSD Recursive just one time..why

Posted: Mon Sep 17, 2012 1:00 pm
by Akangel
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?

Re: XSD Recursive just one time..why

Posted: Mon Sep 17, 2012 2:16 pm
by Akangel
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

Re: XSD Recursive just one time..why

Posted: Mon Sep 17, 2012 2:20 pm
by adrian
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