XML Schema for Node with attribute and text

Discussion in 'XML' started by Simon Vaillancourt, Nov 28, 2003.

  1. I've tried to find how to write a schema for this type of node
    everywhere.

    <Param name="FirstParam">ABCD</Param>

    How do i arrange a complex type that contains an attribute and a text.
    This :
    <xs:complexType name="Param">
    <xs:attribute name="name" />
    </xs:complexType>
    Result as :
    <invalid char="13" code="cvc-complex-type.1.2" line="3086"
    resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML
    Schema/test.xml">element Param must be empty but is not</invalid>

    This :
    <xs:complexType name="Param">
    <xs:all>
    <xs:element name="text" type="xs:string" />
    </xs:all>
    <xs:attribute name="name" />
    </xs:complexType>
    Result as :
    <invalid char="13" code="cvc-complex-type.1.2.3" line="3086"
    resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML
    Schema/test.xml">text not allowed: |ABCD|</invalid>


    I just dont know where to add the unnamed <xs:element ... > tag.

    Anyone can help me figure this out?

    Thx
    Simon Vaillancourt, Nov 28, 2003
    #1
    1. Advertising

  2. In article <>,

    Simon Vaillancourt <> wrote:
    % I've tried to find how to write a schema for this type of node
    % everywhere.
    %
    % <Param name="FirstParam">ABCD</Param>
    %
    % How do i arrange a complex type that contains an attribute and a text.


    Use xs:simpleContent.

    <xs:complexType name="Param">
    <xs:simpleContent>
    <xs:extension base="xs:string">
    <xs:attribute name="name"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>


    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, Nov 30, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page