xml - How to have the same attribute name reference two different types in the same namespace? -
all xml attributes in different namespace, xsd references them other xsd. have 2 different elements attribute same name, different types.
<integer ons:name="10" /> <string ons:name="string"/>
so integer
element has ons:name
attribute integer
while string
element has ons:name
attribute string
.
how define in xsd? have:
<xs:element name="integer"> <xs:complextype> <xs:attribute ref="ons:name" use="required"/> </xs:complextype> </xs:element>
then in second xsd ons
namespace have following:
then problem second element's attribute there no way specify type
ref
, , if ref
references different attribute gets different name.
in schema document namespace ons
, define 2 singleton attribute groups:
<xs:attributegroup name="name-int"> <xs:attribute name="name" type="xs:integer" use="required" form="qualified"/> </xs:attribute-group> <xs:attributegroup name="name-str"> <xs:attribute name="name" type="xs:string" form="qualified"/> </xs:attribute-group>
then reference attribute group complex type:
<xs:complextype> <xs:attributegroup ref="ons:name-int"/> </xs:complextype>
Comments
Post a Comment