Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Re-using a simple type definition; with enumeration constraint and without enumeration constraint

From: puvit82 <puvising@-----.--->
To: NULL
Date: 2/1/2008 7:32:00 AM
On Feb 1, 4:36=A0am, use...@tech-know-ware.com wrote:
> On 30 Jan, 22:35, puvit82 <puvis...@gmail.com> wrote:
>
>
>
>
>
> > My problem is as follows, any advice / suggestion would be greatly
> > appreciated:
>
> > Lets suppose that I have defined a simpleType "addressType" with 3
> > enumeration values (Home, Office, Vacation) that restrict data entry.
> > I want to use this simpleType in 2 different unrelated complexType
> > definitions, lets call them "personalAddress" and "companyAddress"
>
> > How will I be able to use "addressType" inside "personalAddress" such
> > that the 3 enumeration values are taken into consideration, i.e. data
> > entry is restricted to either one of those three enumeration values
> > and also use the same "addressType" inside "companyAddress" such that
> > the enumeration values are not considered and the user can enter a
> > completely different value for addressType (such as "HomeOffice" and
> > the schema validates the XML file)?
>
> > I do not want to create another addressType (one with enumerations and
> > one without - and different names)
>
> > Does anybody think that there is a way to re use the same simple type
> > twice; once with the enumeration values and another time without the
> > enumeration values?
>
> One thing you might be able to do is define your addressType to be a
> list of types, e.g. in an XML instance it might look like:
>
> =A0 =A0 addressType=3D"Home Office"
>
> The XML schema for that would look something like:
>
> =A0 =A0 <xs:simpleType name=3D"addressType">
> =A0 =A0 =A0 =A0 <xs:list>
> =A0 =A0 =A0 =A0 =A0 =A0 <xs:simpleType>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <xs:restriction base=3D"xs:string">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <xs:enumeration value=3D"Home"/>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <xs:enumeration value=3D"Office"/>=

> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <xs:enumeration value=3D"Vacation"=
/>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 </xs:restriction>
> =A0 =A0 =A0 =A0 =A0 =A0 </xs:simpleType>
> =A0 =A0 =A0 =A0 </xs:list>
> =A0 =A0 </xs:simpleType>
>
> or you could make the xs:enumeration 'open' by including an xs:union
> of the enumeration and xs:string. =A0However, this does weaken the
> amount of validation that can be automatically done.
>
> HTH,
>
> Pete Cordell
> Codalogic
> Visithttp://www.codalogic.com/lmx/for XML C++ data binding- Hide quoted te=
xt -
>
> - Show quoted text -

Thanks for the input Pete.

I tried what you suggested and put the enumerations into a list and
heres what a valid xml instance looks like:

<BusinessAddress xsi:noNamespaceSchemaLocation=3D"Untitled2.xml"
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance">
<AddressType>Home Office</AddressType>
<StringOne>any string</StringOne>
</BusinessAddress>

I actually wanted to be able to allow something that is outside the
set of enumeration values of addressType.

Nevermind, I guess this is a failed battle!! .. I'll just have to
create duplicate types so that one can validate the data and the other
one can allow whatever data.

Thanks!

Puvit


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