|
Re: enumeration-facet of union types [message #55015 is a reply to message #54988] |
Tue, 23 November 2004 13:15 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Klass,
When the model sees value="11" it must determine the "actual value" of
the literal using the base type of the restriction, and that union will
accept 11 as a value of type string, so that's the one and only value in
the enumeration. There isn't even the slightest hint in the enumeration
description in the spec to indicate that the single literal value must
be converted to more than one valid value if the base type is a union.
And even the comment about the use of xsi:type does not have any direct
bearing on how enumeration is interpreted, because it talks only about a
union. In fact, it seems very reasonable to argue that only the String
11 should be in the enumeration and that BigDecimal 11 should not, and
hence that the instance should not validate. I can see how other
interpretations would be reasonable, but there really needs to be some
explicit wording in the spec to support such alternative interpretations...
(I'm curious if the instance would validate if the xsi:type were int.)
Klaas Dellschaft wrote:
>Hi,
>
>I have a question about enumeration facets of union types. I have the
>following schema:
>
><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xs:element name="test" type="st.unionType"/>
>
>
> <xs:simpleType name="st.unionType">
> <xs:restriction>
> <xs:simpleType>
> <xs:union memberTypes="xs:string xs:integer"/>
> </xs:simpleType>
> <xs:enumeration value="11"/>
> </xs:restriction>
> </xs:simpleType>
>
></xs:schema>
>
>
>I had a look into the implementation of the type system in XSD. I've seen
>that xs:string is represented by the Java String-type and xs:integer is
>represented by BigDecimal.
>
>So the value space of the anonymous sub union-type would contain String and
>BigDecimal values. If I restrict this type with the enumeration facet I'm
>not sure whether the value space of "st.unionType" would contain
>String("11") and BigDecimal("11") or only String("11").
>
>In the datatypes part of the W3C it is said that a lexical value is
>validated against the memberTypes until a match is found but the evaluation
>order can be overridden with the use of xsi:type.
>
>So from my point of view it should be possible to validate the following
>file against the schema from above:
>
><test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xsi:noNamespaceSchemaLocation="test.xsd" xsi:type="xs:integer">
> 11
></test>
>
>And Xerces-C also successfully validates this file. So I think the value
>space of "st.unionType" should contain BigDecimal("11") and String("11).
>
>But at the moment if I call the function XSDEnumerationFacet.getValue() on
>the enumeration facet of "st.unionType" I only get one Object, the
>String("11") and not also BigDecimal("11"). I would interpret this result
>that XSD only puts String("11") into the value space of "st.unionType" and
>not also BigDecimal("11"). Is this correct (my interpretation and/or the
>behaviour of XSD)?
>
>Regards
>Klaas Dellschaft
>
>
>
>
>
|
|
|
|
|
Re: enumeration-facet of union types [message #592591 is a reply to message #54988] |
Tue, 23 November 2004 13:15 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Klass,
When the model sees value="11" it must determine the "actual value" of
the literal using the base type of the restriction, and that union will
accept 11 as a value of type string, so that's the one and only value in
the enumeration. There isn't even the slightest hint in the enumeration
description in the spec to indicate that the single literal value must
be converted to more than one valid value if the base type is a union.
And even the comment about the use of xsi:type does not have any direct
bearing on how enumeration is interpreted, because it talks only about a
union. In fact, it seems very reasonable to argue that only the String
11 should be in the enumeration and that BigDecimal 11 should not, and
hence that the instance should not validate. I can see how other
interpretations would be reasonable, but there really needs to be some
explicit wording in the spec to support such alternative interpretations...
(I'm curious if the instance would validate if the xsi:type were int.)
Klaas Dellschaft wrote:
>Hi,
>
>I have a question about enumeration facets of union types. I have the
>following schema:
>
><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xs:element name="test" type="st.unionType"/>
>
>
> <xs:simpleType name="st.unionType">
> <xs:restriction>
> <xs:simpleType>
> <xs:union memberTypes="xs:string xs:integer"/>
> </xs:simpleType>
> <xs:enumeration value="11"/>
> </xs:restriction>
> </xs:simpleType>
>
></xs:schema>
>
>
>I had a look into the implementation of the type system in XSD. I've seen
>that xs:string is represented by the Java String-type and xs:integer is
>represented by BigDecimal.
>
>So the value space of the anonymous sub union-type would contain String and
>BigDecimal values. If I restrict this type with the enumeration facet I'm
>not sure whether the value space of "st.unionType" would contain
>String("11") and BigDecimal("11") or only String("11").
>
>In the datatypes part of the W3C it is said that a lexical value is
>validated against the memberTypes until a match is found but the evaluation
>order can be overridden with the use of xsi:type.
>
>So from my point of view it should be possible to validate the following
>file against the schema from above:
>
><test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xsi:noNamespaceSchemaLocation="test.xsd" xsi:type="xs:integer">
> 11
></test>
>
>And Xerces-C also successfully validates this file. So I think the value
>space of "st.unionType" should contain BigDecimal("11") and String("11).
>
>But at the moment if I call the function XSDEnumerationFacet.getValue() on
>the enumeration facet of "st.unionType" I only get one Object, the
>String("11") and not also BigDecimal("11"). I would interpret this result
>that XSD only puts String("11") into the value space of "st.unionType" and
>not also BigDecimal("11"). Is this correct (my interpretation and/or the
>behaviour of XSD)?
>
>Regards
>Klaas Dellschaft
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04231 seconds