'Can I use RegExps in DTD schemas?
I want to enforce that an XML element has to contain an ISBN code. Therefore, I need your typical pattern "[0-9]{3}-[0-9]{3}......".
Could that be achieved on a DTD schema? I've read you can't combine DTD with RegExps but I'm not so sure.
Solution 1:[1]
No, you can't define regex patterns with DTD.
You can enforce regex patterns with XSD schemas.
<xsd:simpleType name="SSN">
<xsd:restriction base="xsd:token">
<xsd:pattern value="[0-9]{3}-[0-9]{2}-[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleType>
Another option is applying some sort of other validation, such as Schematron.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mads Hansen |
