473,748 Members | 4,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In xml schema, what's the difference between attribute "final" and "block" in element "element"

That is, what's the difference between
<complexType name="Address" final="restrict ion">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
<element name="city" type="string"/>
</sequence>
</complexType>
and
<complexType name="Address" block="restrict ion">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
<element name="city" type="string"/>
</sequence>
</complexType>
in xml schema?

Jul 20 '06 #1
1 4745
Hi,

You can think of final as a development time restriction (applies to
schema itself) and of block as a runtime restriction (applies to schema
usage from the instance documents).

If you have final="restrict ion" (note that I made city optional to have
something to restrict)

<xs:complexTy pe name="Address" final="restrict ion">
<xs:sequence>
<xs:element name="name" type="xs:string "/>
<xs:element name="street" type="xs:string "/>
<xs:element name="city" type="xs:string " minOccurs="0"/>
</xs:sequence>
</xs:complexType>

then trying to create a type like below will fail with an error:

<xs:complexTy pe name="Restricte dAddress">
<xs:complexCont ent>
<xs:restricti on base="Address">
<xs:sequence>
<xs:element name="name" type="xs:string "/>
<xs:element name="street" type="xs:string "/>
</xs:sequence>
</xs:restriction>
</xs:complexConte nt>
</xs:complexType>

But if you block restriction

<xs:complexTy pe name="Address" block="restrict ion">
<xs:sequence>
<xs:element name="name" type="xs:string "/>
<xs:element name="street" type="xs:string "/>
<xs:element name="city" type="xs:string " minOccurs="0"/>
</xs:sequence>
</xs:complexType>

then you can derive the RestrictedAddre ss type from it.

Let's assume further that you use block="restrict ion" and you have also
two element declarations in your schema as below:

<xs:element name="test1" type="Address"/>
<xs:element name="test2" type="Restricte dAddress"/>

Then, when you create instance documents you can have a valid instance
like:

<test1 xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test.xsd">
<name></name>
<street></street>
<city></city>
</test1>

But if you want to use xsi:type to specify that test1 is actually of
the RestrictedAddre ss type:

<test1 xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test.xsd" xsi:type="Restr ictedAddress">
<name></name>
<street></street>
</test1>

Then you will get an error as RestrictedAddre ss type cannot be used
instead of Address type because you blocked restriction for the Address
type. If you remove block="restrict ion" from the schema you can see
that the above instance becames valid.

But if you use test2 has RestrictedAddre ss as type then you get a valid
instance:

<test2 xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test.xsd">
<name></name>
<street></street>
</test2>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

tankbattle wrote:
That is, what's the difference between
<complexType name="Address" final="restrict ion">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
<element name="city" type="string"/>
</sequence>
</complexType>
and
<complexType name="Address" block="restrict ion">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
<element name="city" type="string"/>
</sequence>
</complexType>
in xml schema?
Jul 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2208
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore anything I'll write should be stuck on a single file. I thought about creating a funny pop-up. <a href="javascript:myFunction();"... that's because, as you will see, the code for the popup is pretty complex. I've insterted myFunction somewhere...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.