I’m using python’s lxml to validate xmls against a schema. I have a schema with an element:
<xs:element name="link-url" type="xs:anyURL"/>
and I test, for example, this (part of an) xml:
<a link-url="server/path"/>
I would like this test to FAIL because the link-url doesn’t start with http://. I tried switching anyURI to anyURL but this results in an exception – it’s not a valid tag.
Is this possible with lxml? is it possible at all with schema validation?
(I’m pretty sure
xs:anyURLis not valid. The XML Schema standard calls itanyURI. And sincelink-urlis an attribute, shouldn’t you be usingxs:attributeinstead ofxs:element?)You could restrict the URIs by creating a new
simpleTypebased on it, and put arestrictionon thepattern. For example,