This is the definition for my type in the XSD file (using xs:anyURI doesn't work):
<xs:simpleType name="lastNavigType">
<xs:restriction base="xs:string">
<xs:pattern value="qrc\:\/help\/SBBL_[\d]+_[\w]+\.html"/>
</xs:restriction>
</xs:simpleType>
And this is the attribute which should validate:
<xs:attribute type="lastNavigType" name="last-navigated" use="required"/>
The XML file has this:
<helpviewer last-zoom="12" last-navigated="qrc:/help/SBBL_67_Graph_Terminology.html" bookmarks="" maximized="true">
I am trying to use the online XSD validation service at https://www.softwarebytes.org/xmlvalidation/
which uses Xerces-J as backend, but it says:
[Error] sbbl_app_settings.xml:20:118:cvc-pattern-valid: Value 'qrc:/help/SBBL_67_Graph_Terminology.html' is not facet-valid with respect to pattern 'qrc\:\/help\/SBBL_[\d]+_[\w]+\.html' for type 'lastNavigType'.
[Error] sbbl_app_settings.xml:20:118:cvc-attribute.3: The value 'qrc:/help/SBBL_67_Graph_Terminology.html' of attribute 'last-navigated' on element 'helpviewer' is not valid with respect to its type, 'lastNavigType'.
On the regex101.com
page it passes validation. What is wrong? Thanks.
Please try the following solution.
XSD's regular expressions are different from a generic regex.
Colon ":" and forward slash "/" characters don't require escaping.
XML
<?xml version="1.0"?>
<helpviewer last-navigated="qrc:/help/SBBL_67_Graph_Terminology.html"/>
XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="helpviewer">
<xs:complexType>
<xs:attribute name="last-navigated" use="required" type="lastNavigType"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="lastNavigType">
<xs:restriction base="xs:string">
<xs:pattern value="qrc:/help/SBBL_\d+_\w+_\w+\.html"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>