473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Schema Derivation by Restriction

I am trying to create an XML Schema type definition by deriving from another
type definition using restriction. For example suppose my base type was
this:

<xs:schema <<schema element setup>> >
<xs:complexType name="Fruits">
<xs:sequence>
<xs:any minOccurs="8" maxOccurs="8"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

and I wanted to derive to create a type that requires that the first fruit
is an apple but still have a max of 8 "Fruits". For example without using
derivation I'd have:

<xs:schema <<schema element setup>> >
<xs:complexType name="Fruits">
<xs:sequence>
<xs:element name="Apple">
<xs:complexType/>
</xs:element>
<xs:any minOccurs="7" maxOccurs="7"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

How would I acheive this using derivation by restriction?

Thanks,
Wells
Nov 12 '05 #1
3 1590
Hi Wells,

Thank you for using MSDN Newsgroup! My name is Kevin, and I will be
assisting you on this issue.

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you're writing the Xml schema of a type
and would like to reuse it with derivation.

As far as I know, we have to re-list all the parts of the base types while
doing derivation. Here's an example. Suppose we have defined a Person type.
Now we need to derive from it to define a RestrictedPerson. It will looks
like the following:

<xsd:complexType name="RestrictedPerson">
<xsd:complexContent>
<xsd:restriction base="tns:Person">
<!-- redefine base type's particles here -->
...
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

The xsd:restriction element indicates the base type we're restricting and
it contains the new definitions for all of the base type's particles (e.g.,
compositors, element definitions, wildcards, etc.). When doing this, you
must list all of the particles of the base type as well as those of the
base type's ancestors, if it has any. I think the complexity might be
similar to not using derivation.

Here is an article about how to designing XML schema libraries. Hope this
will be helpful to you.

http://msdn.microsoft.com/library/de...us/dnxml/html/
desxsdlib.asp

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2
Hi Kevin,

Thank you for the reply. Your reply and the link are exactly what I needed.
I tried get this info from the XML Schema definition, but that is not the
easiest to read document.

Thanks,
Wells
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:2g**************@cpmsftngxa08.phx.gbl...
Hi Wells,

Thank you for using MSDN Newsgroup! My name is Kevin, and I will be
assisting you on this issue.

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you're writing the Xml schema of a type and would like to reuse it with derivation.

As far as I know, we have to re-list all the parts of the base types while
doing derivation. Here's an example. Suppose we have defined a Person type. Now we need to derive from it to define a RestrictedPerson. It will looks
like the following:

<xsd:complexType name="RestrictedPerson">
<xsd:complexContent>
<xsd:restriction base="tns:Person">
<!-- redefine base type's particles here -->
...
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

The xsd:restriction element indicates the base type we're restricting and
it contains the new definitions for all of the base type's particles (e.g., compositors, element definitions, wildcards, etc.). When doing this, you
must list all of the particles of the base type as well as those of the
base type's ancestors, if it has any. I think the complexity might be
similar to not using derivation.

Here is an article about how to designing XML schema libraries. Hope this
will be helpful to you.

http://msdn.microsoft.com/library/de...us/dnxml/html/ desxsdlib.asp

Does this answer your question? If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #3
Hi Wells,

I'm glad that my reply makes sense. If you have any further questions or
concerns, please feel free to post it in the group. I'm standing by to be
of assistance.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4

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

Similar topics

4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
3
by: hre1 | last post by:
stan, once more, thank you for your assistance and patience. can you explain in more detail why my code violates the particle restriction ok (Elt:Elt -- NameAndTypeOK)? i tried to understand...
1
by: Soren Kuula | last post by:
Hi, 1) If I have a definition + declaration like <complexType name="fattype"> <complexContent> <element name="bar" minOccurs="0" maxOccurs="342"/> </complexContent> <attribute...
12
by: steve_marjoribanks | last post by:
I'm fairly new to XML and schemas and I'm trying to work out why a schema I've been given keeps throwing up validation errors in XMLSpy. The section of code with the problem is: ...
0
by: Mark Parter | last post by:
I'm trying convert an XML Schema (http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net class using the XSD tool provided with the .NET 2 SDK. However, it's failing to generate...
2
by: Krzysztof Nogal | last post by:
Hi, I have following problem with XML Schema definition. I have following element InitialEcrHeader: <xs:complexType name="InitialEcrHeader"> <xs:complexContent> <xs:extension...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
3
by: Kai Schlamp | last post by:
Hello! In my schema I have the following: <xs:complexType name="textareaType"> <xs:simpleContent> <xs:restriction base="xs:string"> <xs:attribute ref="label" use="required" />...
2
by: MarianM | last post by:
Hi all, how to validate xades xml against xades and xmlsig schemas? i have this sample: XmlTextReader xmlReader = new XmlTextReader(@"..\..\Data\xades_zep- epes.xml"); XmlReaderSettings...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.