Re: [xml-dev] What's difference between ref and type in XML schema
If we create the data type for an element and refer to it rather than creating the code for datatype inline in the element, we can use the same data type in other elements also.
e.g.
<xsd:element name="A" type="AType" maxOccurs="unbounded"/>
<xsd:complexType name="AType">
..
</xsd:complexType>
<xsd:complexType name="AType">
..
</xsd:complexType>
Here, if you want to use the same type 'AType' in other element also , say B, you can use the following syntax for that.
<xsd:element name="B" type="AType"/>.
If you coded like this
<xsd:element ref="A" maxOccurs="unbounded"/>
<xsd:element name="A">
<xsd:complexType>
...
</xsd:complexType>
</xsd:element>
then you can not use the same type in other elements. i.e. it is not reusable.
<xsd:element name="A">
<xsd:complexType>
...
</xsd:complexType>
</xsd:element>
then you can not use the same type in other elements. i.e. it is not reusable.
So from the point of OOP, we prefer the first form.
"Baisak, Ranjan" <[email protected]> wrote:
I am bit confused regarding referring an element and creating a data
type for an element and referring it.
E.g.
Referring by type
..
Referring by element itself
...
regards,
-Ranjan
-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org , an
initiative of OASIS
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription
manager:
Thanks & Regards,
Chandrashekhar P. Otari
Software Engineer
------------------------------------------------------------
Suma Soft Pvt. Ltd.
Suma Center, 2nd Floor, Opp. Himali Society,
Near Mangeshkar Hospital, Erandawane,
Pune 411004.
Phone 25425655, 25424253
------------------------------------------------------------
Chandrashekhar P. Otari
Software Engineer
------------------------------------------------------------
Suma Soft Pvt. Ltd.
Suma Center, 2nd Floor, Opp. Himali Society,
Near Mangeshkar Hospital, Erandawane,
Pune 411004.
Phone 25425655, 25424253
------------------------------------------------------------
Yahoo! India Matrimony: Find your life partner online.