Fonction ms:schema-info-available

Retourne true si l'information XSD est disponible pour le nœud actuel.

        boolean ms:schema-info-available()

Notes

L'expression suivante retourne true pour tous les nœuds possédant des informations de type XSD.

"//*[ms:schema-info-available()]"

Exemple

L'exemple suivant utilise une règle de modèle XSLT pour sélectionner tous les éléments de 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 HTML (books.html)

Le fichier HTML est identique à celui répertorié dans la rubrique Fonction ms:type-namespace-uri([node-set]).

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:template match="text()"/>
  <xsl:output method="html"   
     omit-xml-declaration="yes"/>

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

  <xsl:template match="*">
    <!-- process only those element whose schema-info is available. -->
    <xsl:if test="ms:schema-info-available()">
      <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:if>
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>

Sortie

x:catalog is of "" in ""

book is of "" in ""

author is of "string" in "http://www.w3.org/2001/XMLSchema"

title is of "string" in "http://www.w3.org/2001/XMLSchema"

genre is of "string" in "http://www.w3.org/2001/XMLSchema"

price is of "float" in "http://www.w3.org/2001/XMLSchema"

publish_date is of "date" in "http://www.w3.org/2001/XMLSchema"

description is of "string" in "http://www.w3.org/2001/XMLSchema"

description is of "string" in "http://www.w3.org/2001/XMLSchema"

Cette sortie est identique à celle indiquée dans la rubrique ms:type-namespace-uri car les informations de schéma sont disponibles pour chaque élément.

Voir aussi

Référence

Référence du schéma XML (XSD)
Référence des types de données XML

Concepts

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