Recent posts

Recent comments

Archive

Calender

«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

출처 : w3schools - XML Namespaces(영문)


프로그래밍을 정식으로 배운 적도 없는데다가, XML 문서는 작성해본 적도 없는터라,
뭔 말인지 몰라, 해석이 제대로 되지가 않는다... ㅜ.ㅜ
아래 번역에 오역이 많으리라 본다... ㅠ.ㅠ


XML Namespaces

XML의 이름 공간 (namespace)


XML Namespaces provide a method to avoid element name conflicts.

XML의 네임스페이스는, 엘리먼트 이름의 충돌을 막는 방법을 제공한다.


Name Conflicts

이름의 충돌


In XML, element names are defined by the developer.
This often results in a conflict when trying to mix XML documents from different XML applications.

XML에서 엘리먼트의 이름은 개발자가 정하게 되는데,
다른 XML 응용 프로그램에서 XML 문서를 가져와 결합하려 하면, 이 이름에서 종종 충돌이 일어난다.


This XML carries HTML table information:

아래 XML은 HTML의 <table> 정보를 전달하고 있다.

 
<table>
     <tr>
          <td>Apples</td>
          <td>Bananas</td>
     </tr>
</table>
 

This XML carries information about a table (a piece of furniture):

이 XML은 (가구의 하나인) 테이블에 관한 정보를 전달하고 있다.

 
<table>
     <name>African Coffee Table</name>
     <width>80</width>
     <length>120</length>
</table>
 

If these XML fragments were added together, there would be a name conflict.
Both contain a <table> element, but the elements have different content and meaning.

이러한 XML의 일부(fragment)가 함께 추가되면, 이름 충돌이 발생할 것이다.
양쪽 모두 <table> 엘리먼트가 들어있지만, 다른 의미와 다른 콘텐츠를 가지고 있기 때문이다.


A user or an XML application will not know how to handle these differences.

사용자나 XML용 응용프로그램은 이 차이점을 처리할 방법을 알 수 없기에 충돌이 일어난다.


Solving the Name Conflict Using a Prefix

접두어를 사용하여 이름 충돌을 해결하기


Name conflicts in XML can easily be avoided using a name prefix.

이름의 접두어를 사용하여 XML에서의 이름 충돌을 쉽게 막을 수 있다.


This XML carries information about an HTML table, and a piece of furniture:

아래의 XML은 HTML의 table과 가구인 테이블에 관한 정보를 전달하고 있다.

 
<h:table>
     <h:tr>
          <h:td>Apples</h:td>
          <h:td>Bananas</h:td>
     </h:tr>
</h:table>

<f:table>
     <f:name>African Coffee Table</f:name>
     <f:width>80</f:width>
     <f:length>120</f:length>
</f:table>
 

In the example above,
there will be no conflict because the two <table> elements have different names.

위의 예문에서는,
두 개의 <table> 엘리먼트가 서로 다른 이름을 가지고 있기 때문에 충돌이 없을 것이다.


XML Namespaces - The xmlns Attribute


When using prefixes in XML,
a so-called namespace for the prefix must be defined.

XML에서 접두어를 사용하는 경우,
접두어에 대하여, “네임스페이스”라는 것이 정해져야만 한다.


The namespace is defined by the xmlns attribute in the start tag of an element.

네임스페이스는 엘리먼트의 시작 태그 안쪽에서 xmlns 속성으로 지정한다.


The namespace declaration has the following syntax. xmlns:prefix="URI".

네임스페이스의 선언은 아래와 같은 구문을 가지고있다. xmlns:접두어="URI값".

 
<root>

<h:table xmlns:h="http://www.w3.org/TR/html4/">
     <h:tr>
          <h:td>Apples</h:td>
          <h:td>Bananas</h:td>
     </h:tr>
</h:table>

<f:table xmlns:f="http://www.w3schools.com/furniture">
     <f:name>African Coffee Table</f:name>
     <f:width>80</f:width>
     <f:length>120</f:length>
</f:table>

</root>

In the example above,
the xmlns attribute in the <table> tag give the h: and f: prefixes a qualified namespace.

위의 예문에서,
<table> 태그 안의 xmlns 속성이, h: 와 f: 라는 접두어에게, qualified namespace를 제공한다.


When a namespace is defined for an element,
all child elements with the same prefix are associated with the same namespace.

엘리먼트에 대해 네임스페이스가 지정되면,
같은 접두어를 가진 하위 엘리먼트(child element)들은 모두 같은 네임스페이스와 연결이 된다.


Namespaces can be declared in the elements where they are used or in the XML root element:

네임 스페이스는,
최상위 엘리먼트(root element) 안에서 또는,
그 네임스페이스가 사용될 엘리먼트 안에서 선언될 수 있다.

 
<root xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture">

<h:table>
     <h:tr>
          <h:td>Apples</h:td>
          <h:td>Bananas</h:td>
     </h:tr>
</h:table>

<f:table>
     <f:name>African Coffee Table</f:name>
     <f:width>80</f:width>
     <f:length>120</f:length>
</f:table>

</root>
 

Note: The namespace URI is not used by the parser to look up information.

네임스페이스의 URI는, 정보 검색용 parser에서 이용되지 않는다.
구문 분석기 parser가 네임스페이스 부분은 건너뛰고 그냥 넘어간다...??


XML 파서는 “접두어:엘리먼트 이름”을 한 개의 엘리먼트 이름으로 간주한다.


The purpose is to give the namespace a unique name.
However, often companies use the namespace as a pointer to a web page containing namespace information.

(이것의) 용도는 네임스페이스에 고유한 이름을 붙이는 것이다.
그러나, 간혹 company는
네임스페이스의 정보가 들어있는 웹 페이지를 가리키는 포인터로서 네임스페이스를 사용한다.


Uniform Resource Identifier (URI)

인터넷 식별자 (URI)


A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.

URI는 인터넷 자원(공급원)을 식별하는 문자열이다.


The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address.
Another, not so common type of URI is the Universal Resource Name (URN).

보편적으로 가장 흔한 URI는 인터넷 도메인 주소를 식별하는 URL이다.
그리 흔치 않은, 또 다른 URI의 유형은 URN이다.


In our examples we will only use URLs.

우리의 예문에서는 URL만을 사용할 것이다.


Default Namespaces

기본적인 네임스페이스 (네임스페이스의 기본값)


Defining a default namespace for an element saves us from using prefixes in all the child elements.
It has the following syntax:

엘리먼트에 대해서, 네임스페이스의 기본값을 지정하면,
모든 자식 엘리먼트에 일일이 접두어를 붙이지 않아도 된다.

 
xmlns="namespaceURI" 
 

This XML carries HTML table information:

아래 XML은 HTML의 <table> 정보를 전달하고 있다.

 
<table xmlns="http://www.w3.org/TR/html4/">
     <tr>
          <td>Apples</td>
          <td>Bananas</td>
     </tr>
</table>
 

This XML carries information about a piece of furniture:

이 XML은 가구의 일부에 관한 정보를 전달하고 있다.

 
<table xmlns="http://www.w3schools.com/furniture">
     <name>African Coffee Table</name>
     <width>80</width>
     <length>120</length>
</table>
 

Namespaces in Real Use


XSLT is an XML language that can be used to transform XML documents into other formats, like HTML.

XSLT는 XML 문서를 HTML과 같은 다른 형식의 문서로 변환하는 데 사용할 수 있는 XML 언어이다.


In the XSLT document below, you can see that most of the tags are HTML tags.

아래의 XSLT 문서에서 볼 수 있는 대부분의 태그는 HTML 태그이다.


The tags that are not HTML tags have the prefix xsl,
identified by the namespace xmlns:xsl="http://www.w3.org/1999/XSL/Transform":

HTML 태그가 아닌 태그는
네임 스페이스의 xmlns에 의해서 식별되는, xsl이라는 접두어를 가지고 있다.

 
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
     <h2>My CD Collection</h2>
     <table border="1">
          <tr>
               <th style="text-align:left">Title</th>
               <th style="text-align:left">Artist</th>
          </tr>
          <xsl:for-each select="catalog/cd">
          <tr>
               <td><xsl:value-of select="title"/></td>
               <td><xsl:value-of select="artist"/></td>
          </tr>
          </xsl:for-each>
     </table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>
 

If you want to learn more about XSLT, please read our XSLT Tutorial.

XSLT에 대해서 더 배우고 싶다면, XSLT Tutorial을 읽어보기 바란다.


'XML > w3schools' 카테고리의 다른 글

[ XML ] 8. XML 출력하기  (0) 2015.06.25
[ XML ] 7. XML의 인코딩(Encoding)  (0) 2015.06.24
[ XML ] 5. XML 엘리먼트의 속성  (0) 2015.06.22
[ XML ] 4. XML의 엘리먼트  (0) 2015.06.21
[ XML ] 3. XML 문서에서의 문법  (0) 2015.06.20