[Xml-compile] XML::Compile::Schema validation on xs:ID has problem

Mark Overmeer mark at overmeer.net
Thu May 15 06:47:49 BST 2008


* MENG Xin (zinces at gmail.com) [080515 04:02]:
>                    <xs:pattern value="[a-zA-Z_][a-zA-Z_0-9]*"/>
> 'name' element can occur multiple times in instance XML files. I want every
> name to be unique, so "xs:ID" restriction is used.

> But when I use same names in one XML file, XML::Compile::Schema can read XML
> file smoothly and produce resulting HASH without error. But if I use name
> violating pattern rule,  error is reported.

Which error?

> Does XML::Compile::Schema implement xs:ID validation?

What is "xs:ID validation"?  Is that a special kind of validation?
Patterns are translated into reg-exes, because the XML::LibXML module
does not export the related libxml2 functions (yet).  So there could
be something wrong.
  But please send me some code which does shows the problem (off-
mailinglist might be better)

 If not, is there any existing work-around?
>    Following is the perl code I used in testing:
>    # get schema from file
>    my $schema = XML::Compile::Schema->new('my.shcema.xsd');
>    # create and use a reader
>    use XML::Compile::Util qw/pack_type/;
>    my $elem   = pack_type '', 'my.root.element';
>    my $read   = $schema->compile(READER => $elem);
>    my $data   = $read->("inst.xml");

This looks ok. But reading did work, as you reported.  Writing didn't.
-- 
Regards,
               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list