Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2010, 11:04 AM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extending an XML Schema content model

I am leveraging an existing XML schema that I cannot modify, however, I want to allow for additional child elements (that belong to a different namespace). For example, the existing schema allows for:

<book>
<author/>
<title/>
</book>

And I want to extend the <book> content model to allow:

<book>
<author/>
<title/>
<my:isbn/>
</book>

Am I able to define a my own schema document with a new <book> element definition that would override the existing definition?

Any help is greatly appreciated.
 
Old June 24th, 2010, 11:18 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Provided the complex type of <book> is defined as a named type definition, then you can create a type derived from this by extension, or you can redefine the complex type. But if the type was anonymous, you can't. In XSD 1.1 you will be able to use xs:override for this.

Michael Kay
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 24th, 2010, 01:35 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To clarify, if the element definition is:

<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element ref="author"/>
...
</xs:sequence>
</xs:complexType>
</xs:element>

then I am unable to extend the schema to allow for other child elements that belong to a different namespace. Is this correct?

Thanks again for your help.
 
Old June 24th, 2010, 02:16 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Is this correct?

Yes.

Except of course by creating a different schema using cut and paste.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Any tool to validate the length of each xml attribute against an xml schema LeoMathew XML 6 December 8th, 2009 05:02 AM
Any tool to validate the length of each xml attribute against an xml schema LeoMathew XSLT 0 December 7th, 2009 02:18 AM
Problem with date format in XML and XML Schema nelly78 XML 3 October 23rd, 2009 09:43 AM
put an xml schema in an email content using asp.ne ariyanto ASP.NET 1.0 and 1.1 Basics 0 September 11th, 2006 09:02 AM
Content model imroostercogburn XML 1 August 13th, 2006 02:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.