다음을 통해 공유


ms:type-namespace-uri( ) 함수

제공된 노드 집합에서 현재 노드 또는 문서 순서상 첫 번째 노드의 XSD 데이터 형식에 연결된 네임스페이스 URI를 반환합니다.

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

주의

단순 XSD 형식에 대해 type-namespace-uri 함수는 빈 문자열을 반환합니다. name 특성이 지정된 복합 XSD 형식에 대해 type-namespace-uri 함수는 "http://www.example.microsoft.com/my-xsd-types."와 같은 전체 URI를 반환합니다.

다음 샘플 식은 데이터 형식에 "PurchaseOrderType"의 네임스페이스 URI가 있는 노드를 반환합니다.

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

예제

다음 예제에서는 XSLT 템플릿 규칙을 사용하여 books.xml에서 모든 요소를 선택하고 books.xsd에 정의된 대로 요소 데이터 형식 및 네임스페이스 URI를 출력합니다.

XML 파일(books.xml)

books.xml을 사용합니다.

XSD 파일(books.xsd)

books.xsd를 사용합니다.

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>

HTML 파일(books.html)

HTML 파일에는 XML, XSLT 및 XSD 파일 로드를 처리하는 JScript가 포함됩니다.

<html>
  <head>
    <script>
      function init() {
       try {
         var objxsd = new ActiveXObject("Msxml2.XMLSchemaCache.5.0");
         var objxml = new ActiveXObject("Msxml2.DOMDocument.5.0");
         var objxsl = new ActiveXObject("Msxml2.DOMDocument.5.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.xsl");

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

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

출력

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"

x:catalogbook 요소는 익명의 데이터 형식을 가집니다. 따라서 ms:type-local-name()ms:type-namespace-uri() 함수는 모두 빈 문자열을 반환합니다.

참고 항목

참조

XML 스키마(XSD) 참조
XML 데이터 형식 참조

개념

XSD 지원을 위해 XPath 확장 함수 사용