| Author |
ref vs type in XML Schema
|
Lilly Wiesie
Greenhorn
Joined: Jan 20, 2005
Posts: 26
|
|
Would somebody tell me what's the difference between ref and type in XML schema. Seems we can use either of them. The difference seems subtle. Thanks. Lilly
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
The type attribute is used to associate either a standard or user-defined simple type or a complex type in a declaration. Examples would be defining an attribute of type="string" or type="integer", something like that. While the ref attribute is used in a declaration to associate another declaration of element/attribute which has a type. Its like declaring the type only indirectly. I would read this as 'I am of the same type as that other element'. Examples of the use of the ref attribute would be say a declaration of the Shipping-Address and Billing-Address elements. You declare the Shipping-Address element using the type attribute and associate it to a user-defined complex-type. Once that is done, you can declare the Billing-Address using the ref attribute and declare that the Billing-Address is the same type as the Shipping-Address element. <!-- ...... declare complex type AddressType..... --> <xsd:element name="Shipping-Address" type="AddressType"/> <!-- ...... other declarations ..... --> <xsd:element name="Billing-Address" ref="Shipping-Address"/> <!-- ...... other declarations ..... --> The ref attribute is mostly used to associate types from different namespaces. - m
|
Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
|
 |
Lilly Wiesie
Greenhorn
Joined: Jan 20, 2005
Posts: 26
|
|
Thanks. It looks confusing at the beginning. I got it now. Lilly
|
 |
 |
|
|
subject: ref vs type in XML Schema
|
|
|