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 3rd, 2005, 07:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Modeling with restrictions on attribute value

Cannot figure out how to model the folowing XML node with some further restrictions and requirements (described underneath). The node to model as XML Schema Definition...
Code:
<connections>
    <connection type="build" port="11000" />
    <connection type="admin" port="11011" />
</connections>
I want the above structure and want to model that the connection node with type build is required but the connection node with type admin is optional. Furthermore that it is only these two instances of connection which is allowed.

I have tried to model some of it in the following XML Schema Definition...
Code:
<xsd:element name="connections">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="connection" maxOccurs="2">
                <xsd:complexType>
                    <xsd:attribute name="type" type="connectionType" />
                    <xsd:attribute name="port" type="xsd:integer" />
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>    
<xsd:simpleType name="connectionType">        
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="build"/>
        <xsd:enumeration value="admin"/>
    </xsd:restriction>
</xsd:simpleType>
However it does not specify that the connection node with type build has to appear. One node has to appear since minOccurs is 1 by default, but it might as well be the admin type.

I might add that I am not interested in renaming the connection nodes if another solution to the above is available. Should be simple to model the problem using e.g. connectionBuild and connectionAdmin.

Hope someone will help me, thanks,

Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).





Similar Threads
Thread Thread Starter Forum Replies Last Post
Many-to-many dimensional modeling boson SQL Server 2000 6 September 22nd, 2006 12:34 PM
restrictions on attributes kfir XML 2 May 30th, 2006 04:35 AM
restrictions kgoldvas XML 8 April 27th, 2006 03:27 AM
Purpose of this forum and restrictions jminatel ASP.NET 2.0 Basics 2 January 27th, 2005 10:43 AM





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