Subject: | length work not correctly for xsd:list |
In the documentation it is told that it is "lenght" for the list should to define a stake-in of elements in the list, instead of lenght each element as it works in XML:: Compile
---------------------------------------------------------------------------------------------------------------------------------
List Types
Whereas enumerated types force an XML developer to use a value from a predefined set of values, list types allow an XML developer to provide multiple values for a given element. The xsd:list element is used to create list types, which are useful any time you need to allow for a list of information. As an example, you might want to create an element that stores rainfall totals for each month of the year as part of an XML-based weather application. Following is code that carries out this function:
<xsd:element name="rainfall"> <xsd:simpleType> <xsd:list base="xsd:decimal"> <xsd:length value="12"/> </xsd:list> </xsd:simpleType> </xsd:element>
This code allows you to list exactly 12 decimal numbers, separated by white space. Following is an example of what the XML code might look like for the rainfall element:
<rainfall>1.25 2.0 3.0 4.25 3.75 1.5 0.25 0.75 1.25 1.75 2.0 2.25</rainfall>
If you wanted to be a little more flexible and not require exactly 12 items in the list, you could use the xsd:minLength and xsd:maxLength elements to set minimum and maximum bounds on the list. You can also create a completely unbounded list by using the xsd:list element by itself, like this:
<xsd:element name="cities"> <xsd:simpleType> <xsd:list base="xsd:string"/> </xsd:simpleType> </xsd:element> --------------------------------------------------------------------------------------------------------------------------------------
I offer here such patch: BuiltInFacets.pm 179c179 < sub { return $_[0] if defined $_[0] && length($_[0])==$len; --- > sub { return $_[0] if defined $_[0] && ((ref $_[0] eq 'ARRAY' && scalar @{$_[0]}) || length($_[0])==$len); Reader.pm 800,803c800,802 < EL: for my $e (ref $v eq 'ARRAY' ? @$v : $v) < { for(@$late) { defined $e or next EL; $e = $_->($e) } < push @r, $e; < } --- > my $e = $v; > for(@$late) { defined $e or last; $e = $_->($e) } > push @r, $e;