Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Algorithm for computing the cardinality of a simpleType?

From: Xan Gregg <xan.gregg@---.--->
To: "Roger L. Costello" <costello@-----.--->
Date: 7/21/2005 9:34:00 AM
> Note that I am assuming that the enumeration facet takes precedence 
> over all
> other facets.  I believe that this is true, isn't it?

I don't think it is. Just because a value satisfies one facet doesn't 
give a free ride past the others.

I like your organization into three parts (pattern, enumerations, and 
range), but unfortunately you need the *intersection* of each part's 
value space. Consider this variation of your exanmple:

> <simpleType name="foo">
>     <restriction base="byte">
>         <pattern value=".*[13579]"/>  <!-- odd numbers -->
>         <minInclusive value="0"/>
>         <maxInclusive value="35"/>
>         <enumeration value="11"/>
>         <enumeration value="22"/>
>         <enumeration value="33"/>
>         <enumeration value="44"/>
>         <enumeration value="55"/>
>     </restriction>
> </simpleType>

The value space is {11, 33} with cardinality 2.

Algorithm becomes:

1. Compute range [lo..hi], as before.

2. If enumeration present,
        cardinality is number of enumeration values that are in [lo..hi] 
and satisfy any pattern values;
        done.

3. If pattern present,
        cardinality is number of values in [lo..hi] that satisfy pattern 
values;
        done.

3. Otherwise, cardinality is hi - lo + 1.

xan


On Jul 21, 2005, at 12:06 PM, Roger L. Costello wrote:
> Hi Xan,
>
> I like your algorithm!  I wonder if checking for enumerations 
> shouldn't be
> done first, and then patterns, and then the 7 steps you described?
>
> Algorithm for Computing the Cardinality of a byte simpleType (with 
> Xan's
> suggestions)
>
> 1. If there are enumeration facets then
>       cardinality = count the number of enumeration facets
>    Done.
>
> 2. If there are pattern facets then
>       cardinality = the maximum cardinality of all the pattern facets.
>    Done.
>
> 3. Otherwise:
>       3.1. lo = -128, hi = 127
>       3.2. minInclusive present => lo = max(lo, minInclusive)
>       3.3. maxInclusive present => hi = min(hi, maxInclusive)
>       3.4. minExclusive present => lo = max(lo, minExclusive + 1)
>       3.5. maxExclusive present => hi = min(hi, maxExclusive - 1)
>       3.6. totalDigits present => lo = max(lo, -10^^totalDigits + 1);
>                                   hi = min(hi, 10^^totalDigits - 1)
>       3.7. cardinality = hi - lo + 1
>
> Note that I am assuming that the enumeration facet takes precedence 
> over all
> other facets.  I believe that this is true, isn't it?
>
> Does this algorithm seem correct?   /Roger


From gabriel.klappenbach@b... Wed Jul 27 09:41:08 2005
Received: from wiggum.w3.org ([128.30.52.23])


transparent
Print
Mail
Digg
delicious
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