xsd - Is it possible to define an element group which contains attribute groups? -
I am defining xsd with many complex elements that repeat the same structure under various elements. Sample:
& lt; Keys & gt; & Lt; Ad-key & gt; & Lt; Add Key = "New Key" value = "v1" & gt; & Lt; / Ad-key & gt; & Lt; Dell Keys & gt; & Lt; Add Key = "Bad Key" value = "v2" & gt; & Lt; / Dell Keys & gt; & Lt; / Key & gt;
What is the correct way to define the following? I can not parse the schema when using this segment of code.
& lt; X: complex type name = "keytype" & gt; & Lt; Xs: sequence maxOccurs = "unauthorized" & gt; & Lt; Xs: element name = "add" & gt; & Lt; XS: complexType & gt; & Lt; Xs: attribute group riff = "key specialty group" /> & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; & Lt; Xs: Specialty Group Name = "Key Attribute Group" & gt; & Lt; Xs: attribute name = "key" type = "x: string" = "required" /> & Lt; Xs: attribute name = "value" type = "x: string" = "required" /> & Lt; / XS: attributeGroup & gt;
If you already know that all names have an element type type can have ( add-key, del-key
), then it is possible to use an anonymous solution :
& lt; Xs: schema xmlns: xs = "http://www.w3.org/2001/XMLSchema" & gt; & Lt; Xs: element name = "keys" & gt; & Lt; XS: complexType & gt; & Lt; Xs: likes maxOccurs = "unbounded" & gt; & Lt; Xs: element name = "add-key" type = "keytype" /> & Lt; Xs: element name = "del-key" type = "keytype" /> & Lt; / XS: Options & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; X: complex type name = "keytype" & gt; & Lt; Xs: sequence maxOccurs = "unauthorized" & gt; & Lt; Xs: element name = "add" & gt; & Lt; XS: complexType & gt; & Lt; Xs: attribute group riff = "key specialty group" /> & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; & Lt; Xs: Specialty Group Name = "Key Attribute Group" & gt; & Lt; Xs: attribute name = "key" type = "x: string" = "required" /> & Lt; Xs: attribute name = "value" type = "x: string" = "required" /> & Lt; / XS: attributeGroup & gt; & Lt; / XS: Schema & gt;
If the element can have any random name ( add-key, del-key, whatever
), then the closest solution I know is its xs: any
to use.
Comments
Post a Comment