L'élément field permet de sélectionner par l'intermédiaire d'une expression XPath , des éléments ou des attributs destinés à être utilisés comme clé.
<xsd:field id = ID xpath = {sous-ensemble d'expressions XPath} {tout attribut ayant un espace de noms différent de celui du schéma...}> Contenu : (annotation?) </xsd:field>
L'élément field possède plusieurs attributs destinés à identifier le champ et à préciser une expression XPath.
Attributs | Description |
---|---|
id | précise un identificateur unique pour l'élément. |
xpath | spécifie un sous-ensemble d'expressions XPath. |
L'élément field ne peut être inclus que dans les éléments suivants :
Exemple [voir]<?xml version="1.0" encoding="ISO-8859-1"?> <site:annuaire xmlns:site="http://www.site.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.site.com c:\schema.xsd"> <page numero="1" langue="US"> <titre>XML Schema</titre> <lien>http://www.w3.org/XML/Schema/</lien> <commentaire> XML Schemas express shared vocabularies and allow machines ... </commentaire> <cle_site>1</cle_site> </page> <page numero="2" langue="FR"> <titre>XML Schema tome 0 : Introduction</titre> <lien>http://xmlfr.org/w3c/TR/xmlschema-0/</lien> <commentaire> Le tome 0 de la spécification XML Schema n'est qu'une introduction ... </commentaire> <cle_site>1</cle_site> </page> <page numero="3" langue="FR"> <titre>XML Schema tome 1 : Structures</titre> <lien>http://xmlfr.org/w3c/TR/xmlschema-1/</lien> <commentaire> XML Schema tome 1 : Structures est la spécification du langage ... </commentaire> <cle_site>2</cle_site> </page> <page numero="4" langue="US"> <titre>XML Schema Part 2: Datatypes</titre> <lien>http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/</lien> <commentaire> XML Schema: Datatypes is part 2 of the specification of the XML ... <cle_site>1</cle_site> </page> <site numero="1"> <nom>W3C</nom> <url>http://www.w3.org/</url> </site> <site numero="2"> <nom>XMLfr</nom> <url>http://www.xmlfr.org/</url> </site> </site:annuaire> <?xml version="1.0" encoding="ISO-8859-1"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.site.com" targetNamespace="http://www.site.com"> <xsd:complexType name="type_page"> <xsd:sequence> <xsd:element name="titre" type="xsd:string"/> <xsd:element name="lien" type="xsd:string"/> <xsd:element name="commentaire" type="xsd:string"/> <xsd:element name="cle_site" type="xsd:positiveInteger"/> </xsd:sequence> <xsd:attribute name="numero" type="xsd:positiveInteger" use="required"/> <xsd:attribute name="langue" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="type_site"> <xsd:sequence> <xsd:element name="nom" type="xsd:string"/> <xsd:element name="url" type="xsd:string"/> </xsd:sequence> <xsd:attribute name="numero" type="xsd:positiveInteger" use="required"/> </xsd:complexType> <xsd:complexType name="type_annuaire"> <xsd:sequence> <xsd:element name="page" maxOccurs="unbounded" type="type_page"> <xsd:unique name="cle_page"> <xsd:selector xpath=".//page"/> <xsd:field xpath="./@numero"/> </xsd:unique> </xsd:element> <xsd:element name="site" maxOccurs="unbounded" type="type_site"> <xsd:key name="num_site"> <xsd:selector xpath=".//site"/> <xsd:field xpath="./@numero"/> </xsd:key> <xsd:keyref name="cle_site" refer="num_site"> <xsd:selector xpath=".//page"/> <xsd:field xpath="./cle_site"/> </xsd:keyref> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:element name="annuaire" type="type_annuaire"/> </xsd:schema> |