Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Xml Schema - block attribute

Reply
Thread Tools

Xml Schema - block attribute

 
 
ProgrammierMan
Guest
Posts: n/a
 
      09-07-2003
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"
xmlnssi="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
 
Reply With Quote
 
 
 
 
Bob Foster
Guest
Posts: n/a
 
      09-07-2003
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: om...
> 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"
> xmlnssi="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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
In xml schema, what's the difference between attribute "final" and "block" in element "element" tankbattle XML 1 07-21-2006 07:51 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML schema validation of one xml block based on values from another xml block Andy XML 0 11-18-2004 11:04 PM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM



Advertisments