I get the upcoming error while validating the XML against the schema.
Value 'this/is/a/simple/node-path' is not facet-valid
with respect to pattern '^(\w+[\w\-/])+\w' for type 'PathModel'.
The definition of type PathModel is defined as a simpleType as the following snippet shows. It is used by <path>this/is/a/simple/node-path</path>
<xs:simpleType name="PathModel">
<xs:restriction base="xs:string">
<xs:pattern value="^(\w+[\w\-/])+\w" />
</xs:restriction>
</xs:simpleType>
The expected result is listed in this matching table.
this/is/a/simple/node-path MATCHING
/this/is/a/simple/node-path NOT MATCHING
this/is/a/simple/node-path/ NOT MATCHING
this/is/a/simple/nodep%th NOT MATCHING (special characters)
What is going wrong? Thank you
Remove the leading
^character.This is the only valid value from the set you provided:
This should do the trick for you (tested in my Eclipse IDE).
The reason is visible, for example, here: http://www.regular-expressions.info/xml.html
“Compared with other regular expression flavors, the XML schema flavor is quite limited in features. Since it’s only used to validate whether an entire element matches a pattern or not, rather than for extracting matches from large blocks of data. XML schema always implicitly anchors the entire regular expression. The regex must match the whole element for the element to be considered valid. If you have the pattern
regexp, the XML schema validator will apply it in the same way as say Perl, Java or .NET would do with the pattern^regexp$.”