Class

NSXMLDocument

An XML document as internalized into a logical tree structure. 論理ツリー構造への内面化としてのXML文書。

Declaration 宣言

@interface NSXMLDocument : NSXMLNode

Overview 概要

An NSXMLDocument object can have multiple child nodes but only one element, the root element. Any other node must be a NSXMLNode object representing a comment or a processing instruction. If you attempt to add any other kind of child node to an NSXMLDocument object, such as an attribute, namespace, another document object, or an element other than the root, NSXMLDocument raises an exception. If you add a valid child node and that object already has a parent, NSXMLDocument raises an exception. An NSXMLDocument object may also have document-global attributes, such as XML version, character encoding, referenced DTD, and MIME type. NSXMLDocumentオブジェクトは、複数の子ノードを持つことが出来ます、しかしただ1つの要素、ルート要素を除いては。なんらかの他のノードは、あるNSXMLNodeオブジェクトで、あるコメントまたは処理命令を表していなければなりません。あなたが何か他の種類の子ノードをNSXMLDocumentオブジェクトに加えようと試みるならば、たとえば属性、名前空間、別の書類オブジェクト、またはルート以外のある要素など、 NSXMLDocumentは例外を引き起こします。あなたが有効な子ノードを加えてそのオブジェクトが既にある親を持つならば、NSXMLDocumentは例外を引き起こします。NSXMLDocumentオブジェクトはまた、文書にグローバルな属性、たとえばXMLバージョン、文字符号化、参照DTD、そしてMIMEタイプなどを持つかもしれません。

The initializers of the NSXMLDocument class read an external source of XML, whether it be a local file or remote website, parse it, and process it into the tree representation. You can also construct an NSXMLDocument programmatically. There are accessor methods for getting and setting document attributes, methods for transforming documents using XSLT, a method for dynamically validating a document, and methods for printing out the content of an NSXMLDocument as XML, XHTML, HTML, or plain text. NSXMLDocumentクラスのイニシャライザは、XMLの外部ソースを読み込みます、それがローカルファイルまたはリモートウェブサイトであろうとなかろうと、そしてそれをツリー表現へと加工処理します。あなたはまた、NSXMLDocumentをプログラム的に組み立てられます。書類属性を取得及び設定するためのアクセッサメソッド、XSLTを使った文書変形のためのメソッド、動的に文書を検証するためのメソッド、そしてNSXMLDocumentの内容をXML、XHTML、HTML、またはプレーンテキストとして出力するためのメソッドがあります。

The NSXMLDocument class is thread-safe as long as any given instance is used only in one thread. NSXMLDocumentクラスは、スレッド安全です、どんなインスタンスであれ1つのスレッドの中でのみ使われる限りは。

Subclassing Notes サブクラス作成の注意

Methods to Override メソッドのオーバーライド

To subclass NSXMLDocument you need to override the primary initializer, initWithData:options:error:, and the methods listed below. In most cases, you need only invoke the superclass implementation, adding any subclass-specific code before or after the invocation, as necessary. NSXMLDocumentのサブクラスを作るためにあなたは主要イニシャライザ、initWithData:options:error:、および下で一覧にされるメソッドをオーバーライドしなければなりません。ほとんどの場合には、あなたはスーパークラス実装の発動だけが必要です、何らかのサブクラス特有コードをその発動の前または後に加えます、必要に応じて。

By default NSXMLDocument implements the NSObject isEqual: method to perform a deep comparison: two NSXMLDocument objects are not considered equal unless they have the same name, same child nodes, same attributes, and so on. The comparison does not consider the parent node (and hence the node’s location). If you want a different standard of comparison, override isEqual:. 初期状態でNSXMLDocumentNSObjectisEqual:メソッドを実装して、ある深い比較を実行します:2つのNSXMLDocumentオブジェクトは等しいとみなされません、それらが同じ名前、同じ子ノード、同じ属性、などを持たない限り。比較は、親ノードを考慮しません(そしてそれゆえそのノードのもつ位置を)。あなたが比較の異なる標準を望むならば、isEqual:をオーバーライドしてください。

Special Considerations 特別な注意事項

Because of the architecture and data model of NSXML, when it parses and processes a source of XML it cannot know about your subclass unless you override the class method replacementClassForClass: to return your custom class in place of an NSXML class. If your custom class has no direct NSXML counterpart—for example, it is a subclass of NSXMLNode that represents CDATA sections—then you can walk the tree after it has been created and insert the new node where appropriate. NSXMLのアーキテクチャとデータモデルが原因で、それがXMLのソースを構文解析して処理する時にそれはあなたのサブクラスについて知ることはできません、もしあなたがクラスメソッドreplacementClassForClass:をオーバーライドしてあなたのあつらえのクラスをNSXMLクラスの代わりに返すのでなければ。あなたのあつらえのクラスが直接のNSXML相当物を持たないならば — 例えば、それが、NSXMLNodeのサブクラスであり、CDATAセクションを表している — そのときあなたはツリーをそれが作成された後に歩いて行って(walk)、新しいノードを適切なところに挿入できます。

Topics 話題

Initializing NSXMLDocument Objects NSXMLDocumentオブジェクトを初期化する

Managing Document Attributes 文書属性を管理する

Managing the Root Element ルート要素を管理する

Adding and Removing Child Nodes 子ノードの追加と除去

Transforming a Document Using XSLT ある書類をXSLTを使って変換する

Writing a Document as XML Data 書類をXMLデータとして書き出す

Validating a Document 書類を検証する

Constants 定数

Initializers イニシャライザ

Relationships 関係

Inherits From 継承元

See Also 参照

Tree-Based Processing ツリー基盤の処理