"xml.dom" --- 문서 객체 모델 API
********************************

**소스 코드:** Lib/xml/dom/__init__.py

======================================================================

문서 객체 모델(Document Object Model), 또는 "DOM"은 XML 문서를 액세스
하고 수정하기 위한 W3C(World Wide Web Consortium)의 교차 언어 API입니
다. DOM 구현은 XML 문서를 트리 구조로 나타내거나, 클라이언트 코드가 이
러한 구조를 처음부터 구축 할 수 있도록 합니다. 그런 다음 잘 알려진 인
터페이스를 제공하는 객체 집합을 통해 구조에 액세스 할 수 있습니다.

DOM은 무작위 액세스 응용 프로그램에 매우 유용합니다. SAX에서는 한 번에
한 조각의 문서만 볼 수 있습니다. 하나의 SAX 요소를 보고 있는 동안, 다
른 SAX 요소에 액세스할 수 없습니다. 텍스트 노드를 보고 있으면, 이것을
포함하는 요소에 액세스할 수 없습니다. SAX 응용 프로그램을 작성할 때는,
문서에서의 프로그램의 위치를 자신의 코드 어딘가에서 추적해야 합니다.
SAX는 여러분을 위해 대신해주지 않습니다. 또한, XML 문서를 미리 보아야
한다면, 운이 다했다고 보아야 합니다.

트리에 액세스할 수 없는 이벤트 중심 모델에서는 일부 응용 프로그램이 불
가능합니다. 물론 SAX 이벤트에서 트리를 직접 만들 수는 있지만, DOM을 사
용하면 그런 코드를 작성하지 않아도 됩니다. DOM은 XML 데이터의 표준 트
리 표현입니다.

문서 객체 모델은 W3C에 의해 단계적으로 또는 그들의 용어로는 "수준"으로
정의됩니다. API의 파이썬 매핑은 실질적으로 DOM 수준 2 권장 사항을 기반
으로 합니다.

DOM 응용 프로그램은 일반적으로 일부 XML을 DOM으로 구문 분석하는 것으로
시작합니다. 이것을 달성하는 방법은 DOM 수준 1은 전혀 다루지 않으며, 수
준 2는 제한된 개선만을 제공합니다: "Document" 생성 메서드에 대한 액세
스를 제공하는 "DOMImplementation" 객체 클래스가 있습니다만, 구현에 독
립적인 방법으로 XML 판독기(reader)/기록기(writer)/Document 구축기
(builder)를 액세스하는 방법이 없습니다. 기존 "Document" 객체 없이 이러
한 메서드에 액세스할 수 있는 잘 정의된 방법도 없습니다. 파이썬에서, 각
DOM 구현은 "getDOMImplementation()" 함수를 제공합니다. DOM 수준 3은 판
독기(reader)에 대한 인터페이스를 정의하는 로드/저장 명세를 추가하지만,
아직 파이썬 표준 라이브러리에서는 사용할 수 없습니다.

일단 DOM 문서 객체가 있으면, 프로퍼티와 메서드를 통해 XML 문서의 일부
에 액세스 할 수 있습니다. 이러한 프로퍼티는 DOM 명세에 정의되어 있습니
다; 레퍼런스 설명서의 이 부분은 파이썬이 명세를 해석하는 방법을 설명합
니다.

W3C에서 제공하는 명세는 Java, ECMAScript 및 OMG IDL 용 DOM API를 정의
합니다. 여기에 정의된 파이썬 매핑은 대부분 명세의 IDL 버전을 기반으로
하지만, 엄격한 준수는 필요하지 않습니다 (구현은 IDL의 엄격한 매핑을 자
유롭게 지원할 수 있습니다). 매핑 요구 사항에 대한 자세한 내용은 규격
준수 절을 참조하십시오.

더 보기:

  Document Object Model (DOM) Level 2 Specification
     파이썬 DOM API의 기반이 되는 W3C 권장 사항.

  Document Object Model (DOM) Level 1 Specification
     "xml.dom.minidom"이 지원하는 DOM에 대한 W3C 권장 사항.

  Python Language Mapping Specification
     OMG IDL에서 파이썬으로의 매핑을 지정합니다.


모듈 내용
=========

The "xml.dom" contains the following functions:

xml.dom.registerDOMImplementation(name, factory)

   *factory* 함수를 *name*이라는 이름으로 등록합니다. 팩토리(factory)
   함수는 "DOMImplementation" 인터페이스를 구현하는 객체를 반환해야 합
   니다. 팩토리 함수는 호출 때마다 같은 객체를 반환하거나 특정 구현에
   적합하다면 새 객체를 반환할 수 있습니다 (예를 들어, 해당 구현이 일
   부 사용자 정의를 지원하는 경우).

xml.dom.getDOMImplementation(name=None, features=())

   Return a suitable DOM implementation. The *name* is either well-
   known, the module name of a DOM implementation, or "None". If it is
   not "None", imports the corresponding module and returns a
   "DOMImplementation" object if the import succeeds.  If no name is
   given, and if the environment variable "PYTHON_DOM" is set, this
   variable is used to find the implementation. The only well-known
   name in the standard library is "'minidom'", for "xml.dom.minidom".

   If name is not given, this examines the available implementations
   to find one with the required feature set.  If no implementation
   can be found, raise an "ImportError".  The features list must be a
   sequence of "(feature, version)" pairs which are passed to the
   "hasFeature()" method on available "DOMImplementation" objects.

몇 가지 편의 상수도 제공됩니다:

xml.dom.EMPTY_NAMESPACE

   The value used to indicate that no namespace is associated with a
   node in the DOM.  This is typically found as the "namespaceURI" of
   a node, or used as the *namespaceURI* parameter to a namespaces-
   specific method.

xml.dom.XML_NAMESPACE

   예약된 접두어 "xml"과 연관된 이름 공간 URI, Namespaces in XML에서
   정의됩니다 (4절).

xml.dom.XMLNS_NAMESPACE

   이름 공간 선언의 이름 공간 URI, Document Object Model (DOM) Level 2
   Core Specification에서 정의됩니다 (1.1.8 절).

xml.dom.XHTML_NAMESPACE

   XHTML 이름 공간의 URI, XHTML 1.0: The Extensible HyperText Markup
   Language에서 정의됩니다 (3.1.1 절).

In addition, "xml.dom" contains a base "Node" class and the DOM
exception classes.  The "Node" class provided by this module does not
implement any of the methods or attributes defined by the DOM
specification; concrete DOM implementations must provide those.  The
"Node" class provided as part of this module does provide the
constants used for the "nodeType" attribute on concrete "Node"
objects; they are located within the class rather than at the module
level to conform with the DOM specifications.


DOM의 객체
==========

DOM에 대한 결정적인 문서는 W3C의 DOM 명세입니다.

The names documented in this section are DOM interfaces. With the
exception of "Node" and the exception classes, they are not provided
by the "xml.dom" module itself, but by concrete DOM implementations,
such as "xml.dom.minidom".

DOM 어트리뷰트는 간단한 문자열 대신 노드로 조작될 수도 있음에 유의하십
시오. 하지만 그렇게 해야만 하는 경우는 매우 드물어서, 이 사용법은 아직
문서화되지 않았습니다.

+----------------------------------+-------------------------------------+-----------------------------------+
| 인터페이스                       | 절                                  | 목적                              |
|==================================|=====================================|===================================|
| "DOMImplementation"              | DOMImplementation 객체              | 하부 구현에 대한 인터페이스.      |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Node"                           | Node 객체                           | 문서에 있는 대부분 객체에 대한 베 |
|                                  |                                     | 이스 인터페이스.                  |
+----------------------------------+-------------------------------------+-----------------------------------+
| "NodeList"                       | NodeList 객체                       | 노드의 시퀀스를 위한 인터페이스.  |
+----------------------------------+-------------------------------------+-----------------------------------+
| "DocumentType"                   | DocumentType 객체                   | 문서를 처리하는 데 필요한 선언에  |
|                                  |                                     | 대한 정보.                        |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Document"                       | Document 객체                       | 전체 문서를 나타내는 객체.        |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Element"                        | Element 객체                        | 문서 계층의 엘리먼트 노드.        |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Attr"                           | Attr 객체                           | 엘리먼트 노드의 어트리뷰트 값 노  |
|                                  |                                     | 드                                |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Comment"                        | Comment 객체                        | 소스 문서에 있는 주석의 표현.     |
+----------------------------------+-------------------------------------+-----------------------------------+
| "Text"                           | Text와 CDATASection 객체            | 문서의 텍스트 내용을 포함하는 노  |
|                                  |                                     | 드.                               |
+----------------------------------+-------------------------------------+-----------------------------------+
| "ProcessingInstruction"          | ProcessingInstruction 객체          | 처리 명령어 표현.                 |
+----------------------------------+-------------------------------------+-----------------------------------+

추가 절에서 파이썬에서 DOM 작업을 위해 정의된 예외에 관해 설명합니다.


DOMImplementation 객체
----------------------

"DOMImplementation" 인터페이스는 응용 프로그램이 사용 중인 DOM에서 특
정 기능의 가용성을 판별할 방법을 제공합니다. DOM 수준 2는
"DOMImplementation"을 사용하여 새로운 "Document"와 "DocumentType" 객체
를 만드는 기능을 추가했습니다.

DOMImplementation.hasFeature(feature, version)

   문자열 *feature*와 *version* 쌍으로 식별되는 기능이 구현되었으면
   "True"를 반환합니다.

DOMImplementation.createDocument(namespaceUri, qualifiedName, doctype)

   지정된 *namespaceUri*와 *qualifiedName*을 가진 자식 "Element" 객체
   를 포함하는 새 "Document" 객체(DOM의 루트)를 반환합니다. *doctype*
   은 "createDocumentType()"으로 만든 "DocumentType" 객체거나 "None"이
   어야 합니다. 파이썬 DOM API에서, "Element" 자식이 만들어지지 않음을
   표시하기 위해 처음 두 인자는 "None"일 수 있습니다.

DOMImplementation.createDocumentType(qualifiedName, publicId, systemId)

   XML 문서 형 선언에 포함된 정보를 나타내는, 지정된 *qualifiedName*,
   *publicId* 및 *systemId* 문자열을 캡슐화하는 새 "DocumentType" 객체
   를 반환합니다.


Node 객체
---------

XML 문서의 모든 구성 요소는 "Node"의 서브 클래스입니다.

Only nodes of the following types can have children, and only children
of the listed types:

"Document"
   at most one "Element", at most one "DocumentType",
   "ProcessingInstruction" and "Comment"

"DocumentFragment" and "Element"
   "Element", "Text", "CDATASection", "ProcessingInstruction" and
   "Comment"

"Attr"
   "Text"

Nodes of other types cannot have children. Inserting a child of a not
allowed type raises "HierarchyRequestErr".

Node.nodeType

   An integer representing the node type.  Symbolic constants for the
   types are on the "Node" object. This is a read-only attribute.

Node.ELEMENT_NODE
Node.ATTRIBUTE_NODE
Node.TEXT_NODE
Node.CDATA_SECTION_NODE
Node.ENTITY_REFERENCE_NODE
Node.ENTITY_NODE
Node.PROCESSING_INSTRUCTION_NODE
Node.COMMENT_NODE
Node.DOCUMENT_NODE
Node.DOCUMENT_TYPE_NODE
Node.DOCUMENT_FRAGMENT_NODE
Node.NOTATION_NODE

   Integer constants for the possible values of the "nodeType"
   attribute.

Node.parentNode

   현재 노드의 부모, 또는 문서 노드의 경우 "None". 값은 항상 "Node" 객
   체나 "None"입니다. "Element" 노드의 경우, 이것은 부모 엘리먼트가 되
   는데, 루트 엘리먼트는 예외로, 이때는 "Document" 객체가 됩니다.
   "Attr" 노드의 경우, 항상 "None"입니다. 이것은 읽기 전용 어트리뷰트
   입니다.

Node.attributes

   어트리뷰트 객체의 "NamedNodeMap". 엘리먼트에만 실제 값이 있습니다;
   다른 것은 이 어트리뷰트에서 "None"을 제공합니다. 이것은 읽기 전용
   어트리뷰트입니다.

Node.previousSibling

   같은 부모를 갖고 이 노드 바로 앞에 있는 노드. 예를 들어 *self* 엘리
   먼트의 시작 태그 바로 앞에 오는 종료 태그의 엘리먼트. 물론, XML 문
   서는 단순히 엘리먼트만으로 구성되지 않기 때문에, 이전 형제(previous
   sibling)는 텍스트, 주석 또는 뭔가 다른 것이 될 수 있습니다. 이 노드
   가 부모의 첫 번째 자식이면, 이 어트리뷰트는 "None"입니다. 이것은 읽
   기 전용 어트리뷰트입니다.

Node.nextSibling

   같은 부모를 갖고 이 노드 바로 뒤에 나오는 노드. "previousSibling"도
   참조하십시오. 이것이 부모의 마지막 자식이면, 이 어트리뷰트는 "None"
   입니다. 이것은 읽기 전용 어트리뷰트입니다.

Node.childNodes

   A "NodeList" of the children of this node. If the node has no
   children, the list is empty. This is a read-only attribute.

Node.firstChild

   노드의 첫 번째 자식 (있다면), 또는 "None". 이것은 읽기 전용 어트리
   뷰트입니다.

Node.lastChild

   노드의 마지막 자식 (있다면), 또는 "None". 이것은 읽기 전용 어트리뷰
   트입니다.

Node.localName

   The part of the "tagName" following the colon if there is one, else
   the entire "tagName".  The value is a string.

Node.prefix

   The part of the "tagName" preceding the colon if there is one, else
   the empty string.  The value is a string, or "None".

Node.namespaceURI

   엘리먼트 이름과 연관된 이름 공간. 이것은 문자열이나 "None"입니다.
   이것은 읽기 전용 어트리뷰트입니다.

Node.ownerDocument

   The "Document" object to which this node belongs, or "None" for a
   document itself. This is a read-only attribute.

Node.isSupported(feature, version)

   Return whether the DOM implementation supports a particular
   *feature*, as "DOMImplementation.hasFeature()" does.

Node.setUserData(key, data, handler)

   Associate *data* with *key* on this node and return the data
   previously associated with *key*, or "None". If *data* is "None",
   the association is removed. *handler* is called when the node is
   cloned, imported, renamed or deleted; pass "None" if no
   notification is needed.

Node.getUserData(key)

   Return the data associated with *key* on this node by
   "setUserData()", or "None".

Node.nodeName

   The name of this node, depending on its type; see the table below.
   You can always get the information you would get here from another
   property such as the "tagName" property for elements or the "name"
   property for attributes. This is a read-only attribute.

Node.nodeValue

   The value of this node, depending on its type; see the table below.
   The value is a string or "None".

The values of "nodeName" and "nodeValue" for each node type are:

+----------------------------------+-----------------------------------------+---------------------------------------+
| Node type                        | nodeName                                | nodeValue                             |
|==================================|=========================================|=======================================|
| "Attr"                           | "name"                                  | "value"                               |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "CDATASection"                   | "'#cdata-section'"                      | the content                           |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Comment"                        | "'#comment'"                            | the content                           |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Document"                       | "'#document'"                           | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "DocumentFragment"               | "'#document-fragment'"                  | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "DocumentType"                   | "name"                                  | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Element"                        | "tagName"                               | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Entity"                         | the name of the entity                  | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Notation"                       | the name of the notation                | "None"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "ProcessingInstruction"          | "target"                                | "data"                                |
+----------------------------------+-----------------------------------------+---------------------------------------+
| "Text"                           | "'#text'"                               | the content                           |
+----------------------------------+-----------------------------------------+---------------------------------------+

Node.hasAttributes()

   노드에 어트리뷰트가 있으면 "True"를 반환합니다.

Node.hasChildNodes()

   노드에 자식 노드가 있으면 "True"를 반환합니다.

Node.isSameNode(other)

   *other*가 이 노드와 같은 노드를 가리키면 "True"를 반환합니다. 이것
   은 모든 종류의 프락시 구조를 사용하는 DOM 구현에서 특히 유용합니다
   (여러 객체가 같은 노드를 가리킬 수 있기 때문입니다).

   참고:

     이것은 여전히 "작업 초안" 단계에 있는 제안된 DOM 수준 3 API를 기
     반으로 하지만, 이 특정 인터페이스는 논란의 여지가 없는 것으로 보
     입니다. W3C의 변경 사항이 파이썬 DOM 인터페이스에서 이 메서드에
     반드시 영향을 미치는 것은 아닙니다 (이를 위한 새 W3C API도 지원되
     기는 하겠지만).

Node.appendChild(newChild)

   자식 리스트의 끝에 이 노드의 새 자식 노드를 추가하고, *newChild*를
   반환합니다. 노드가 이미 트리에 있으면, 먼저 제거됩니다.

Node.insertBefore(newChild, refChild)

   Insert a new child node before an existing child.  It must be the
   case that *refChild* is a child of this node; if not, "NotFoundErr"
   is raised. *newChild* is returned. If *refChild* is "None", it
   inserts *newChild* at the end of the children's list.

Node.removeChild(oldChild)

   Remove a child node.  *oldChild* must be a child of this node; if
   not, "NotFoundErr" is raised.  *oldChild* is returned on success.
   If *oldChild* will not be used further, its "unlink()" method
   should be called.

Node.replaceChild(newChild, oldChild)

   Replace an existing node with a new node. It must be the case that
   *oldChild* is a child of this node; if not, "NotFoundErr" is
   raised.

Node.normalize()

   모든 텍스트 스트레치(stretch)가 단일 "Text" 인스턴스로 저장되도록,
   인접한 텍스트 노드를 결합합니다. 이는 많은 응용 프로그램에서 DOM 트
   리의 텍스트 처리를 단순화합니다.

Node.cloneNode(deep)

   이 노드를 복제합니다. *deep*을 설정하면 모든 자식 노드도 복제됩니다
   . 복제를 반환합니다.


NodeList 객체
-------------

A "NodeList" represents a sequence of nodes.  These objects are used
in two ways in the DOM Core recommendation:  an "Element" object
provides one as its list of child nodes, and the
"getElementsByTagName()" and "getElementsByTagNameNS()" methods of
"Node" return objects with this interface to represent query results.

"NodeList" does *not* inherit from "Node".

DOM 수준 2 권장 사항은 이러한 객체에 대해 하나의 메서드와 하나의 어트
리뷰트를 정의합니다:

NodeList.item(i)

   Return the *i*'th item from the sequence, or "None" if *i* is out
   of range. Negative indices are not supported.

NodeList.length

   시퀀스의 노드 수.

또한, 파이썬 DOM 인터페이스는 "NodeList" 객체를 파이썬 시퀀스로 사용할
수 있도록 몇 가지 추가 지원을 요구합니다. 모든 "NodeList" 구현에는
"__len__()"과 "__getitem__()"에 대한 지원이 포함되어야 합니다; 이를 통
해 "for" 문에서 "NodeList"를 이터레이트할 수 있고, "len()" 내장 함수를
적절히 지원할 수 있습니다.

DOM 구현이 문서 수정을 지원하면, "NodeList" 구현은 "__setitem__()"과
"__delitem__()" 메서드도 지원해야 합니다.


DocumentType 객체
-----------------

Information about the notations and entities declared by a document
(including the external subset if the parser uses it and can provide
the information) is available from a "DocumentType" object.  The
"DocumentType" for a document is available from the "Document"
object's "doctype" attribute; if there is no "DOCTYPE" declaration for
the document, the document's "doctype" attribute will be set to "None"
instead of an instance of this interface.

"DocumentType"은 "Node"의 특수화(specialization)이고 다음 어트리뷰트를
추가합니다:

DocumentType.publicId

   The public identifier for the external subset of the document type
   definition, or "None" if the "DOCTYPE" declaration does not specify
   it.

DocumentType.systemId

   The system identifier, a URI, for the external subset of the
   document type definition, or "None" if the "DOCTYPE" declaration
   does not specify it.

DocumentType.internalSubset

   문서에서 완전한 내부 부분 집합(internal subset)을 제공하는 문자열.
   부분 집합을 묶는 대괄호는 포함되지 않습니다. 문서에 내부 부분 집합
   이 없으면 "None"이어야 합니다.

DocumentType.name

   "DOCTYPE" 선언에 제공된 루트 엘리먼트의 이름 (있다면).

DocumentType.entities

   This is a "NamedNodeMap" of "Entity" nodes giving the definitions
   of external entities. For entity names defined more than once, only
   the first definition is provided (others are ignored as required by
   the XML recommendation).  This may be "None" if the information is
   not provided by the parser, or if no entities are defined.

DocumentType.notations

   This is a "NamedNodeMap" of "Notation" nodes giving the definitions
   of notations. For notation names defined more than once, only the
   first definition is provided (others are ignored as required by the
   XML recommendation).  This may be "None" if the information is not
   provided by the parser, or if no notations are defined.


Document 객체
-------------

"Document"는 구성 엘리먼트, 어트리뷰트, 처리 명령어, 주석 등을 포함한
전체 XML 문서를 나타냅니다. "Node"의 프로퍼티를 상속한다는 점을 기억하
십시오.

Document.documentElement

   문서의 유일한 루트 엘리먼트.

Document.doctype

   The "DocumentType" node of the document, or "None". This is a read-
   only attribute.

Document.implementation

   The "DOMImplementation" object which created this document. This is
   a read-only attribute.

Document.strictErrorChecking

   Whether error checking is enforced.

Document.documentURI

   The location of the document, or "None" if it is unknown.

Document.createDocumentFragment()

   Create and return an empty "DocumentFragment" node.

Document.createCDATASection(data)

   Create and return a "CDATASection" node containing *data*.

Document.importNode(importedNode, deep)

   Return a copy of *importedNode* which belongs to this document. The
   original node is not removed from its document. If *deep* is true,
   the descendants of the node are copied too.

Document.createElement(tagName)

   Create and return a new element node.  The element is not inserted
   into the document when it is created.  You need to explicitly
   insert it with one of the other methods such as "insertBefore()" or
   "appendChild()".

Document.createElementNS(namespaceURI, tagName)

   Create and return a new element with a namespace.  The *tagName*
   may have a prefix.  The element is not inserted into the document
   when it is created.  You need to explicitly insert it with one of
   the other methods such as "insertBefore()" or "appendChild()".

Document.createTextNode(data)

   매개 변수로 전달된 data를 포함하는 텍스트 노드를 만들고 반환합니다.
   다른 생성 메서드와 마찬가지로 이 메서드는 노드를 트리에 삽입하지 않
   습니다.

Document.createComment(data)

   매개 변수로 전달된 data를 포함하는 주석 노드를 만들고 반환합니다.
   다른 생성 메서드와 마찬가지로 이 메서드는 노드를 트리에 삽입하지 않
   습니다.

Document.createProcessingInstruction(target, data)

   매개 변수로 전달된 *target*과 *data*를 포함하는 처리 명령어 노드를
   만들고 반환합니다. 다른 생성 메서드와 마찬가지로 이 메서드는 노드를
   트리에 삽입하지 않습니다.

Document.createAttribute(name)

   Create and return an attribute node.  This method does not
   associate the attribute node with any particular element.  You must
   use "setAttributeNode()" on the appropriate "Element" object to use
   the newly created attribute instance.

Document.createAttributeNS(namespaceURI, qualifiedName)

   Create and return an attribute node with a namespace.  The
   *tagName* may have a prefix.  This method does not associate the
   attribute node with any particular element.  You must use
   "setAttributeNode()" on the appropriate "Element" object to use the
   newly created attribute instance.

Document.getElementById(id)

   Return the element with the given ID, or "None". Only attributes
   declared as being of type ID in the DTD or by
   "Element.setIdAttribute()" are searched.

Document.getElementsByTagName(tagName)

   특정 엘리먼트 형 이름을 가진 모든 자손(직계 자식, 자식의 자식 등)을
   검색합니다.

Document.getElementsByTagNameNS(namespaceURI, localName)

   특정 이름 공간 URI와 지역 이름(localname)을 사용하여 모든 자손(직계
   자식, 자식의 자식 등)을 검색합니다. 지역 이름은 접두사 다음에 나오
   는 이름 공간의 일부입니다.

Document.renameNode(n, namespaceURI, name)

   Rename the element or attribute node *n* and return it.
   *namespaceURI* is the new namespace URI, or "EMPTY_NAMESPACE" if
   the node does not belong to a namespace. *name* is the new
   qualified name.

   Raise "WrongDocumentErr" if *n* was created by another document,
   and "NotSupportedErr" if it is neither an element nor an attribute.


Element 객체
------------

"Element"는 "Node"의 서브 클래스이므로, 모든 어트리뷰트를 상속합니다.

Element.tagName

   엘리먼트 형 이름. 이름 공간을 사용하는 문서에서는 콜론을 포함할 수
   있습니다. 값은 문자열입니다.

Element.setIdAttribute(name)

   Declare that the attribute *name* is of type ID, so that the
   element is found by "Document.getElementById()". Raise
   "NotFoundErr" if the element has no such attribute.

Element.setIdAttributeNS(namespaceURI, localName)

   The same as "setIdAttribute()", but for an attribute specified by
   its namespace URI and local name.

Element.setIdAttributeNode(idAttr)

   The same as "setIdAttribute()", but for an already retrieved
   attribute node.

Element.getElementsByTagName(tagName)

   "Document" 클래스의 동등한 메서드와 같습니다.

Element.getElementsByTagNameNS(namespaceURI, localName)

   "Document" 클래스의 동등한 메서드와 같습니다.

Element.hasAttribute(name)

   엘리먼트에 *name*이라는 이름의 어트리뷰트가 있으면 "True"를 반환합
   니다.

Element.hasAttributeNS(namespaceURI, localName)

   엘리먼트에 *namespaceURI*와 *localName*으로 이름이 지정된 어트리뷰
   트가 있으면 "True"를 반환합니다.

Element.getAttribute(name)

   *name*이라는 이름의 어트리뷰트의 값을 문자열로 반환합니다. 그러한
   어트리뷰트가 없으면, 어트리뷰트에 값이 없는 것처럼 빈 문자열이 반환
   됩니다.

Element.getAttributeNode(attrname)

   *attrname*이라는 이름의 어트리뷰트에 대한 "Attr" 노드를 반환합니다.

Element.getAttributeNS(namespaceURI, localName)

   *namespaceURI*와 *localName*으로 이름이 지정된 어트리뷰트의 값을 문
   자열로 반환합니다. 그러한 어트리뷰트가 없으면, 어트리뷰트에 값이 없
   는 것처럼 빈 문자열이 반환됩니다.

Element.getAttributeNodeNS(namespaceURI, localName)

   *namespaceURI*와 *localName*으로 주어진 어트리뷰트의 값을 노드로 반
   환합니다.

Element.removeAttribute(name)

   Remove an attribute by name.

Element.removeAttributeNode(oldAttr)

   존재하면, 어트리뷰트 목록에서 *oldAttr*를 제거하고 반환합니다.
   *oldAttr*가 없으면 "NotFoundErr"가 발생합니다.

Element.removeAttributeNS(namespaceURI, localName)

   Remove an attribute by name.  Note that it uses a localName, not a
   qname.

Element.setAttribute(name, value)

   문자열로 어트리뷰트 값을 설정합니다.

Element.setAttributeNode(newAttr)

   Add a new attribute node to the element, replacing an existing
   attribute if necessary if the "name" attribute matches.  If a
   replacement occurs, the old attribute node will be returned.  If
   *newAttr* is already in use, "InuseAttributeErr" will be raised.

Element.setAttributeNodeNS(newAttr)

   Add a new attribute node to the element, replacing an existing
   attribute if necessary if the "namespaceURI" and "localName"
   attributes match.  If a replacement occurs, the old attribute node
   will be returned.  If *newAttr* is already in use,
   "InuseAttributeErr" will be raised.

Element.setAttributeNS(namespaceURI, qname, value)

   문자열로 *namespaceURI*와 *qname*으로 지정된 어트리뷰트 값을 설정합
   니다. qname은 전체 어트리뷰트 이름임에 유의하십시오. 이것은 위와 다
   릅니다.


Attr 객체
---------

"Attr"은 "Node"를 상속하므로, 모든 어트리뷰트를 상속합니다.

Attribute nodes are not part of the document tree. They are contained
in the "attributes" map of an element, not in its children, and their
"parentNode", "previousSibling" and "nextSibling" are always "None".

Attr.name

   어트리뷰트 이름. 이름 공간을 사용하는 문서에서는 콜론을 포함할 수
   있습니다.

Attr.localName

   콜론이 있으면 그 뒤에 오는 이름의 일부, 그렇지 않으면 전체 이름. 이
   것은 읽기 전용 어트리뷰트입니다.

Attr.prefix

   콜론이 있으면 그 앞에 오는 이름의 일부, 그렇지 않으면 빈 문자열.

Attr.isId

   Whether this attribute is of type ID, either because it is declared
   as such in the DTD or because "Element.setIdAttribute()" was used.
   This is a read-only attribute.

Attr.ownerElement

   The "Element" node to which this attribute belongs, or "None" if it
   is not used. This is a read-only attribute.

Attr.specified

   Whether the value of the attribute was explicitly set in the
   document, as opposed to being defaulted from the DTD. This is a
   read-only attribute.

Attr.value

   The text value of the attribute.  This is a synonym for the
   "nodeValue" attribute.


NamedNodeMap 객체
-----------------

"NamedNodeMap"은 "Node"를 상속하지 *않습니다*.

NamedNodeMap.length

   어트리뷰트 목록의 길이입니다.

NamedNodeMap.item(index)

   Return an attribute with a particular index.  The order you get the
   attributes in is arbitrary but will be consistent for the life of a
   DOM.  Each item is an attribute node.  Get its value with the
   "value" attribute.

NamedNodeMap.getNamedItem(name)

   Return the node with the given "name", or "None" if there is no
   such node.

NamedNodeMap.getNamedItemNS(namespaceURI, localName)

   Return the node with the given namespace URI and local name, or
   "None" if there is no such node.

NamedNodeMap.setNamedItem(node)

   Add *node* to the map, using its "name" as the key. Return the node
   which it replaces, or "None" if it replaces no node.

NamedNodeMap.setNamedItemNS(node)

   Add *node* to the map, using its namespace URI and local name as
   the key. Return the node which it replaces, or "None" if it
   replaces no node.

NamedNodeMap.removeNamedItem(name)

   Remove and return the node with the given "name". Raise
   "NotFoundErr" if there is no such node.

NamedNodeMap.removeNamedItemNS(namespaceURI, localName)

   Remove and return the node with the given namespace URI and local
   name. Raise "NotFoundErr" if there is no such node.

You can also use the standardized "getAttribute*()" family of methods
on the "Element" objects.


DocumentFragment Objects
------------------------

"DocumentFragment" is a lightweight container of nodes. It is a
subclass of "Node". When it is inserted into the document tree, its
children are inserted instead of it, and it becomes empty.


CharacterData Objects
---------------------

"CharacterData" represents text-like data in the XML document. It is a
subclass of "Node", and the base class of "Text", "CDATASection" and
"Comment". Such nodes cannot have child nodes.

CharacterData.data

   The content of the node as a string.

CharacterData.length

   The number of characters in "data". This is a read-only attribute.

CharacterData.substringData(offset, count)

   Return the substring of "data" of *count* characters starting at
   *offset*.

CharacterData.appendData(arg)

   Append the string *arg* to "data".

CharacterData.insertData(offset, arg)

   Insert the string *arg* into "data" at *offset*.

CharacterData.deleteData(offset, count)

   Remove *count* characters from "data" starting at *offset*.

CharacterData.replaceData(offset, count, arg)

   Replace *count* characters of "data" starting at *offset* with the
   string *arg*.


Comment 객체
------------

"Comment" represents a comment in the XML document. It is a subclass
of "CharacterData".

Comment.data

   주석의 내용을 제공하는 문자열. 이 어트리뷰트는 선행 "<!-""-"와 후행
   "-""->" 사이의 모든 문자를 포함하지만, 이들을 포함하지는 않습니다.


Text와 CDATASection 객체
------------------------

The "Text" interface represents text in the XML document.  If the
parser and DOM implementation support the DOM's XML extension,
portions of the text enclosed in CDATA marked sections are stored in
"CDATASection" objects. These two interfaces are identical, but
provide different values for the "nodeType" attribute.

"Text" extends the "CharacterData" interface, and "CDATASection"
extends "Text".

Text.data

   문자열로 표현된 텍스트 노드의 내용.

Text.wholeText

   The text of all "Text" nodes logically adjacent to this node,
   concatenated in document order. This is a read-only attribute.

Text.replaceWholeText(content)

   Replace the text of all "Text" nodes logically adjacent to this
   node with *content*, removing the other nodes. Return this node, or
   "None" if *content* is empty.

Text.splitText(offset)

   Split this node into two nodes at *offset*, keeping the first part
   in this node and returning a new sibling node with the rest.

참고:

  "CDATASection" 노드의 사용이 그 노드가 완전한 CDATA 표시 섹션을 표현
  한다고 나타내는 것은 아닙니다, 단지 노드의 내용이 CDATA 섹션의 일부
  임을 나타낼 뿐입니다. 단일 CDATA 섹션은 문서 트리에서 둘 이상의 노드
  로 표현될 수 있습니다. 인접한 두 개의 "CDATASection" 노드가 다른
  CDATA 표시 섹션을 나타내는지를 확인할 방법은 없습니다.


ProcessingInstruction 객체
--------------------------

XML 문서의 처리 명령어를 나타냅니다; 이것은 "Node" 인터페이스를 상속하
며 자식 노드를 가질 수 없습니다.

ProcessingInstruction.target

   첫 번째 공백 문자까지의 처리 명령어의 내용. 이것은 읽기 전용 어트리
   뷰트입니다.

ProcessingInstruction.data

   첫 번째 공백 문자 다음에 오는 처리 명령어의 내용.


Entity Objects
--------------

"Entity" represents a parsed or unparsed entity declared in the DTD.
It is a subclass of "Node". Entity nodes are contained in
"DocumentType.entities" and cannot be inserted into the document tree.
The name of the entity is its "nodeName".

Entity.publicId

   The public identifier of the entity, or "None" if it is not
   specified. This is a read-only attribute.

Entity.systemId

   The system identifier of the entity, or "None" if it is not
   specified. This is a read-only attribute.

Entity.notationName

   The name of the notation for an unparsed entity, or "None" for a
   parsed entity. This is a read-only attribute.


Notation Objects
----------------

"Notation" represents a notation declared in the DTD. It is a subclass
of "Node" and cannot have child nodes. Notation nodes are contained in
"DocumentType.notations" and cannot be inserted into the document
tree. The name of the notation is its "nodeName".

Notation.publicId

   The public identifier of the notation, or "None" if it is not
   specified. This is a read-only attribute.

Notation.systemId

   The system identifier of the notation, or "None" if it is not
   specified. This is a read-only attribute.


예외
----

DOM 수준 2 권장 사항은 단일 예외 "DOMException"과 응용 프로그램이 어떤
종류의 에러가 발생했는지 판별하도록 하는 여러 상수를 정의합니다.
"DOMException" 인스턴스에는 구체적인 예외에 적절한 값을 제공하는
"code" 어트리뷰트가 있습니다.

파이썬 DOM 인터페이스는 상수를 제공하지만, 동시에 예외 집합을 확장하여
DOM에 의해 정의된 각 예외 코드마다 구체적인 예외가 존재하도록 합니다.
구현 시 적절한 구체적인 예외를 발생시켜야 하며, 각 예외는 "code" 속성
으로 적절한 값을 제공합니다.

exception xml.dom.DOMException

   모든 구체적인 DOM 예외에 사용되는 베이스 예외 클래스. 이 예외 클래
   스는 직접 인스턴스 화할 수 없습니다.

exception xml.dom.DomstringSizeErr

   지정된 텍스트 범위가 문자열에 맞지 않을 때 발생합니다. 이것은 파이
   썬 DOM 구현에서 사용되는 것으로 알려지지 않았지만, 파이썬으로 작성
   되지 않은 DOM 구현에서 수신될 수 있습니다.

exception xml.dom.HierarchyRequestErr

   노드 형이 허용하지 않는 곳에 노드를 삽입하려고 할 때 발생합니다.

exception xml.dom.IndexSizeErr

   메서드의 인덱스(index)나 크기(size) 매개 변수가 음수이거나 허용된
   값을 초과할 때 발생합니다.

exception xml.dom.InuseAttributeErr

   문서의 다른 곳에 이미 존재하는 "Attr" 노드를 삽입하려고 할 때 발생
   합니다.

exception xml.dom.InvalidAccessErr

   하부 객체에서 매개 변수나 연산이 지원되지 않으면 발생합니다.

exception xml.dom.InvalidCharacterErr

   이 예외는 문자열 매개 변수에 XML 1.0 권장 사항에서 사용 중인 컨텍스
   트에서 허용되지 않는 문자가 포함될 때 발생합니다. 예를 들어, 엘리먼
   트 형 이름에 스페이스가 있는 "Element" 노드를 만들려고 하면 이 에러
   가 발생합니다.

exception xml.dom.InvalidModificationErr

   노드 형을 수정하려고 할 때 발생합니다.

exception xml.dom.InvalidStateErr

   정의되지 않았거나 더는 사용할 수 없는 객체를 사용하려고 할 때 발생
   합니다.

exception xml.dom.NamespaceErr

   Namespaces in XML 권장 사항에서 허용되지 않는 방식으로 객체를 변경
   하려고 시도하면 이 예외가 발생합니다.

exception xml.dom.NotFoundErr

   참조된 컨텍스트에 노드가 존재하지 않을 때 발생하는 예외. 예를 들어,
   "NamedNodeMap.removeNamedItem()"은 전달된 노드가 맵에 존재하지 않으
   면 이것을 발생시킵니다.

exception xml.dom.NotSupportedErr

   구현이 요청된 형의 객체나 연산을 지원하지 않을 때 발생합니다.

exception xml.dom.NoDataAllowedErr

   데이터를 지원하지 않는 노드에 데이터가 지정되면 발생합니다.

exception xml.dom.NoModificationAllowedErr

   수정이 허용되지 않는 객체(가령 읽기 전용 노드)를 수정하려고 하면 발
   생합니다.

exception xml.dom.SyntaxErr

   유효하지 않거나 잘못된 문자열이 지정될 때 발생합니다.

exception xml.dom.ValidationErr

   Raised when an operation would make the document invalid with
   respect to partial validity. This is not known to be used in the
   Python DOM implementations, but may be received from DOM
   implementations not written in Python.

exception xml.dom.WrongDocumentErr

   노드가 현재 속한 것과 다른 문서에 삽입되고 구현이 한 문서에서 다른
   문서로 노드 이전을 지원하지 않을 때 발생합니다.

DOM 권장 사항에 정의된 예외 코드는 이 테이블에 따라 위에서 설명한 예외
에 매핑됩니다:

+-----------------------------------------+-----------------------------------+
| 상수                                    | 예외                              |
|=========================================|===================================|
| xml.dom.DOMSTRING_SIZE_ERR              | "DomstringSizeErr"                |
+-----------------------------------------+-----------------------------------+
| xml.dom.HIERARCHY_REQUEST_ERR           | "HierarchyRequestErr"             |
+-----------------------------------------+-----------------------------------+
| xml.dom.INDEX_SIZE_ERR                  | "IndexSizeErr"                    |
+-----------------------------------------+-----------------------------------+
| xml.dom.INUSE_ATTRIBUTE_ERR             | "InuseAttributeErr"               |
+-----------------------------------------+-----------------------------------+
| xml.dom.INVALID_ACCESS_ERR              | "InvalidAccessErr"                |
+-----------------------------------------+-----------------------------------+
| xml.dom.INVALID_CHARACTER_ERR           | "InvalidCharacterErr"             |
+-----------------------------------------+-----------------------------------+
| xml.dom.INVALID_MODIFICATION_ERR        | "InvalidModificationErr"          |
+-----------------------------------------+-----------------------------------+
| xml.dom.INVALID_STATE_ERR               | "InvalidStateErr"                 |
+-----------------------------------------+-----------------------------------+
| xml.dom.NAMESPACE_ERR                   | "NamespaceErr"                    |
+-----------------------------------------+-----------------------------------+
| xml.dom.NOT_FOUND_ERR                   | "NotFoundErr"                     |
+-----------------------------------------+-----------------------------------+
| xml.dom.NOT_SUPPORTED_ERR               | "NotSupportedErr"                 |
+-----------------------------------------+-----------------------------------+
| xml.dom.NO_DATA_ALLOWED_ERR             | "NoDataAllowedErr"                |
+-----------------------------------------+-----------------------------------+
| xml.dom.NO_MODIFICATION_ALLOWED_ERR     | "NoModificationAllowedErr"        |
+-----------------------------------------+-----------------------------------+
| xml.dom.SYNTAX_ERR                      | "SyntaxErr"                       |
+-----------------------------------------+-----------------------------------+
| xml.dom.VALIDATION_ERR                  | "ValidationErr"                   |
+-----------------------------------------+-----------------------------------+
| xml.dom.WRONG_DOCUMENT_ERR              | "WrongDocumentErr"                |
+-----------------------------------------+-----------------------------------+


규격 준수
=========

이 섹션에서는 규격 준수 요구 사항과 파이썬 DOM API, W3C DOM 권장 사항
및 파이썬의 OMG IDL 매핑 간의 관계에 관해 설명합니다.


형 매핑
-------

DOM 명세에 사용된 IDL 형은 다음 표에 따라 파이썬 형에 매핑됩니다.

+--------------------+---------------------------------------------+
| IDL 형             | 파이썬 형                                   |
|====================|=============================================|
| "boolean"          | "bool" 또는 "int"                           |
+--------------------+---------------------------------------------+
| "int"              | "int"                                       |
+--------------------+---------------------------------------------+
| "long int"         | "int"                                       |
+--------------------+---------------------------------------------+
| "unsigned int"     | "int"                                       |
+--------------------+---------------------------------------------+
| "DOMString"        | "str" 또는 "bytes"                          |
+--------------------+---------------------------------------------+
| "null"             | "None"                                      |
+--------------------+---------------------------------------------+


접근자 메서드
-------------

OMG IDL에서 파이썬으로의 매핑은 Java 매핑과 거의 같은 방식으로 IDL
"attribute" 선언에 대한 접근자 함수를 정의합니다. 다음과 같은 IDL 선언
매핑은:

   readonly attribute string someValue;
            attribute string anotherValue;

yields three accessor functions:  a "get" method for "someValue"
("_get_someValue()"), and "get" and "set" methods for "anotherValue"
("_get_anotherValue()" and "_set_anotherValue()").  The mapping, in
particular, does not require that the IDL attributes are accessible as
normal Python attributes:  "object.someValue" is *not* required to
work, and may raise an "AttributeError".

그러나, 파이썬 DOM API는 일반 어트리뷰트 액세스가 동작하도록 *요구합니
다*. 이것은 파이썬 IDL 컴파일러에 의해 생성된 일반적인 서로게이트가 작
동하지 않을 수 있으며, DOM 객체가 CORBA를 통해 액세스되는 경우 래퍼 객
체가 클라이언트에 필요할 수 있음을 의미합니다. CORBA DOM 클라이언트에
대해 추가적인 고려가 필요하지만, 파이썬에서 CORBA를 통해 DOM을 사용한
경험이 있는 구현자들은 이것을 문제라고 보지 않습니다. "readonly"로 선
언된 어트리뷰트는 모든 DOM 구현에서 쓰기 액세스를 제한하지 않을 수 있
습니다.

파이썬 DOM API에서는, 접근자 함수가 필요하지 않습니다. 제공되면, 파이
썬 IDL 매핑으로 정의된 형식을 취해야 하지만, 어트리뷰트를 파이썬에서
직접 액세스할 수 있어서 이러한 메서드들은 불필요한 것으로 간주합니다.
"readonly" 어트리뷰트에 "set" 접근자를 제공해서는 안 됩니다.

The IDL definitions do not fully embody the requirements of the W3C
DOM API, such as the notion of certain objects, such as the return
value of "getElementsByTagName()", being "live".  The Python DOM API
does not require implementations to enforce such requirements.
