Xml Schema - block attribute

Discussion in 'XML' started by ProgrammierMan, Sep 7, 2003.

  1. Hi folks,

    I don't know what the block attribute means. The final attribute looks
    like to be simple: I can prevent derivations. Did I write
    final="restriction" and I restrict it in another complexType XML Spy
    said, that it's wrong - fine.

    But my "block" examples don't work:

    Schema:

    <xs:complexType name="AA">
    <xs:complexContent>
    <xs:extension base="XXX">
    <xs:sequence>
    <xs:element name="AA" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="BB">
    <xs:complexContent>
    <xs:extension base="XXX">
    <xs:sequence>
    <xs:element name="BB" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="XXX" abstract="true" block="extension">
    <xs:sequence>
    <xs:element name="A" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>

    <xs:element name="test" type="XXX"/>


    Instance:

    <ttt:test xmlns:ttt="http://Olli"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://Olli
    C:\test.xsd" xsi:type="ttt:AA">

    <A></A>
    <AA></AA>

    </ttt:test>

    ----
    I expected, that the Validator give a message like: No you forbid it
    -you said in the schema that you don't want! But Xml Spy means
    everything is fine. Why? Maybe you've got a better example for me to
    learn what "block" means.

    tnx a lot,
    Olli
     
    ProgrammierMan, Sep 7, 2003
    #1
    1. Advertising

  2. ProgrammierMan

    Bob Foster Guest

    A simple way to think about these is that final constrains schemas while
    block constrains documents. Block substitution says an instance document
    can't replace an element in the model with one from its substitution group;
    block restriction/extension say an instance can't use an xsi:type that is a
    restriction/extension of the declared element type.

    Bob Foster
    http://www.xmlbuddy.com/

    "ProgrammierMan" <> wrote in message
    news:...
    > Hi folks,
    >
    > I don't know what the block attribute means. The final attribute looks
    > like to be simple: I can prevent derivations. Did I write
    > final="restriction" and I restrict it in another complexType XML Spy
    > said, that it's wrong - fine.
    >
    > But my "block" examples don't work:
    >
    > Schema:
    >
    > <xs:complexType name="AA">
    > <xs:complexContent>
    > <xs:extension base="XXX">
    > <xs:sequence>
    > <xs:element name="AA" type="xs:string"/>
    > </xs:sequence>
    > </xs:extension>
    > </xs:complexContent>
    > </xs:complexType>
    >
    > <xs:complexType name="BB">
    > <xs:complexContent>
    > <xs:extension base="XXX">
    > <xs:sequence>
    > <xs:element name="BB" type="xs:string"/>
    > </xs:sequence>
    > </xs:extension>
    > </xs:complexContent>
    > </xs:complexType>
    >
    > <xs:complexType name="XXX" abstract="true" block="extension">
    > <xs:sequence>
    > <xs:element name="A" type="xs:string"/>
    > </xs:sequence>
    > </xs:complexType>
    >
    > <xs:element name="test" type="XXX"/>
    >
    >
    > Instance:
    >
    > <ttt:test xmlns:ttt="http://Olli"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xsi:schemaLocation="http://Olli
    > C:\test.xsd" xsi:type="ttt:AA">
    >
    > <A></A>
    > <AA></AA>
    >
    > </ttt:test>
    >
    > ----
    > I expected, that the Validator give a message like: No you forbid it
    > -you said in the schema that you don't want! But Xml Spy means
    > everything is fine. Why? Maybe you've got a better example for me to
    > learn what "block" means.
    >
    > tnx a lot,
    > Olli
     
    Bob Foster, Sep 7, 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