How do I defined unique constraint in xsd ? How can I achive error validation using xml-libxml?

StackOverflow https://stackoverflow.com/questions/13800461

  •  06-12-2021
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

  • 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.

다른 팁

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

minOccurs="0" maxOccurs="1"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top