XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Simone MilaniSubject: Restricting on an extended type
Author: Simone Milani
Date: 24 Sep 2007 09:29 AM
Originally Posted: 24 Sep 2007 09:28 AM
Can someone please confirm the below restriction is valid? Stylus says yes, XMLBeans says yes, XMLSpy says no.

Please note the substitution group.

Thanks!

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.myCompany.com/xml/reference"
xmlns:reference="http://www.myCompany.com/xml/reference"
targetNamespace="http://www.myCompany.com/xml/reference"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:complexType name="SystemReference">
<xsd:annotation>
<xsd:documentation>A system reference for an object</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="system" type="xsd:string"/>
<xsd:element name="code" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserReference">
<xsd:complexContent>
<xsd:extension base="SystemReference">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="SystemReferenceList">
<xsd:sequence>
<xsd:element ref="systemReference" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserReferenceList">
<xsd:complexContent>
<xsd:restriction base="SystemReferenceList">
<xsd:sequence>
<xsd:element ref="userReference" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="systemReference" type="SystemReference"/>
<xsd:element name="userReference" type="UserReference" substitutionGroup="systemReference"/>
</xsd:schema>


DocumentRestrictByExtension.xsd
Sample Schema

Postnext
Ivan PedruzziSubject: Restricting on an extended type
Author: Ivan Pedruzzi
Date: 24 Sep 2007 11:59 AM

All XML Schema processors available in Stylus Studio (Saxon, .NET, MSXML, Xerces, XSV) pass validation using the following documents.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team



<?xml version="1.0"?>
<p1:userReference
xmlns:p1="http://www.myCompany.com/xml/reference"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myCompany.com/xml/reference RestrictByExtension.xsd">
<p1:system>string</p1:system>
<p1:code>string</p1:code>
</p1:userReference>

-------------------------------------------------------------

<?xml version="1.0"?>
<p1:systemReference
xmlns:p1="http://www.myCompany.com/xml/reference"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myCompany.com/xml/reference RestrictByExtension.xsd">
<p1:system>string</p1:system>
<p1:code>string</p1:code>
</p1:systemReference>

Postnext
Simone MilaniSubject: Restricting on an extended type
Author: Simone Milani
Date: 24 Sep 2007 12:15 PM
Thanks Ivan,

What I was actually asking was is whether my schema is actually a valid schema and if doing that type of restriction is actually OK. I checked the spec and could not really work out if it's a valid restriction. Any ideas on which part of the XSD spec (if any) would cover my restriction scenario?

Thanks!

Simone

Postnext
Ivan PedruzziSubject: Restricting on an extended type
Author: Ivan Pedruzzi
Date: 24 Sep 2007 04:25 PM

I believe the schema is valid based on the definition given at

http://www.w3.org/TR/xmlschema-0/#DerivByRestrict

<<"A complex type derived by restriction is very similar to its base type, except that its declarations are more limited than the corresponding declarations in the base type. In fact, the values represented by the new type are a subset of the values represented by the base type (as is the case with restriction of simple types). In other words, an application prepared for the values of the base type would not be surprised by the values of the restricted type.">>

UserReference is defined as substitution of SystemReference, because UserReference can safely replace any instance of SystemReference without breaking the data model, the type extension is valid.

An example of incorrect extension would be changing the cardinality

<xsd:element ref="userReference" minOccurs="1" maxOccurs="2"/>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
Simone MilaniSubject: Restricting on an extended type
Author: Simone Milani
Date: 25 Sep 2007 05:37 AM
Many thanks!

Simone

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.