Hi, all, <br><br>I've just use XML::Compile::Schema in my code and found it can not validate xs:ID restriction. <br><br>I have following definition in my XSD:<br><br><span style="font-family: courier new,monospace;"> <xs:element name="name"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <xs:simpleType></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <xs:restriction base="xs:ID"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <xs:pattern value="[a-zA-Z_][a-zA-Z_0-9]*"/></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </xs:restriction></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </xs:simpleType></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </xs:element><br><br><span style="font-family: arial,sans-serif;">'name' element can occur multiple times in instance XML files. I want every name to be unique, so "xs:ID" restriction is used.<br>
But when I </span></span>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. Does XML::Compile::Schema implement xs:ID validation? If not, is there any existing work-around? <br>
<br>Following is the perl code I used in testing:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># get schema from file</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">my $schema = XML::Compile::Schema->new('my.shcema.xsd');</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># create and use a reader</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">use XML::Compile::Util qw/pack_type/;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">my $elem = pack_type '', 'my.root.element'; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">my $read = $schema->compile(READER => $elem);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">my $data = $read->("inst.xml");</span><br>
<br><br>Thanks!<br><br>Iamsolo<br><br>