OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Schema views - are they possible?

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: XML Schema views - are they possible?
  • From: "Cheng, Andy" <Andy.Cheng@ato.gov.au>
  • Date: Fri, 27 Aug 2004 18:04:08 +1000
  • Thread-index: AcSMDG4dpsG9NDhaT0669PkZjwLu9w==
  • Thread-topic: XML Schema views - are they possible?

Title: XML Schema views - are they possible?

Dear XML Dev List,

Hello, my name is Andy and I'm a newbie to this forum. I am currently getting into the XML schema development and am having a problem (hope you guys can help me out). I'm wondering is there a possibility of having different XML Schema views (for reusability purposes). Here is an example of code:

<xs:complexType name="StatusType">
                <xs:all>
                        <xs:element name="StatusCode" minOccurs="0">
                                <xs:complexType>
                                        <xs:simpleContent>
                                                <xs:restriction base="tns:stringItemType">
                                                        <xs:minLength value="1"/>
                                                        <xs:maxLength value="10"/>
                                                </xs:restriction>
                                        </xs:simpleContent>
                                </xs:complexType>
                        </xs:element>
                        <xs:element name="StatusMessage" minOccurs="0">
                                <xs:complexType>
                                        <xs:simpleContent>
                                                <xs:restriction base="tns:stringItemType">
                                                        <xs:minLength value="1"/>
                                                        <xs:maxLength value="50"/>
                                                </xs:restriction>
                                        </xs:simpleContent>
                                </xs:complexType>
                        </xs:element>
                </xs:all>
</xs:complexType>

These two elements are optional. However, I want to reuse the complexType and change the 'StatusCode' element to mandatory ie change the value of 'minOccurs' to 1. What I have found so far is that I could use a 'restriction' element to change the value, hence the code:

<xs:element name="Status">
                                        <xs:complexType>
                                                <xs:complexContent>
                                                        <xs:restriction base="tns:StatusType">
                                                                <xs:all>
                                                                        <xs:element name="StatusCode">
                                                                                <xs:complexType>
                                                                                        <xs:simpleContent>
                                                                                                <xs:restriction base="tns:stringItemType">

                                                                                                        <xs:minLength value="1"/>

                                                                                                        <xs:maxLength value="10"/>

                                                                                                </xs:restriction>
                                                                                        </xs:simpleContent>
                                                                                </xs:complexType>
                                                                        </xs:element>
                                                                        <xs:element name="StatusMessage" minOccurs="0">
                                                                                <xs:complexType>
                                                                                        <xs:simpleContent>
                                                                                                <xs:restriction base="tns:stringItemType">

                                                                                                        <xs:minLength value="1"/>

                                                                                                        <xs:maxLength value="50"/>

                                                                                                </xs:restriction>
                                                                                        </xs:simpleContent>
                                                                                </xs:complexType>
                                                                        </xs:element>
                                                                </xs:all>
                                                        </xs:restriction>
                                                </xs:complexContent>
                                        </xs:complexType>
</xs:element>

What I would like to achieve is:
1. if I wanted to change the restriction values in the complexType, the change would ripple through to all elements using this complexType. However, this is not the case. When placing a 'restriction' element, in XMLSpy it duplicates all the elements from the complexType

2. If I didn’t want this element to be passed at all ie make maxOccurs ='0' (PS is this bad coding?), I don’t want the XML Schema to validate the element. After a few examples by putting the element in, the XML schema still does validate the element, although its not wanted.

Does anyone know how to get around this?? Or perhaps is there an alternative solution?

Thanks a lot!

Regards,

    Andy Cheng
Australian Taxation Office
INFORMATION COMMUNICATIONS & TECHNOLOGY
Software Development Quality & Productivity

andy.cheng@ato.gov.au  



****************************************************************
IMPORTANT

The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. Any review, re-transmission, disclosure dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may result in severe penalties. If you have received this e-mail in error please notify the Privacy Hotline of the Australian Taxation Office, telephone 13 28 69 and delete all copies of this transmission together with any attachments.
****************************************************************




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS