共用方式為


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-tw,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 資料型別參考

概念

使用 XPath 擴充程式函式以獲得 XSD 支援