Validate that URI is not empty in RelaxNG

148 Views Asked by At

I'm trying to validate that an element always has an href attribute in RelaxNG, and assumed you could do it with this:

<attribute name="href">
  <data type="anyURI"/>
</attribute>

Only catch is, apparently anyURI considers empty strings to be valid, so href="" passes with flying colors. Is there any easy way to fix this?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the minLength facet. For example:

<attribute name="href">
  <data type="anyURI">
    <param name="minLength">5</param>
  </data>
</attribute>

See also http://www.w3.org/TR/xmlschema-2/#anyURI