2

With reference to topic, Perl, LibXML and Schemas

If I want to make the isbn tag to be an unique constraint, then what will be the change required in XSD. In addition to this, if I want to add validations for unique constraint using XML::LibXml, can I achieve the validations check using the same code? Can someone please explain with sample example with error in xml doc for unique constraint?

Community
  • 1
  • 1
Vipul
  • 23
  • 1
  • 1
  • 4

2 Answers2

1
  • In regards of XSD schema enforcing key uniqueness: use the xs:unique element. More info in Enforcing Association Cardinality article, and take a look at the provided example XSD;
  • XML schema validation in Perl can be achieved using XML::Compile module, which wraps itself around XML::LibXML.
creaktive
  • 5,193
  • 2
  • 18
  • 32
0

xsd allows the amount of an item could appear, add this to your isbn element xsd declaration

minOccurs="0" maxOccurs="1"
jacktrade
  • 3,125
  • 2
  • 36
  • 50