DOMDocument::schemaValidate(): Problems with Regex patterns
Posted: Sun Oct 04, 2009 2:11 am
I am having problems with function DOMDocument::schemaValidate() because it is not properly evaluating Regex patterns, even though they are correct.
I have validated my XML/XSD through Eclipse tools and this site with no problems:
http://tools.decisionsoft.com/schemaVal ... esults.jsp
Taking a simple example of a Regex pattern: "\/[a-zA-Z0-9_\-\+]+", schemaValidate() is failing on the initial forward-slash reference: "\/".
This Regex is inserted into this simpleType element of an XML Schema:
When I run this through DOMDocument::schemaValidate(), it fails and libxml_get_errors() returns:
What I am doing wrong or is there a better PHP class in validating XML/XSD?
Thanks
Jeff in Seattle
I have validated my XML/XSD through Eclipse tools and this site with no problems:
http://tools.decisionsoft.com/schemaVal ... esults.jsp
Taking a simple example of a Regex pattern: "\/[a-zA-Z0-9_\-\+]+", schemaValidate() is failing on the initial forward-slash reference: "\/".
This Regex is inserted into this simpleType element of an XML Schema:
Code: Select all
<xs:simpleType name="patternUrlPath">
<xs:restriction base="xs:string">
<xs:pattern
[color=#0000FF][b]value="\/[a-zA-Z0-9_\-\+]+"[/b][/color] >
</xs:pattern>
</xs:restriction>
</xs:simpleType>If I modify the Regex to be "\\/[a-zA-Z0-9_\-\+]+", whereby I add an additional back-slash before the initial forward-slash reference like so: "\\/", then schemaValidate() passes but this is not the Regex pattern I want.Error 1756: Element '{http://www.w3.org/2001/XMLSchema}pattern': The value '\/[a-zA-Z0-9_\-\+]+' of the facet 'pattern' is not a valid regular expression.
What I am doing wrong or is there a better PHP class in validating XML/XSD?
Thanks
Jeff in Seattle