다음을 통해 공유


ms:type-local-name( ) 함수

제공된 노드 집합에서 현재 노드 또는 문서 순서상 첫 번째 노드의 XSD 형식의 정규화되지 않은 이름을 반환합니다.

string ms:type-local-name([node-set])

주의

단순 형식에 대해 type-local-name 함수는 "ID", "ENTITY" 등의 이름을 반환합니다. name 특성이 지정된 복합 XSD 형식에 대해 type-local-name 함수는 "Class"와 같이 정규화되지 않은 이름을 반환합니다. 이름이 없는 형식을 사용할 경우 이 함수는 빈 문자열을 반환합니다.

다음 샘플 식에서는 XSD 기본 제공 데이터 형식이 "string"인 모든 노드를 선택합니다.

"//*[ms:type-local-name()='string')]"

예제

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

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="/">
     <H3>nodes of all data types:</H3>
     <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="*">
     <DIV>
          <xsl:value-of select="name()"/> is of 
          <xsl:value-of select="ms:type-local-name()"/> 
     </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 += "<h2>Used in an XSLT</h2>";
         result += objxml.transformNode(objxsl);
         document.body.innerHTML = result;
         
       }
       catch (e) {
         alert(e.description);
       }
      }
    </script>
  </head>

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

출력

x:catalog is of

book is of

author is of string

title is of string

genre is of string

price is of float

publish_date is of date

description is of string

x:catalogbook 요소는 이름이 없는 형식을 가집니다.

참고 항목

참조

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

개념

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