Subject: | <group> tag is not supported |
Date: | Thu, 4 Oct 2007 16:46:09 +0530 |
To: | <bug-XML-Validator-Schema [...] rt.cpan.org> |
From: | "Abhijeet A Rahatekar" <Abhijeet.Rahatekar [...] kpitcummins.com> |
bug-XML-Validator-Schema@cpan.org; bug-XML-Validator-Schema@rt.cpan.org
Hi,
The initial details are given below,
1. Distribution name and version: XML::Validator::Schema-1.07
2. Perl Version: 5.8.8
3. Operating System: Windows XP
Problem Description:
While working with XML validation against schema using Perl
Validator.
I found a problem with "group" element. Whenever I try to use group
element provided in
XML schema, the perl validator program is throwing an error given below,
Unrecognized element '<group>' found. This error is mentioned in
XML::Validator::Schema::Parser.pm.
According to me the <group> tag is not supported
XML::Validator::Schema::Parser.pm.
Error or Warning Message:
Unrecognized element '<group>' found
The file details:
The perl validator program file is:
Code: ( perl )
1. #!/usr/bin/perl
2. use XML::SAX::ParserFactory;
3. use XML::Validator::Schema;
4.
5. #
6. # create a new validator object, using foo.xsd
7. #
8. $validator = XML::Validator::Schema->new(file =>
'/xml2c/test1/test_1.xsd');
9.
10. #
11. # create a SAX parser and assign the validator as a Handler
12. #
13. $parser = XML::SAX::ParserFactory->parser(Handler => $validator);
14.
15. #
16. # validate foo.xml against foo.xsd
17. #
18. eval { $parser->parse_uri('/xml2c/test1/test_schema_1.xml') };
19. if ($@) {
20. die "File failed validation: $@";
21. } else {
22. print "Validation completed without error";
.xsd file
Code: ( text )
1. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2. <xsd:element name="PurchaseOrderType">
3. <xsd:complexType>
4. <xsd:sequence>
5. <xsd:choice>
6. <xsd:group ref="shipAndBill"/>
7. <xsd:element name="singleUSAddress"
type="USAddress"/>
8. </xsd:choice>
9. <xsd:element ref="comment" minOccurs="0"/>
10. <xsd:element name="items" type="Items"/>
11. </xsd:sequence>
12. <xsd:attribute name="orderDate" type="xsd:date"/>
13. </xsd:complexType>
14. </xsd:element>
15. <xsd:complexType name="USAddress">
16. <xsd:sequence>
17. <xsd:element name="name" type="xsd:string"/>
18. <xsd:element name="street" type="xsd:string"/>
19. <xsd:element name="city" type="xsd:string"/>
20. <xsd:element name="state" type="xsd:string"/>
21. <xsd:element name="zip" type="xsd:decimal"/>
22. </xsd:sequence>
23. <xsd:complexType name="Items">
24. <xsd:sequence>
25. <xsd:element name="item" minOccurs="0"
maxOccurs="unbounded">
26. <xsd:complexType>
27. <xsd:sequence>
28. <xsd:element name="productName"
type="xsd:string"/>
29. <xsd:element name="quantity">
30. <xsd:simpleType>
31. <xsd:restriction
base="xsd:positiveInteger">
32. <xsd:maxExclusive value="100"/>
33. </xsd:restriction>
34. </xsd:simpleType>
35. </xsd:element>
36. <xsd:element name="USPrice" type="xsd:decimal"/>
37. <xsd:element ref="comment" minOccurs="0"/>
38. <xsd:element name="shipDate" type="xsd:date"
minOccurs="0"/>
39. </xsd:sequence>
40. <xsd:attribute name="partNum" type="SKU"
use="required"/>
41. </xsd:complexType>
42. </xsd:element>
43. </xsd:sequence>
44. </xsd:complexType>
45. <xsd:group id="shipAndBill">
46. <xsd:sequence>
47. <xsd:element name="shipTo" type="USAddress"/>
48. <xsd:element name="billTo" type="USAddress"/>
49. </xsd:sequence>
50. </xsd:group>
51. </xsd:schema>
.xml file
Code: ( text )
1. <?xml version="1.0"?>
2. <purchaseOrder orderDate="1999-10-20">
3. <shipTo country="US">
4. <name>Alice Smith</name>
5. <street>123 Maple Street</street>
6. <city>Mill Valley</city>
7. <state>CA</state>
8. <zip>90952</zip>
9. </shipTo>
10. <billTo country="US">
11. <name>Robert Smith</name>
12. <street>8 Oak Avenue</street>
13. <city>Old Town</city>
14. <state>PA</state>
15. <zip>95819</zip>
16. </billTo>
17. <comment>Hurry, my lawn is going wild<!/comment>
18. <items>
19. <item partNum="872-AA">
20. <productName>Lawnmower</productName>
21. <quantity>1</quantity>
22. <USPrice>148.95</USPrice>
23. <comment>Confirm this is electric</comment>
24. </item>
25. <item partNum="926-AA">
26. <productName>Baby Monitor</productName>
27. <quantity>1</quantity>
28. <USPrice>39.98</USPrice>
29. <shipDate>1999-05-21</shipDate>
30. </item>
31. </items>
32. </purchaseOrder>
Thank you,
Regards,
Abhijeet A Rahatekar
Message body is not shown because it is too large.