ms:schema-info-available 函数

如果当前节点有 XSD 信息,则返回 true。

        boolean ms:schema-info-available()

备注

以下表达式对所有具有 XSD 类型信息的节点返回 true。

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

示例

以下示例使用 XSLT 模板规则,从 books.xml 中选择所有元素并输出元素的数据类型和命名空间 URI(按 books.xsd 中的定义)。

XML 文件 (books.xml)

使用 books.xml

XSD 文件 (books.xsd)

使用 books.xsd

HTML 文件 (books.html)

该 HTML 文件与 ms:type-namespace-uri([node-set]) 函数主题中列出的文件相同。

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>

ms256442.collapse_all(zh-cn,VS.120).gif输出

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"

此处的输出与 ms:type-namespace-uri 主题中显示的相同,因为架构信息对每一个元素都可用。

请参见

参考

XML 架构 (XSD) 参考

XML 数据类型引用

概念

使用针对 XSD 的 XPath 扩展函数支持