Skip to content

XSD anyURI

How to use the anyURI data type in XSD to define valid URI references in XML attributes and elements, including handling spaces and applying restrictions like length, pattern, and enumeration.

anyURI data type is used to specify a URI.

AnyURI Data Type

The anyURI data type is used to specify a URI.

Let's see an example:

<xs:attribute name="src" type="xs:anyURI"/>

and an element in your XML document look like this:

<img src="www.example.com/images/myimage.png"  />

Restrictions on AnyURI Data Type

Restrictions that can be used with anyURI data type:

  • enumeration
  • length
  • maxLength
  • minLength
  • pattern
  • whiteSpace

See XSD Restrictions chapter to learn more.

Navigation