Element with attribute

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IsValidUN
    New Member
    • Jul 2007
    • 17

    #1

    Element with attribute

    How do you define an element within a schema that has an attribute
    For example in the following Offset has an attribute + a long value:
    [code=xml]<Cue>
    <Name>mycue</Name>
    <Offset Kind="Start">0</Offset>
    </Cue>[/code]

    This doesn't work
    [code=xml]<xs:element name="Cue">
    <xs:complexType >
    <xs:all>
    <xs:element name="Name" type="xs:string "/>
    <xs:element name="Offest">
    <xs:complexType >
    <xs:attribute name="Kind" type="TKind"/>
    </xs:complexType>
    </xs:element>
    </xs:all>
    </xs:complexType>

    <xs:simpleTyp e name ="TKind">
    <xs:restricti on base="xs:string ">
    <xs:enumerati on value="End"/>
    <xs:enumerati on value="Start"/>
    </xs:restriction>
    </xs:simpleType>[/code]
    Last edited by jkmyoung; Jan 21 '08, 08:42 PM. Reason: code blocks
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    [code=xml]
    <xs:element name="Offset">
    <xs:complexType >
    <xs:simpleConte nt>
    <xs:extension base="xs:string ">
    <xs:attribute name="Kind" type="TKind"/>
    </xs:extension>
    </xs:simpleConten t>
    </xs:complexType>
    </xs:element>
    [/code]

    Comment

    Working...