Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Duplicate XSD Elements

Status
Not open for further replies.

jmadux2003

Programmer
Jul 2, 2009
1
In XSD, how would I go about defining 2 elements of the same name(e.g., Input), but have different attribute requirements depending on a particular type?

For example, with html, the attributes you provide for the Input element are dependent on the value you provide for the Type attribute.

<Input Type="text" name="name1" maxlength="20"/>
<Input Type="checkbox" checked="checked"/>


Thanks in advance.
 
If xhtml is the sole target document type, you can refer to w3c note (work-in-progress) on xhtml (1.0) schemas (strict and transitional) imitating the DTD's.
ref Specifically, you can inspect the construction of
[ol]
[li]xs:simpleType name="InputTpe[/li]
[li]xs:element name="input[/li]
[li]xs:element name="select"[/li]
[li]xs:element name="option"[/li]
[li]xs:element name="textarea"[/li]
[li]xs:attributeGroup name="attrs"[/li]
[li]xs:attributeGroup name="focus"[/li]
[li]etc.[/li]
[/ol]
You might notice that there checked attribute is admitted text input element, though it should have no visual effect, at the mercy of the application with uncertain interpretation... This is no difference of xhtml expressed in DTD.

To enforce a restriction on other attributes such as checked when the type is text or checkbox, say, is a very much unrewarding exercise, it seems. wxsl is very unexpressive for this kind of co-occurrence constraints and mostly can not even be done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top