<xsd:any/>
「任意の」要素と実際には一致しません。むしろ、スコープ内のスキーマのどこかで宣言された任意の要素と一致します。
たとえば、次のスキーマは、xsd:any を含む要素を定義します。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
ただし、次のクエリは失敗します。
import schema namespace my = "http://www.example.com/";
validate { <my:root><my:Child/></my:root> }
my:Child はどこにも宣言されていないためです。
スキーマが次のように変更された場合:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Child" type="xs:anyType"/>
</xs:schema>
その後、クエリは成功するはずです。もちろん、 xsd:any に一致する要素は別の名前空間にある可能性があります。