Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: issue with restrictions

From: "Pete Cordell" <petexmldev@--------------.--->
To: "Guillaume Lebleu" <gl@---------.--->, <xmlschema-dev@--.--->
Date: 3/7/2007 1:49:00 PM
I'm not fully sure what you're looking for, but one possibility might be the 
following approach:

    <xs:element name="SearchRequest" abstract="true">
        <xs:complexType/>
    </xs:element>

    <xs:element name="StartDate" type="xs:date"/>
    <xs:element name="EndDate" type="xs:date"/>

   <xs:element name="SearchRequestByDate" substitutionGroup="SearchRequest">
        <xs:complexType>
            <xs:complexContent>
                <xs:extension base="SearchRequest">
                    <xs:sequence>
                    <xs:element ref="StartDate"/>
                    <xs:element ref="EndDate" minOccurs="0"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
   </xs:element>

This does mean you would have to pre-define all the permitted search types.

If you want users to be able to put together what they like, using a number 
of predefined building blocks, then I don't think you need to actually use 
the SearchRequestByDate type (everything is a SearchRequest).

In that case it might be simpler to make SearchRequest a choice of permitted 
search criterion, e.g.:

    <xs:element name="SearchRequest">
        <xs:complexType>
            <xs:choice  maxOccurs="unbounded">
                    <xs:element ref="StartDate"/>
                    <xs:element ref="EndDate" />
                ...
            </xs:choice>
        </xs:complexType>
    </xs:element>

Or, if your occurrence constraints are favorable(!), then:

    <xs:element name="SearchRequest">
        <xs:complexType>
            <xs:all>
                    <xs:element ref="StartDate"/>
                    <xs:element ref="EndDate"/>
                ...
            </xs:all>
        </xs:complexType>
    </xs:element>

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============================================

----- Original Message ----- 
From: "Guillaume Lebleu" <gl@b...>
To: <xmlschema-dev@w...>
Sent: Tuesday, March 06, 2007 7:38 PM
Subject: issue with restrictions


>
> Hello,
>
> I'm new to this list. I'm having a XSD development issue that relates to 
> restrictions and I hope this is the right place to ask.
>
> My context is one where developers can create new messages but they must 
> follow some pre-defined patterns. For instance, I want all my search 
> request messages to contain 0 or more search criterias that they can pick 
> from a list of concrete predefined criterias.
>
> What I am trying to do is use XSD to enforce these patterns. A sample XSD 
> is below. When I validate the XSD, I get the error that 
> SearchRequestByDate is not a valid restriction of SearchRequest.
>
> Thank you,
>
> Guillaume
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>    <xs:complexType name="SearchRequest" abstract="true">
>        <xs:sequence>
>            <xs:element ref="SelectionCriteria" minOccurs="0" 
> maxOccurs="unbounded"/>
>        </xs:sequence>
>    </xs:complexType>
>
>    <xs:element name="SelectionCriteria" abstract="true"/>
>   <xs:element name="StartDate" type="xs:string" 
> substitutionGroup="SelectionCriteria"/>
>    <xs:element name="EndDate" type="xs:string" 
> substitutionGroup="SelectionCriteria"/>
>   <xs:complexType name="SearchRequestByDate">
>        <xs:complexContent>
>            <xs:restriction base="SearchRequest">
>                <xs:sequence>
>                <xs:element ref="StartDate"/>
>                <xs:element ref="EndDate" minOccurs="0"/>
>                </xs:sequence>
>            </xs:restriction>
>        </xs:complexContent>
>    </xs:complexType>
>   </xs:schema>
>
>
>
> 



From dmaze@u... Wed Mar 07 15:39:24 2007
Received: from lisa.w3.org ([128.30.52.41])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1HOyEd-0002MN-Rl
	for xmlsche


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent