다음을 통해 공유


namespace-uri 함수

문서 순서에서 첫 번째인 노드 집합 인수에서 노드 확장 이름의 네임스페이스 URI(Uniform Resource Identifier)를 반환합니다.

string namespace-uri(node-set?)

주의

노드 집합 인수가 비어 있거나 첫 번째 노드에 확장 이름이 없거나 확장 이름의 네임스페이스 URI가 Null인 경우 빈 문자열이 반환됩니다. 이 인수를 생략하면 유일한 멤버로 컨텍스트 노드가 있는 노드 집합을 기본값으로 설정합니다.

참고

요소 노드와 특성 노드를 제외하고 반환되는 문자열은 비어 있습니다.

샘플

XML 파일(data.xml)

<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<b:catalog xmlns:b="x-schema:book-schema.xml">
   <b:book id="bk101">
      <b:author>Gambardella, Matthew</b:author>
      <b:title>XML Developer's Guide</b:title>
      <b:genre>Computer</b:genre>
      <b:price>44.95</b:price>
      <b:publish_date>2000-10-01</b:publish_date>      
      <b:description>An in-depth look at creating applications with XML.</b:description>
   </b:book>
   <b:book id="bk102">
      <b:author>Ralls, Kim</b:author>
      <b:title>Midnight Rain</b:title>
      <b:genre>Fantasy</b:genre>
      <b:price>5.95</b:price>
      <b:publish_date>2000-12-16</b:publish_date>
      <b:description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</b:description>
   </b:book>
</b:catalog>

XSLT 파일(sample.xsl)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="html"/>
  <xsl:template match="/">
      <html>
         <body>
            <h3>namespace-uri() Function</h3>
            
            <table width="100%" border="1">
               <tr>
                  <td width="25%"><b>namespace-uri()</b></td>
                  <td width="25%"><b>name()</b></td>
                  <td width="25%"><b>local-name</b></td>
                  <td width="25%"><b>text()</b></td>
               </tr>
               <xsl:apply-templates />
            </table>      

         </body>
      </html>
  </xsl:template>
  
  <xsl:template match="*">
      <tr>
         <td>
            <xsl:value-of select="namespace-uri()"/>
         </td>
         <td>
            <xsl:value-of select="name()"/>
         </td>
         <td>
            <xsl:value-of select="local-name()"/>
         </td>
         <td>
            <xsl:value-of select="text()"/>
         </td>
      </tr>
      <xsl:apply-templates select="*"/>
  </xsl:template>
</xsl:stylesheet>

보조 XSLT 파일(book-schema.xml)

<Schema name="books" xmlns="urn:schemas-microsoft-com:xml-data"
           xmlns:dt="urn:schemas-microsoft-com:datatypes">
   <ElementType name="author"/>
   <ElementType name="title"/>
   <ElementType name="genre"/>
   <ElementType name="price"/>
   <ElementType name="publish_date"/>
   <ElementType name="description"/>
   <AttributeType name="id" dt:type="id"/>
         
   <ElementType name="catalog">
      <element type="book"/>
   </ElementType>
         
   <ElementType name="book" model="closed" content="eltOnly">
      <attribute type="id"/>
      <element type="author"/>
      <element type="title"/>
      <element type="genre"/>
      <element type="price"/>
      <element type="publish_date"/>
      <element type="description"/>
   </ElementType>
</Schema>

서식이 지정된 출력

형식이 지정된 함수 출력

프로세서 출력

<html>

<body>

<h3>namespace-uri() Function</h3>

<table width="100%" border="1">

<tr>

<td width="25%"><b>namespace-uri()</b></td>

<td width="25%"><b>name()</b></td>

<td width="25%"><b>local-name</b></td>

<td width="25%"><b>text()</b></td>

</tr>

<tr>

<td>x-schema:book-schema.xml</td>

<td>b:catalog</td>

<td>catalog</td>

<td></td>

</tr>

...

<tr>

<td>x-schema:book-schema.xml</td>

<td>b:author</td>

<td>author</td>

<td>Gambardella, Matthew</td>

</tr>

...

</table>

</body>

</html>

참고 항목

참조

XML 데이터 형식 참조