XML Tutorial/XML Schema/anyURI

Материал из Web эксперт
Перейти к: навигация, поиск

The anyURI data type represents a URI reference

<!-- schema -->
<xsd:element name="address">
  <xsd:simpleType>
   <xsd:restriction base="xsd:anyURI">
    <xsd:enumeration value=
    "http://www.w3.org/TR/2000/PR-xlink-20001220/"/>
    <xsd:enumeration value=
    "http://www.w3.org/TR/xmlschema-2/"/>
   </xsd:restriction>
  </xsd:simpleType>
</xsd:element>
<!-- instance document -->
<address>http://www.w3.org/TR/xmlschema-2/</address>


To limit the accepted URI schemes

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
  <xs:simpleType name="myType">
    <xs:restriction base="xs:anyURI">
      <xs:pattern value="http://.*" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>