Xml Schema - block attribute

P

ProgrammierMan

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
 
B

Bob Foster

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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top