Fonction ms:type-namespace-uri([collection de nœuds])

Retourne l'URI d'espace de noms associé au type de données XSD d'un nœud actuel ou du premier nœud (dans l'ordre du document) de la collection de nœuds spécifiée.

string ms:type-namespace-uri([node-set])

Notes

Pour les types XSD simples, la fonction type-namespace-uri retourne une chaîne vide. Pour les types XSD complexes dont l'attribut name est spécifié, la fonction type-namespace-uri retourne un URI complet tel que "http://www.example.microsoft.com/my-xsd-types."

L'exemple d'expression suivant retourne des nœuds dont le type de données possède un URI d'espace de noms « PurchaseOrderType ».

//*[ms:type-namespace-uri()='uri:PurchaseOrderType')]

Exemple

L'exemple suivant utilise une règle de modèle XSLT pour sélectionner tous les éléments dans books.xml et générer les types de données des éléments et l'URI d'espace de noms comme défini dans books.xsd.

Fichier XML (books.xml)

Utilisez books.xml.

Fichier XSD (books.xsd)

Utilisez books.xsd.

Fichier XSLT (books.xslt)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
     xmlns:ms="urn:schemas-microsoft-com:xslt"   
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html"   
     omit-xml-declaration="yes"/>

  <xsl:template match="/">
     <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="*">
    <DIV>
       <xsl:value-of select="name()"/> is of
       "<xsl:value-of select="ms:type-local-name()"/>" in 
       "<xsl:value-of select="ms:type-namespace-uri()"/>" 
    </DIV>
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>

Fichier HTML (books.html)

Le fichier HTML contient un JScript qui gère le chargement de fichiers XML, XSLT et XSD.

<html>
  <head>
    <script>
      function init() {
       try {
         var objxsd = new ActiveXObject("Msxml2.XMLSchemaCache.6.0");
         var objxml = new ActiveXObject("Msxml2.DOMDocument.6.0");
         var objxsl = new ActiveXObject("Msxml2.DOMDocument.6.0");

         // namespace uri ("urn:books") must be declared as one of the
         // namespace delarations in the "books.xml" that is an instance
         // of "books.xsd"
         objxsd.add("urn:books", "books.xsd");

         objxml.schemas = objxsd;
         objxml.setProperty("SelectionLanguage", "XPath");
         objxml.setProperty("SelectionNamespaces",
              "xmlns:ms='urn:schemas-microsoft-com:xslt'");
         objxml.async=false;
         objxml.validateOnParse=true;
         objxml.load("books.xml");

         objxsl.async=false;
         objxsl.load("books.xslt");

         document.body.innerHTML = objxml.transformNode(objxsl);         
       }
       catch (e) {
         alert(e.description);
       }
      }
    </script>
  </head>

  <body onload="init()">
  </body>
</html>

ms256130.collapse_all(fr-fr,VS.120).gifSortie

x:catalog is of "" in "" 
book is of "" in "" 
author is of "string" in "http://www.w3.org/2001/XMLSchema" 
Gambardella, Matthew
title is of "string" in "http://www.w3.org/2001/XMLSchema" 
XML Developer's Guide
genre is of "string" in "http://www.w3.org/2001/XMLSchema" 
Computer
price is of "float" in "http://www.w3.org/2001/XMLSchema" 
44.95
publish_date is of "date" in "http://www.w3.org/2001/XMLSchema" 
2000-10-01
description is of "string" in "http://www.w3.org/2001/XMLSchema" 
An in-depth look at creating applications with XML.

Notez que les éléments x:catalog et book présentent des types de données anonymes. Par conséquent, les fonctions ms:type-local-name() et ms:type-namespace-uri() retournent une chaîne vide.

Voir aussi

Référence

Référence XSD (XML Schemas)

Référence des types de données XML

Concepts

Utilisation des fonctions d'extension XPath pour la prise en charge de XSD