XML Schema - Custom types and Attributes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sorrow

    #1

    XML Schema - Custom types and Attributes

    Say I have the following (simplistic) schema:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
    <xs:element name="RootNode" >
    <xs:complexType >
    <xs:sequence>
    <xs:element name="FirstChil dElement" type="Integer8T ype" minOccurs="1"/>
    <xs:element name="SecondChi ldElement" type="Integer8T ype"
    minOccurs="1"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:simpleTyp e name="Integer8T ype">
    <xs:restricti on base="xs:intege r">
    <xs:minInclusiv e value="0"/>
    <xs:maxInclusiv e value="99999999 "/>
    </xs:restriction>
    </xs:simpleType>
    </xs:schema>

    I have "Integer8Ty pe" as a custom type. Now, keeping it so that
    my "FirstChildElem ent" element is of "Integer8Ty pe", how can I
    define that the "FirstChildElem ent" element has an attribute? I've
    looked everywhere I can think of and I can't find an example that
    would keep that element as type "Integer8Ty pe". It always shows
    that I'd have to make the "FirstChildElem ent" element a complex
    type.
    Could anyone point me in the right direction where I can find the
    relevant information on defining attributes for custom typed
    elements?

    thnx,
    Christoph


  • Henry S. Thompson

    #2
    Re: XML Schema - Custom types and Attributes

    "Sorrow" <jcboget@yahoo. com> writes:
    [color=blue]
    > I have "Integer8Ty pe" as a custom [simple] type. Now, keeping it so that
    > my "FirstChildElem ent" element is of "Integer8Ty pe", how can I
    > define that the "FirstChildElem ent" element has an attribute?[/color]

    You can't get there from here.

    If you had defined Integer8Type as a complex type with simple content,
    _then_ you could <redefine> it by extension to add an attribute.

    ht
    --
    Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
    Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
    Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
    URL: http://www.ltg.ed.ac.uk/~ht/
    [mail really from me _always_ has this .sig -- mail without it is forged spam]

    Comment

    • Sorrow

      #3
      Re: XML Schema - Custom types and Attributes

      > > I have "Integer8Ty pe" as a custom [simple] type. Now, keeping it so
      that[color=blue][color=green]
      > > my "FirstChildElem ent" element is of "Integer8Ty pe", how can I
      > > define that the "FirstChildElem ent" element has an attribute?[/color]
      > You can't get there from here.
      > If you had defined Integer8Type as a complex type with simple content,
      > _then_ you could <redefine> it by extension to add an attribute.[/color]

      Perhaps you can provide an example? I'm still just learning.

      thnx,
      Christoph


      Comment

      • Henry S. Thompson

        #4
        Re: XML Schema - Custom types and Attributes

        "Sorrow" <jcboget@yahoo. com> writes:
        [color=blue][color=green][color=darkred]
        >> > I have "Integer8Ty pe" as a custom [simple] type. Now, keeping it
        >> > so that my "FirstChildElem ent" element is of "Integer8Ty pe", how
        >> > can I define that the "FirstChildElem ent" element has an
        >> > attribute?[/color][/color][/color]
        [color=blue][color=green]
        >> You can't get there from here.
        >> If you had defined Integer8Type as a complex type with simple content,
        >> _then_ you could <redefine> it by extension to add an attribute.[/color]
        >
        > Perhaps you can provide an example? I'm still just learning.[/color]

        schemaV1.xsd:

        <xs:complexTy pe name="Integer8T ype">
        <xs:simpleConte nt>
        <xs:restricti on base="xs:intege r">
        <xs:minInclusiv e value="0"/>
        <xs:maxInclusiv e value="99999999 "/>
        </xs:restriction>
        </xs:simpleConten t>
        </xs:complexType>

        . . .

        <xs:element name="FirstChil dElement" type="Integer8T ype"/>

        schemaV2.xsd:

        <xs:redefine schemaLocation= "schemaV1.x sd">
        <xs:complexTy pe name="Integer8T ype">
        <xs:simpleConte nt>
        <xs:extension base="Integer8T ype">
        <xs:attribute name="something " type="something Else"/>
        </xs:extension>
        </xs:simpleConten t>
        </xs:complexType>
        </xs:redefine>

        ht
        --
        Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
        Half-time member of W3C Team
        2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
        Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
        URL: http://www.ltg.ed.ac.uk/~ht/
        [mail really from me _always_ has this .sig -- mail without it is forged spam]

        Comment

        Working...