Jump to content

scotcarl

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by scotcarl

  1. Perhaps the problem is created by the use of elements as opposed to attributes?
    Not that I don't agree, bcos under most circumstances I would also consider that min and max would be well suited to being an attribute, however in this situation it serves my purposes better to have it set up the way I have in the example. Also, fixing the problem with the min/max ellements does not solve the same problem that exists with the ordering of the Height/Width elements.The example that I gave in the origional post is actually a smaller snippet of a larger element definition, which is basically an extension of the same thing. I only included the small section of code bcos I didn't want to clutter the post.Thanks for your reply.Scott.
  2. Hello to everyone in XML schema land.I am only new to the world of XML and schemas, so forgive me if I am asking a stupid question.I seem to have run into a limitation when creating a schema, and I do not see any logical reason for the limitation, so I'm hoping there is a way around it.The problem I have is as follows.I have written the following section of schema code.

    <xsd:element name="Size">	<xsd:complexType>		<xsd:sequence>			<xsd:choice>				<xsd:sequence>					<xsd:element name="minHeight" minOccurs="0" type="xsd:int"/>					<xsd:element name="maxHeight" minOccurs="0" type="xsd:int"/>				</xsd:sequence>				<xsd:element name="Height" type="xsd:int"/>			</xsd:choice>			<xsd:choice>				<xsd:sequence>					<xsd:element name="minWidth" minOccurs="0" type="xsd:int"/>					<xsd:element name="maxWidth" minOccurs="0" type="xsd:int"/>				</xsd:sequence>				<xsd:element name="Width" type="xsd:int"/>			</xsd:choice>		</xsd:sequence>	</xsd:complexType></xsd:element>

    As you can see, I have set it up so that I have the option in my associated XML file to specify either min and/or max height, or a specific height value. The same goes for width.This is pretty much what I want, except for a basic limitation in that the <sequence> indicator forces the included elements to be specified in the order they are listed in the schema.In my associated XML file, I do not care if I specify Min before Max, nor do I care if I specify Height before Width. Even the software I have written to parse the xml files does not care about the order the entries are specified. The only thing that seems to care is the w3 schema rules.The obvious solution to this is to use the <all> indicator, but I cannot use this in conjunction with a <choice> or <sequence> indicator.The other idea I had was to change the code so something like

    <xsd:element name="Size">	<xsd:complexType>		<xsd:choice minOccurs="2" maxOccurs="2">			<xsd:choice>				<xsd:choice minOccurs="1" maxOccurs="2">					<xsd:element name="minHeight" minOccurs="0" type="xsd:int"/>					<xsd:element name="maxHeight" minOccurs="0" type="xsd:int"/>				</xsd:choice>				<xsd:element name="Height" type="xsd:int"/>			</xsd:choice>			.			.			.

    This has the problem, however, that I there is now nothing stopping me from specifying the <minHeight> element twice (or the <maxHeight> element twice), in my XML file, which I do not want.If anyone has any ideas one how to set up the schema to emulate the functionallity of the <all> indicator, it would be greatly appreciated.Thanks,Scott.

×
×
  • Create New...