Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / January 2004

Tip: Looking for answers? Try searching our database.

Schema Derivation by Restriction

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wells Caughey - 16 Jan 2004 00:11 GMT
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
Kevin Yu [MSFT] - 16 Jan 2004 08:20 GMT
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/default.asp?url=/library/en-us/dnxml/html/
desxsdlib.asp

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

Kevin Yu
Signature

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

Wells Caughey - 16 Jan 2004 16:09 GMT
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

> Hi Wells,
>
[quoted text clipped - 28 lines]
> Here is an article about how to designing XML schema libraries. Hope this
> will be helpful to you.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxml/html/
> desxsdlib.asp
>
[quoted text clipped - 5 lines]
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
Kevin Yu [MSFT] - 17 Jan 2004 01:39 GMT
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
Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.