# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # python-doc bot, 2025 # Cheesecake, 2025 # Takanori Suzuki , 2026 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.15\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-09-15 17:49+0000\n" "PO-Revision-Date: 2025-09-16 00:02+0000\n" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/xml.etree.elementtree.rst:2 msgid ":mod:`!xml.etree.ElementTree` --- The ElementTree XML API" msgstr ":mod:`!xml.etree.ElementTree` --- ElementTree XML API" #: ../../library/xml.etree.elementtree.rst:7 msgid "**Source code:** :source:`Lib/xml/etree/ElementTree.py`" msgstr "**Source code:** :source:`Lib/xml/etree/ElementTree.py`" #: ../../library/xml.etree.elementtree.rst:11 msgid "" "The :mod:`!xml.etree.ElementTree` module implements a simple and efficient " "API for parsing and creating XML data." msgstr "" #: ../../library/xml.etree.elementtree.rst:14 msgid "This module will use a fast implementation whenever available." msgstr "このモジュールは利用出来る場合は常に高速な実装を使用します。" #: ../../library/xml.etree.elementtree.rst:17 msgid "The :mod:`!xml.etree.cElementTree` alias of this module is deprecated." msgstr "" #: ../../library/xml.etree.elementtree.rst:23 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "" #: ../../library/xml.etree.elementtree.rst:27 msgid "Tutorial" msgstr "チュートリアル" #: ../../library/xml.etree.elementtree.rst:29 msgid "" "This is a short tutorial for using :mod:`!xml.etree.ElementTree` (``ET`` in " "short). The goal is to demonstrate some of the building blocks and basic " "concepts of the module." msgstr "" #: ../../library/xml.etree.elementtree.rst:34 msgid "XML tree and elements" msgstr "XML 木構造と要素" #: ../../library/xml.etree.elementtree.rst:36 msgid "" "XML is an inherently hierarchical data format, and the most natural way to " "represent it is with a tree. ``ET`` has two classes for this purpose - :" "class:`ElementTree` represents the whole XML document as a tree, and :class:" "`Element` represents a single node in this tree. Interactions with the " "whole document (reading and writing to/from files) are usually done on the :" "class:`ElementTree` level. Interactions with a single XML element and its " "sub-elements are done on the :class:`Element` level." msgstr "" "XML は本質的に階層データ形式で、木構造で表すのが最も自然な方法です。``ET`` は" "この目的のために 2 つのクラス - XML 文書全体を木で表す :class:`ElementTree` " "および木構造内の単一ノードを表す :class:`Element` - を持っています。文書全体" "とのやりとり (ファイルの読み書き) は通常 :class:`ElementTree` レベルで行いま" "す。単一 XML 要素およびその子要素とのやりとりは :class:`Element` レベルで行い" "ます。" #: ../../library/xml.etree.elementtree.rst:47 msgid "Parsing XML" msgstr "XML の解析" #: ../../library/xml.etree.elementtree.rst:49 msgid "" "We'll be using the fictive :file:`country_data.xml` XML document as the " "sample data for this section:" msgstr "" #: ../../library/xml.etree.elementtree.rst:51 msgid "" "\n" "\n" " \n" " 1\n" " 2008\n" " 141100\n" " \n" " \n" " \n" " \n" " 4\n" " 2011\n" " 59900\n" " \n" " \n" " \n" " 68\n" " 2011\n" " 13600\n" " \n" " \n" " \n" "" msgstr "" "\n" "\n" " \n" " 1\n" " 2008\n" " 141100\n" " \n" " \n" " \n" " \n" " 4\n" " 2011\n" " 59900\n" " \n" " \n" " \n" " 68\n" " 2011\n" " 13600\n" " \n" " \n" " \n" "" #: ../../library/xml.etree.elementtree.rst:77 msgid "We can import this data by reading from a file::" msgstr "ファイルを読み込むことでこのデータをインポートすることが出来ます::" #: ../../library/xml.etree.elementtree.rst:79 msgid "" "import xml.etree.ElementTree as ET\n" "tree = ET.parse('country_data.xml')\n" "root = tree.getroot()" msgstr "" #: ../../library/xml.etree.elementtree.rst:83 msgid "Or directly from a string::" msgstr "文字列から直接インポートすることも出来ます::" #: ../../library/xml.etree.elementtree.rst:85 msgid "root = ET.fromstring(country_data_as_string)" msgstr "" #: ../../library/xml.etree.elementtree.rst:87 msgid "" ":func:`fromstring` parses XML from a string directly into an :class:" "`Element`, which is the root element of the parsed tree. Other parsing " "functions may create an :class:`ElementTree`. Check the documentation to be " "sure." msgstr "" ":func:`fromstring` は XML を文字列から :class:`Element` に直接パースします。:" "class:`Element` はパースされた木のルート要素です。他のパース関数は :class:" "`ElementTree` を作成するかもしれません。ドキュメントをきちんと確認してくださ" "い。" #: ../../library/xml.etree.elementtree.rst:91 msgid "" "As an :class:`Element`, ``root`` has a tag and a dictionary of attributes::" msgstr ":class:`Element` として、``root`` はタグと属性の辞書を持ちます::" #: ../../library/xml.etree.elementtree.rst:93 msgid "" ">>> root.tag\n" "'data'\n" ">>> root.attrib\n" "{}" msgstr "" #: ../../library/xml.etree.elementtree.rst:98 msgid "It also has children nodes over which we can iterate::" msgstr "さらにイテレート可能な子ノードも持ちます::" #: ../../library/xml.etree.elementtree.rst:100 msgid "" ">>> for child in root:\n" "... print(child.tag, child.attrib)\n" "...\n" "country {'name': 'Liechtenstein'}\n" "country {'name': 'Singapore'}\n" "country {'name': 'Panama'}" msgstr "" #: ../../library/xml.etree.elementtree.rst:107 msgid "Children are nested, and we can access specific child nodes by index::" msgstr "" "子ノードは入れ子になっており、インデックスで子ノードを指定してアクセスできま" "す::" #: ../../library/xml.etree.elementtree.rst:109 msgid "" ">>> root[0][1].text\n" "'2008'" msgstr "" #: ../../library/xml.etree.elementtree.rst:115 msgid "" "Not all elements of the XML input will end up as elements of the parsed " "tree. Currently, this module skips over any XML comments, processing " "instructions, and document type declarations in the input. Nevertheless, " "trees built using this module's API rather than parsing from XML text can " "have comments and processing instructions in them; they will be included " "when generating XML output. A document type declaration may be accessed by " "passing a custom :class:`TreeBuilder` instance to the :class:`XMLParser` " "constructor." msgstr "" "XML 入力の全ての要素が、パース後の木に要素として含まれる訳ではありません。現" "在、このモジュールは入力中のいかなる XML コメント、処理命令、ドキュメントタイ" "プ宣言も読み飛ばします。しかし、XML テキストからのパースではなく、このモ" "ジュールの API を使用して構築された木には、コメントや処理命令を含むことがで" "き、それらは XML 出力の生成時に含まれます。ドキュメントタイプ宣言は、 :class:" "`XMLParser` コンストラクタにカスタムの :class:`TreeBuilder` インスタンスを渡" "すことで、アクセスすることができます。" #: ../../library/xml.etree.elementtree.rst:129 msgid "Pull API for non-blocking parsing" msgstr "非ブロックパースのためのプル API" #: ../../library/xml.etree.elementtree.rst:131 msgid "" "Most parsing functions provided by this module require the whole document to " "be read at once before returning any result. It is possible to use an :" "class:`XMLParser` and feed data into it incrementally, but it is a push API " "that calls methods on a callback target, which is too low-level and " "inconvenient for most needs. Sometimes what the user really wants is to be " "able to parse XML incrementally, without blocking operations, while enjoying " "the convenience of fully constructed :class:`Element` objects." msgstr "" "このモジュールが提供するパース関数のほとんどは、結果を返す前に、ドキュメント" "全体を読む必要があります。 :class:`XMLParser` を使用して、インクリメンタルに" "データを渡すことは可能ではありますが、それはコールバック対象のメソッドを呼ぶ" "プッシュ API であり、多くの場合、低水準すぎて不便です。ユーザーが望むのは、完" "全に出来上がった :class:`Element` オブジェクトを便利に使いながら、操作をブ" "ロックすることなく XML のパースをインクリメンタルに行えることです。" #: ../../library/xml.etree.elementtree.rst:139 msgid "" "The most powerful tool for doing this is :class:`XMLPullParser`. It does " "not require a blocking read to obtain the XML data, and is instead fed with " "data incrementally with :meth:`XMLPullParser.feed` calls. To get the parsed " "XML elements, call :meth:`XMLPullParser.read_events`. Here is an example::" msgstr "" "これを行うための最も強力なツールは、 :class:`XMLPullParser` です。XML データ" "を取得するためにブロックするような読み込みは必要なく、 :meth:`XMLPullParser." "feed` を呼び出して、インクリメンタルにデータを読みます。パースされた XML 要素" "を取得するには、:meth:`XMLPullParser.read_events` を呼び出します。以下に、例" "を示します。" #: ../../library/xml.etree.elementtree.rst:144 msgid "" ">>> parser = ET.XMLPullParser(['start', 'end'])\n" ">>> parser.feed('sometext')\n" ">>> list(parser.read_events())\n" "[('start', )]\n" ">>> parser.feed(' more text')\n" ">>> for event, elem in parser.read_events():\n" "... print(event)\n" "... print(elem.tag, 'text=', elem.text)\n" "...\n" "end\n" "mytag text= sometext more text" msgstr "" #: ../../library/xml.etree.elementtree.rst:156 msgid "" "The obvious use case is applications that operate in a non-blocking fashion " "where the XML data is being received from a socket or read incrementally " "from some storage device. In such cases, blocking reads are unacceptable." msgstr "" "これの分かりやすい用途は、XML データをソケットから受信したり、ストレージデバ" "イスからインクリメンタルに読み出したりするような、非ブロック式に動作するアプ" "リケーションです。このような場合、ブロッキング読み出しは使用できません。" #: ../../library/xml.etree.elementtree.rst:160 msgid "" "Because it's so flexible, :class:`XMLPullParser` can be inconvenient to use " "for simpler use-cases. If you don't mind your application blocking on " "reading XML data but would still like to have incremental parsing " "capabilities, take a look at :func:`iterparse`." msgstr "" #: ../../library/xml.etree.elementtree.rst:165 msgid "" "Note that both parsers build the tree incrementally: it is not freed " "incrementally, so every parsed element is kept until the whole document is " "read. To keep the memory usage low, get rid of the data which is not needed " "any more." msgstr "" #: ../../library/xml.etree.elementtree.rst:170 msgid "" "If the processed elements are large, it is enough to clear them. This works " "wherever they are in the tree, but the emptied elements are left in it::" msgstr "" #: ../../library/xml.etree.elementtree.rst:174 msgid "" "for event, elem in ET.iterparse(source):\n" " if elem.tag == 'record':\n" " process(elem)\n" " elem.clear()" msgstr "" #: ../../library/xml.etree.elementtree.rst:179 msgid "" "If an element has a large number of children, remove the processed children " "from it::" msgstr "" #: ../../library/xml.etree.elementtree.rst:182 msgid "" "for event, elem in ET.iterparse(source, events=('start', 'end')):\n" " if event == 'start' and elem.tag == 'parent':\n" " parent = elem\n" " elif event == 'end' and elem.tag == 'child':\n" " process(elem)\n" " parent.remove(elem)" msgstr "" #: ../../library/xml.etree.elementtree.rst:189 msgid "" "These examples are not universal, they only give an idea for two common " "cases. If you do not need a tree at all, parse with :class:`XMLParser` and a " "custom target instead; it is not built then, and nothing has to be removed." msgstr "" #: ../../library/xml.etree.elementtree.rst:195 msgid "" "Where *immediate* feedback through events is wanted, calling method :meth:" "`XMLPullParser.flush` can help reduce delay; please make sure to study the " "related security notes." msgstr "" #: ../../library/xml.etree.elementtree.rst:201 msgid "Finding interesting elements" msgstr "関心ある要素の検索" #: ../../library/xml.etree.elementtree.rst:203 msgid "" ":class:`Element` has some useful methods that help iterate recursively over " "all the sub-tree below it (its children, their children, and so on). For " "example, :meth:`Element.iter`::" msgstr "" ":class:`Element` は、例えば、:meth:`Element.iter` などの、配下 (その子ノード" "や孫ノードなど) の部分木全体を再帰的にイテレートするいくつかの役立つメソッド" "を持っています::" #: ../../library/xml.etree.elementtree.rst:207 msgid "" ">>> for neighbor in root.iter('neighbor'):\n" "... print(neighbor.attrib)\n" "...\n" "{'name': 'Austria', 'direction': 'E'}\n" "{'name': 'Switzerland', 'direction': 'W'}\n" "{'name': 'Malaysia', 'direction': 'N'}\n" "{'name': 'Costa Rica', 'direction': 'W'}\n" "{'name': 'Colombia', 'direction': 'E'}" msgstr "" #: ../../library/xml.etree.elementtree.rst:216 msgid "" ":meth:`Element.findall` finds only elements with a tag which are direct " "children of the current element. :meth:`Element.find` finds the *first* " "child with a particular tag, and :attr:`Element.text` accesses the element's " "text content. :meth:`Element.get` accesses the element's attributes::" msgstr "" ":meth:`Element.findall` はタグで現在の要素の直接の子要素のみ検索します。 :" "meth:`Element.find` は特定のタグで *最初の* 子要素を検索し、 :attr:`Element." "text` は要素のテキストコンテンツにアクセスします。 :meth:`Element.get` は要素" "の属性にアクセスします::" #: ../../library/xml.etree.elementtree.rst:221 msgid "" ">>> for country in root.findall('country'):\n" "... rank = country.find('rank').text\n" "... name = country.get('name')\n" "... print(name, rank)\n" "...\n" "Liechtenstein 1\n" "Singapore 4\n" "Panama 68" msgstr "" #: ../../library/xml.etree.elementtree.rst:230 msgid "" "More sophisticated specification of which elements to look for is possible " "by using :ref:`XPath `." msgstr "" ":ref:`XPath ` を使用すると、より洗練された方法で、検索した" "い要素を指定することができます。" #: ../../library/xml.etree.elementtree.rst:234 msgid "Modifying an XML File" msgstr "XML ファイルの編集" #: ../../library/xml.etree.elementtree.rst:236 msgid "" ":class:`ElementTree` provides a simple way to build XML documents and write " "them to files. The :meth:`ElementTree.write` method serves this purpose." msgstr "" ":class:`ElementTree` は XML 文書を構築してファイルに出力する簡単な方法を提供" "しています。:meth:`ElementTree.write` メソッドはこの目的に適います。" #: ../../library/xml.etree.elementtree.rst:239 msgid "" "Once created, an :class:`Element` object may be manipulated by directly " "changing its fields (such as :attr:`Element.text`), adding and modifying " "attributes (:meth:`Element.set` method), as well as adding new children (for " "example with :meth:`Element.append`)." msgstr "" ":class:`Element` オブジェクトを作成すると、そのフィールドの直接変更 (:attr:" "`Element.text` など) や、属性の追加および変更 (:meth:`Element.set` メソッ" "ド)、あるいは新しい子ノードの追加 (例えば :meth:`Element.append` など) によっ" "てそれを操作できます。" #: ../../library/xml.etree.elementtree.rst:244 msgid "" "Let's say we want to add one to each country's rank, and add an ``updated`` " "attribute to the rank element::" msgstr "" "例えば各 country の rank に 1 を足して、rank 要素に ``updated`` 属性を追加し" "たい場合::" #: ../../library/xml.etree.elementtree.rst:247 msgid "" ">>> for rank in root.iter('rank'):\n" "... new_rank = int(rank.text) + 1\n" "... rank.text = str(new_rank)\n" "... rank.set('updated', 'yes')\n" "...\n" ">>> tree.write('output.xml')" msgstr "" #: ../../library/xml.etree.elementtree.rst:254 #: ../../library/xml.etree.elementtree.rst:298 msgid "Our XML now looks like this:" msgstr "XML はこのようになります:" #: ../../library/xml.etree.elementtree.rst:256 msgid "" "\n" "\n" " \n" " 2\n" " 2008\n" " 141100\n" " \n" " \n" " \n" " \n" " 5\n" " 2011\n" " 59900\n" " \n" " \n" " \n" " 69\n" " 2011\n" " 13600\n" " \n" " \n" " \n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:282 msgid "" "We can remove elements using :meth:`Element.remove`. Let's say we want to " "remove all countries with a rank higher than 50::" msgstr "" ":meth:`Element.remove` を使って要素を削除することが出来ます。例えば rank が " "50 より大きい全ての country を削除したい場合::" #: ../../library/xml.etree.elementtree.rst:285 msgid "" ">>> for country in root.findall('country'):\n" "... # using root.findall() to avoid removal during traversal\n" "... rank = int(country.find('rank').text)\n" "... if rank > 50:\n" "... root.remove(country)\n" "...\n" ">>> tree.write('output.xml')" msgstr "" #: ../../library/xml.etree.elementtree.rst:293 msgid "" "Note that concurrent modification while iterating can lead to problems, just " "like when iterating and modifying Python lists or dicts. Therefore, the " "example first collects all matching elements with ``root.findall()``, and " "only then iterates over the list of matches." msgstr "" #: ../../library/xml.etree.elementtree.rst:300 msgid "" "\n" "\n" " \n" " 2\n" " 2008\n" " 141100\n" " \n" " \n" " \n" " \n" " 5\n" " 2011\n" " 59900\n" " \n" " \n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:320 msgid "Building XML documents" msgstr "XML 文書の構築" #: ../../library/xml.etree.elementtree.rst:322 msgid "" "The :func:`SubElement` function also provides a convenient way to create new " "sub-elements for a given element::" msgstr "" ":func:`SubElement` 関数は、与えられた要素に新しい子要素を作成する便利な手段も" "提供しています::" #: ../../library/xml.etree.elementtree.rst:325 msgid "" ">>> a = ET.Element('a')\n" ">>> b = ET.SubElement(a, 'b')\n" ">>> c = ET.SubElement(a, 'c')\n" ">>> d = ET.SubElement(c, 'd')\n" ">>> ET.dump(a)\n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:333 msgid "Parsing XML with Namespaces" msgstr "名前空間のある XML の解析" #: ../../library/xml.etree.elementtree.rst:335 msgid "" "If the XML input has `namespaces `__, tags and attributes with prefixes in the form ``prefix:" "sometag`` get expanded to ``{uri}sometag`` where the *prefix* is replaced by " "the full *URI*. Also, if there is a `default namespace `__, that full URI gets prepended to all of the non-" "prefixed tags." msgstr "" "XML 入力が `名前空間 `__ を持っ" "ている場合、 ``prefix:sometag`` の形式で修飾されたタグと属性が、その " "*prefix* が完全な *URI* で置換された ``{uri}sometag`` の形に展開されます。さ" "らに、 `デフォルトの XML 名前空間 `__ があると、修飾されていない全てのタグにその完全 URI が前置され" "ます。" #: ../../library/xml.etree.elementtree.rst:343 msgid "" "Here is an XML example that incorporates two namespaces, one with the prefix " "\"fictional\" and the other serving as the default namespace:" msgstr "" "ひとつは接頭辞 \"fictional\" でもうひとつがデフォルト名前空間で提供された、 " "2 つの名前空間を組み込んだ XML の例をここにお見せします:" #: ../../library/xml.etree.elementtree.rst:346 msgid "" "\n" "\n" " \n" " John Cleese\n" " Lancelot\n" " Archie Leach\n" " \n" " \n" " Eric Idle\n" " Sir Robin\n" " Gunther\n" " Commander Clement\n" " \n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:364 msgid "" "One way to search and explore this XML example is to manually add the URI to " "every tag or attribute in the xpath of a :meth:`~Element.find` or :meth:" "`~Element.findall`::" msgstr "" "この XML の例を、検索し、渡り歩くためのひとつの方法としては、 :meth:" "`~Element.find` や :meth:`~Element.findall` に渡す xpath で全てのタグや属性に" "手作業で URI を付けてまわる手があります::" #: ../../library/xml.etree.elementtree.rst:368 msgid "" "root = fromstring(xml_text)\n" "for actor in root.findall('{http://people.example.com}actor'):\n" " name = actor.find('{http://people.example.com}name')\n" " print(name.text)\n" " for char in actor.findall('{http://characters.example.com}character'):\n" " print(' |-->', char.text)" msgstr "" #: ../../library/xml.etree.elementtree.rst:375 msgid "" "A better way to search the namespaced XML example is to create a dictionary " "with your own prefixes and use those in the search functions::" msgstr "" "もっと良い方法があります。接頭辞の辞書を作り、これを検索関数で使うことです::" #: ../../library/xml.etree.elementtree.rst:378 msgid "" "ns = {'real_person': 'http://people.example.com',\n" " 'role': 'http://characters.example.com'}\n" "\n" "for actor in root.findall('real_person:actor', ns):\n" " name = actor.find('real_person:name', ns)\n" " print(name.text)\n" " for char in actor.findall('role:character', ns):\n" " print(' |-->', char.text)" msgstr "" #: ../../library/xml.etree.elementtree.rst:387 msgid "These two approaches both output::" msgstr "どちらのアプローチでも同じ結果です::" #: ../../library/xml.etree.elementtree.rst:389 msgid "" "John Cleese\n" " |--> Lancelot\n" " |--> Archie Leach\n" "Eric Idle\n" " |--> Sir Robin\n" " |--> Gunther\n" " |--> Commander Clement" msgstr "" #: ../../library/xml.etree.elementtree.rst:401 msgid "XPath support" msgstr "XPath サポート" #: ../../library/xml.etree.elementtree.rst:403 msgid "" "This module provides limited support for `XPath expressions `_ for locating elements in a tree. The goal is to support a " "small subset of the abbreviated syntax; a full XPath engine is outside the " "scope of the module." msgstr "" "このモジュールは木構造内の要素の位置決めのための `XPath 式 `_ を限定的にサポートしています。その目指すところは短縮構文のほ" "んの一部だけのサポートであり、XPath エンジンのフルセットは想定していません。" #: ../../library/xml.etree.elementtree.rst:409 #: ../../library/xml.etree.elementtree.rst:822 msgid "Example" msgstr "使用例" #: ../../library/xml.etree.elementtree.rst:411 msgid "" "Here's an example that demonstrates some of the XPath capabilities of the " "module. We'll be using the ``countrydata`` XML document from the :ref:" "`Parsing XML ` section::" msgstr "" "以下はこのモジュールの XPath 機能の一部を紹介する例です。:ref:`XML の解析 " "` 節から XML 文書 ``countrydata`` を使用します::" #: ../../library/xml.etree.elementtree.rst:415 msgid "" "import xml.etree.ElementTree as ET\n" "\n" "root = ET.fromstring(countrydata)\n" "\n" "# Top-level elements\n" "root.findall(\".\")\n" "\n" "# All 'neighbor' grand-children of 'country' children of the top-level\n" "# elements\n" "root.findall(\"./country/neighbor\")\n" "\n" "# Nodes with name='Singapore' that have a 'year' child\n" "root.findall(\".//year/..[@name='Singapore']\")\n" "\n" "# 'year' nodes that are children of nodes with name='Singapore'\n" "root.findall(\".//*[@name='Singapore']/year\")\n" "\n" "# All 'neighbor' nodes that are the second child of their parent\n" "root.findall(\".//neighbor[2]\")" msgstr "" #: ../../library/xml.etree.elementtree.rst:435 msgid "" "For XML with namespaces, use the usual qualified ``{namespace}tag`` " "notation::" msgstr "" #: ../../library/xml.etree.elementtree.rst:437 msgid "" "# All dublin-core \"title\" tags in the document\n" "root.findall(\".//{http://purl.org/dc/elements/1.1/}title\")" msgstr "" #: ../../library/xml.etree.elementtree.rst:442 msgid "Supported XPath syntax" msgstr "サポートされている XPath 構文" #: ../../library/xml.etree.elementtree.rst:447 msgid "Syntax" msgstr "操作" #: ../../library/xml.etree.elementtree.rst:447 msgid "Meaning" msgstr "意味" #: ../../library/xml.etree.elementtree.rst:449 msgid "``tag``" msgstr "``tag``" #: ../../library/xml.etree.elementtree.rst:449 msgid "" "Selects all child elements with the given tag. For example, ``spam`` selects " "all child elements named ``spam``, and ``spam/egg`` selects all " "grandchildren named ``egg`` in all children named ``spam``. ``{namespace}" "*`` selects all tags in the given namespace, ``{*}spam`` selects tags named " "``spam`` in any (or no) namespace, and ``{}*`` only selects tags that are " "not in a namespace." msgstr "" #: ../../library/xml.etree.elementtree.rst:458 msgid "Support for star-wildcards was added." msgstr "" #: ../../library/xml.etree.elementtree.rst:461 msgid "``*``" msgstr "``*``" #: ../../library/xml.etree.elementtree.rst:461 msgid "" "Selects all child elements, including comments and processing instructions. " "For example, ``*/egg`` selects all grandchildren named ``egg``." msgstr "" #: ../../library/xml.etree.elementtree.rst:465 msgid "``.``" msgstr "``.``" #: ../../library/xml.etree.elementtree.rst:465 msgid "" "Selects the current node. This is mostly useful at the beginning of the " "path, to indicate that it's a relative path." msgstr "" "現在のノードを選択します。これはパスの先頭に置くことで相対パスであることを示" "すのに役立ちます。" #: ../../library/xml.etree.elementtree.rst:469 msgid "``//``" msgstr "``//``" #: ../../library/xml.etree.elementtree.rst:469 msgid "" "Selects all subelements, on all levels beneath the current element. For " "example, ``.//egg`` selects all ``egg`` elements in the entire tree." msgstr "" "現在の要素の下にある全てのレベルの全ての子要素を選択します。例えば、``.//" "egg`` は木全体から ``egg`` 要素を選択します。" #: ../../library/xml.etree.elementtree.rst:473 msgid "``..``" msgstr "``..``" #: ../../library/xml.etree.elementtree.rst:473 msgid "" "Selects the parent element. Returns ``None`` if the path attempts to reach " "the ancestors of the start element (the element ``find`` was called on)." msgstr "" "親ノードを選択します。パスが開始要素 (``find`` が呼ばれた要素) の上の要素に進" "もうとした場合 ``None`` を返します。" #: ../../library/xml.etree.elementtree.rst:477 msgid "``[@attrib]``" msgstr "``[@attrib]``" #: ../../library/xml.etree.elementtree.rst:477 msgid "Selects all elements that have the given attribute." msgstr "与えられた属性を持つ全ての要素を選択します。" #: ../../library/xml.etree.elementtree.rst:479 msgid "``[@attrib='value']``" msgstr "``[@attrib='value']``" #: ../../library/xml.etree.elementtree.rst:479 msgid "" "Selects all elements for which the given attribute has the given value. The " "value cannot contain quotes." msgstr "" "与えられた属性が与えられた値を持つ全ての要素を選択します。\n" "値に引用符は含められません。" #: ../../library/xml.etree.elementtree.rst:483 msgid "``[@attrib!='value']``" msgstr "``[@attrib!='value']``" #: ../../library/xml.etree.elementtree.rst:483 msgid "" "Selects all elements for which the given attribute does not have the given " "value. The value cannot contain quotes." msgstr "" "与えられた属性が与えられた値を持たない全ての要素を選択します。\n" "値に引用符は含められません。" #: ../../library/xml.etree.elementtree.rst:489 msgid "``[tag]``" msgstr "``[tag]``" #: ../../library/xml.etree.elementtree.rst:489 msgid "" "Selects all elements that have a child named ``tag``. Only immediate " "children are supported." msgstr "" "``tag`` という名前の子要素を持つ全ての要素を選択します。\n" "直下の子要素のみサポートしています。" #: ../../library/xml.etree.elementtree.rst:492 msgid "``[.='text']``" msgstr "``[.='text']``" #: ../../library/xml.etree.elementtree.rst:492 msgid "" "Selects all elements whose complete text content, including descendants, " "equals the given ``text``." msgstr "" "子孫のうち、与えられた ``text`` とテキスト全体が等しい全ての要素を選択しま" "す。" #: ../../library/xml.etree.elementtree.rst:497 msgid "``[.!='text']``" msgstr "``[.!='text']``" #: ../../library/xml.etree.elementtree.rst:497 msgid "" "Selects all elements whose complete text content, including descendants, " "does not equal the given ``text``." msgstr "" "子孫のうち、与えられた ``text`` とテキスト全体が等しくない全ての要素を選択し" "ます。" #: ../../library/xml.etree.elementtree.rst:503 msgid "``[tag='text']``" msgstr "``[tag='text']``" #: ../../library/xml.etree.elementtree.rst:503 msgid "" "Selects all elements that have a child named ``tag`` whose complete text " "content, including descendants, equals the given ``text``." msgstr "" "子孫を含む完全なテキストコンテンツと与えられた ``text`` が一致する、 ``tag`` " "と名付けられた子要素を持つすべての要素を選択します。" #: ../../library/xml.etree.elementtree.rst:507 msgid "``[tag!='text']``" msgstr "``[tag!='text']``" #: ../../library/xml.etree.elementtree.rst:507 msgid "" "Selects all elements that have a child named ``tag`` whose complete text " "content, including descendants, does not equal the given ``text``." msgstr "" "子孫を含む完全なテキストコンテンツと与えられた ``text`` が一致しない、 " "``tag`` と名付けられた子要素を持つすべての要素を選択します。" #: ../../library/xml.etree.elementtree.rst:513 msgid "``[position]``" msgstr "``[position]``" #: ../../library/xml.etree.elementtree.rst:513 msgid "" "Selects all elements that are located at the given position. The position " "can be either an integer (1 is the first position), the expression " "``last()`` (for the last position), or a position relative to the last " "position (e.g. ``last()-1``)." msgstr "" "与えられた位置にあるすべての要素を選択します。位置は整数 (先頭は 1)、式 " "``last()`` (末尾)、あるいは末尾からの相対位置 (例えば ``last()-1``) のいずれ" "かで指定できます。" #: ../../library/xml.etree.elementtree.rst:520 msgid "" "Predicates (expressions within square brackets) must be preceded by a tag " "name, an asterisk, or another predicate. ``position`` predicates must be " "preceded by a tag name." msgstr "" "述語 (角括弧内の式) の前にはタグ名、アスタリスク、あるいはその他の述語がなけ" "ればなりません。\n" "``position`` 述語の前にはタグ名がなければなりません。" #: ../../library/xml.etree.elementtree.rst:525 #: ../../library/xml.etree.elementtree.rst:874 msgid "Reference" msgstr "リファレンス" #: ../../library/xml.etree.elementtree.rst:530 #: ../../library/xml.etree.elementtree.rst:879 msgid "Functions" msgstr "関数" #: ../../library/xml.etree.elementtree.rst:534 msgid "`C14N 2.0 `_ transformation function." msgstr "" #: ../../library/xml.etree.elementtree.rst:536 msgid "" "Canonicalization is a way to normalise XML output in a way that allows byte-" "by-byte comparisons and digital signatures. It reduces the freedom that XML " "serializers have and instead generates a more constrained XML " "representation. The main restrictions regard the placement of namespace " "declarations, the ordering of attributes, and ignorable whitespace." msgstr "" #: ../../library/xml.etree.elementtree.rst:542 msgid "" "This function takes an XML data string (*xml_data*) or a file path or file-" "like object (*from_file*) as input, converts it to the canonical form, and " "writes it out using the *out* file(-like) object, if provided, or returns it " "as a text string if not. The output file receives text, not bytes. It " "should therefore be opened in text mode with ``utf-8`` encoding." msgstr "" #: ../../library/xml.etree.elementtree.rst:549 msgid "Typical uses::" msgstr "利用例::" #: ../../library/xml.etree.elementtree.rst:551 msgid "" "xml_data = \"...\"\n" "print(canonicalize(xml_data))\n" "\n" "with open(\"c14n_output.xml\", mode='w', encoding='utf-8') as out_file:\n" " canonicalize(xml_data, out=out_file)\n" "\n" "with open(\"c14n_output.xml\", mode='w', encoding='utf-8') as out_file:\n" " canonicalize(from_file=\"inputfile.xml\", out=out_file)" msgstr "" #: ../../library/xml.etree.elementtree.rst:560 msgid "The configuration *options* are as follows:" msgstr "" #: ../../library/xml.etree.elementtree.rst:562 msgid "*with_comments*: set to true to include comments (default: false)" msgstr "" #: ../../library/xml.etree.elementtree.rst:563 msgid "" "*strip_text*: set to true to strip whitespace before and after text content" msgstr "" #: ../../library/xml.etree.elementtree.rst:564 #: ../../library/xml.etree.elementtree.rst:566 msgid "(default: false)" msgstr "(デフォルト: false)" #: ../../library/xml.etree.elementtree.rst:565 msgid "" "*rewrite_prefixes*: set to true to replace namespace prefixes by " "\"n{number}\"" msgstr "" #: ../../library/xml.etree.elementtree.rst:567 msgid "*qname_aware_tags*: a set of qname aware tag names in which prefixes" msgstr "" #: ../../library/xml.etree.elementtree.rst:568 #: ../../library/xml.etree.elementtree.rst:570 msgid "should be replaced in text content (default: empty)" msgstr "" #: ../../library/xml.etree.elementtree.rst:569 msgid "" "*qname_aware_attrs*: a set of qname aware attribute names in which prefixes" msgstr "" #: ../../library/xml.etree.elementtree.rst:571 msgid "*exclude_attrs*: a set of attribute names that should not be serialised" msgstr "" #: ../../library/xml.etree.elementtree.rst:572 msgid "*exclude_tags*: a set of tag names that should not be serialised" msgstr "" #: ../../library/xml.etree.elementtree.rst:574 msgid "" "In the option list above, \"a set\" refers to any collection or iterable of " "strings, no ordering is expected." msgstr "" #: ../../library/xml.etree.elementtree.rst:582 msgid "" "Comment element factory. This factory function creates a special element " "that will be serialized as an XML comment by the standard serializer. The " "comment string can be either a bytestring or a Unicode string. *text* is a " "string containing the comment string. Returns an element instance " "representing a comment." msgstr "" "コメント要素のファクトリです。このファクトリ関数は、標準のシリアライザでは " "XML コメントにシリアライズされる特別な要素を作ります。コメント文字列はバイト" "文字列でも Unicode 文字列でも構いません。*text* はそのコメント文字列を含んだ" "文字列です。コメントを表わす要素のインスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:588 msgid "" "Note that :class:`XMLParser` skips over comments in the input instead of " "creating comment objects for them. An :class:`ElementTree` will only contain " "comment nodes if they have been inserted into to the tree using one of the :" "class:`Element` methods." msgstr "" ":class:`XMLParser` は、入力に含まれるコメントを読み飛ばし、コメントオブジェク" "トは作成しません。:class:`ElementTree` は、:class:`Element` メソッドの 1 つを" "使用して木内に挿入されたコメントノードのみを含みます。" #: ../../library/xml.etree.elementtree.rst:595 msgid "" "Writes an element tree or element structure to sys.stdout. This function " "should be used for debugging only." msgstr "" "要素の木もしくは要素の構造を sys.stdout に出力します。この関数はデバッグ目的" "のみに使用してください。" #: ../../library/xml.etree.elementtree.rst:598 msgid "" "The exact output format is implementation dependent. In this version, it's " "written as an ordinary XML file." msgstr "" "出力される形式の正確なところは実装依存です。このバージョンでは、通常の XML " "ファイルとして出力されます。" #: ../../library/xml.etree.elementtree.rst:601 msgid "*elem* is an element tree or an individual element." msgstr "*elem* は要素の木もしくは個別の要素です。" #: ../../library/xml.etree.elementtree.rst:603 msgid "" "The :func:`dump` function now preserves the attribute order specified by the " "user." msgstr "" ":func:`dump` 関数はユーザーが指定した属性の順序を保持するようになりました。" #: ../../library/xml.etree.elementtree.rst:610 msgid "" "Parses an XML section from a string constant. Same as :func:`XML`. *text* " "is a string containing XML data. *parser* is an optional parser instance. " "If not given, the standard :class:`XMLParser` parser is used. Returns an :" "class:`Element` instance." msgstr "" "文字列定数で与えられた XML 断片を解析します。 :func:`XML` と同じです。 " "*text* には XML データを含む文字列を指定します。 *parser* はオプションで、" "パーザのインスタンスを指定します。指定されなかった場合、標準の :class:" "`XMLParser` パーザを使用します。 :class:`Element` インスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:618 msgid "" "Parses an XML document from a sequence of string fragments. *sequence* is a " "list or other sequence containing XML data fragments. *parser* is an " "optional parser instance. If not given, the standard :class:`XMLParser` " "parser is used. Returns an :class:`Element` instance." msgstr "" "文字列フラグメントのシーケンスから XML ドキュメントを解析します。 *sequence* " "は XML データのフラグメントを格納した、リストかその他のシーケンスです。 " "*parser* はオプションのパーザインスタンスです。パーザが指定されない場合、標準" "の :class:`XMLParser` パーザが使用されます。 :class:`Element` インスタンスを" "返します。" #: ../../library/xml.etree.elementtree.rst:628 msgid "" "Appends whitespace to the subtree to indent the tree visually. This can be " "used to generate pretty-printed XML output. *tree* can be an Element or " "ElementTree. *space* is the whitespace string that will be inserted for " "each indentation level, two space characters by default. For indenting " "partial subtrees inside of an already indented tree, pass the initial " "indentation level as *level*." msgstr "" #: ../../library/xml.etree.elementtree.rst:640 msgid "" "Check if an object appears to be a valid element object. *element* is an " "element instance. Return ``True`` if this is an element object." msgstr "" "オブジェクトが正当な要素オブジェクトであるかをチェックします。 *element* は要" "素インスタンスです。引数が要素オブジェクトの場合 ``True`` を返します。" #: ../../library/xml.etree.elementtree.rst:646 msgid "" "Parses an XML section into an element tree incrementally, and reports what's " "going on to the user. *source* is a filename or :term:`file object` " "containing XML data. *events* is a sequence of events to report back. The " "supported events are the strings ``\"start\"``, ``\"end\"``, " "``\"comment\"``, ``\"pi\"``, ``\"start-ns\"`` and ``\"end-ns\"`` (the \"ns\" " "events are used to get detailed namespace information). If *events* is " "omitted, only ``\"end\"`` events are reported. *parser* is an optional " "parser instance. If not given, the standard :class:`XMLParser` parser is " "used. *parser* must be a subclass of :class:`XMLParser` and can only use " "the default :class:`TreeBuilder` as a target. Returns an :term:`iterator` " "providing ``(event, elem)`` pairs; it has a ``root`` attribute that " "references the root element of the resulting XML tree once *source* is fully " "read. The iterator has the :meth:`!close` method that closes the internal " "file object if *source* is a filename." msgstr "" #: ../../library/xml.etree.elementtree.rst:662 msgid "" "Note that while :func:`iterparse` builds the tree incrementally, it issues " "blocking reads on *source* (or the file it names). As such, it's unsuitable " "for applications where blocking reads can't be made. For fully non-blocking " "parsing, see :class:`XMLPullParser`." msgstr "" ":func:`iterparse` は木をインクリメンタルに構築しますが、*source* (または指定" "のファイル) でのブロッキング読みを起こします。したがって、ブロッキング読みが" "許可されないアプリケーションには適しません。完全に非ブロックのパースのために" "は、:class:`XMLPullParser` を参照してください。" #: ../../library/xml.etree.elementtree.rst:667 msgid "" "The tree is only built incrementally, it is not freed incrementally: every " "parsed element is kept until the whole document is read. See :ref:" "`elementtree-pull-parsing` for how to keep the memory usage low." msgstr "" #: ../../library/xml.etree.elementtree.rst:673 msgid "" ":func:`iterparse` only guarantees that it has seen the \">\" character of a " "starting tag when it emits a \"start\" event, so the attributes are defined, " "but the contents of the text and tail attributes are undefined at that " "point. The same applies to the element children; they may or may not be " "present." msgstr "" ":func:`iterparse` は \"start\" イベントを発行した時に開始タグの文字 \">\" が" "現れたことだけを保証します。そのため、属性は定義されますが、その時点ではテキ" "ストの内容も tail 属性も定義されていません。同じことは子要素にも言えて、その" "時点ではあるともないとも言えません。" #: ../../library/xml.etree.elementtree.rst:679 #: ../../library/xml.etree.elementtree.rst:1568 msgid "If you need a fully populated element, look for \"end\" events instead." msgstr "全部揃った要素が必要ならば、\"end\" イベントを探してください。" #: ../../library/xml.etree.elementtree.rst:681 msgid "The *parser* argument." msgstr "*parser* 引数。" #: ../../library/xml.etree.elementtree.rst:684 #: ../../library/xml.etree.elementtree.rst:1572 msgid "The ``comment`` and ``pi`` events were added." msgstr "イベント ``comment``, ``pi`` が追加されました。" #: ../../library/xml.etree.elementtree.rst:687 msgid "Added the :meth:`!close` method." msgstr "" #: ../../library/xml.etree.elementtree.rst:690 msgid "" "A :exc:`ResourceWarning` is now emitted if the iterator opened a file and is " "not explicitly closed." msgstr "" #: ../../library/xml.etree.elementtree.rst:697 msgid "" "Parses an XML section into an element tree. *source* is a filename or file " "object containing XML data. *parser* is an optional parser instance. If " "not given, the standard :class:`XMLParser` parser is used. Returns an :" "class:`ElementTree` instance." msgstr "" "XML 断片を解析して要素の木にします。 *source* には XML データを含むファイル名" "またはファイルオブジェクトを指定します。 *parser* はオプションでパーザインス" "タンスを指定します。パーザが指定されない場合、標準の :class:`XMLParser` パー" "ザが使用されます。 :class:`ElementTree` インスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:705 msgid "" "PI element factory. This factory function creates a special element that " "will be serialized as an XML processing instruction. *target* is a string " "containing the PI target. *text* is a string containing the PI contents, if " "given. Returns an element instance, representing a processing instruction." msgstr "" "PI 要素のファクトリです。このファクトリ関数は XML の処理命令としてシリアライ" "ズされた特別な要素を作成します。*target* は PI ターゲットを含んだ文字列です。" "*text* を指定する場合は PI コンテンツを含む文字列にします。PI を表わす要素イ" "ンスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:710 msgid "" "Note that :class:`XMLParser` skips over processing instructions in the input " "instead of creating PI objects for them. An :class:`ElementTree` will only " "contain processing instruction nodes if they have been inserted into to the " "tree using one of the :class:`Element` methods." msgstr "" #: ../../library/xml.etree.elementtree.rst:718 msgid "" "Registers a namespace prefix. The registry is global, and any existing " "mapping for either the given prefix or the namespace URI will be removed. " "*prefix* is a namespace prefix. *uri* is a namespace uri. Tags and " "attributes in this namespace will be serialized with the given prefix, if at " "all possible." msgstr "" "名前空間の接頭辞を登録します。レジストリはグローバルで、与えられた接頭辞か名" "前空間 URI のどちらかの既存のマッピングはすべて削除されます。*prefix* には名" "前空間の接頭辞を指定します。*uri* には名前空間の URI を指定します。この名前空" "間のタグや属性は、可能な限り与えられた接頭辞をつけてシリアライズされます。" #: ../../library/xml.etree.elementtree.rst:729 msgid "" "Subelement factory. This function creates an element instance, and appends " "it to an existing element." msgstr "" "子要素のファクトリです。この関数は要素インスタンスを作成し、それを既存の要素" "に追加します。" #: ../../library/xml.etree.elementtree.rst:732 msgid "" "The element name, attribute names, and attribute values can be either " "bytestrings or Unicode strings. *parent* is the parent element. *tag* is " "the subelement name. *attrib* is an optional dictionary, containing element " "attributes. *extra* contains additional attributes, given as keyword " "arguments. Returns an element instance." msgstr "" "要素名、属性名、および属性値はバイト文字列でも Unicode 文字列でも構いませ" "ん。 *parent* には親要素を指定します。 *tag* には要素名を指定します。" "*attrib* はオプションで要素の属性を含む辞書を指定します。 *extra* は追加の属" "性で、キーワード引数として与えます。要素インスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:738 #: ../../library/xml.etree.elementtree.rst:929 msgid "*attrib* can now be a :class:`frozendict`." msgstr "" #: ../../library/xml.etree.elementtree.rst:741 msgid "*parent* and *tag* are now positional-only parameters." msgstr "" #: ../../library/xml.etree.elementtree.rst:749 msgid "" "Generates a string representation of an XML element, including all " "subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is " "the output encoding (default is US-ASCII). Use ``encoding=\"unicode\"`` to " "generate a Unicode string (otherwise, a bytestring is generated). *method* " "is either ``\"xml\"``, ``\"html\"`` or ``\"text\"`` (default is " "``\"xml\"``). *xml_declaration*, *default_namespace* and " "*short_empty_elements* has the same meaning as in :meth:`ElementTree.write`. " "Returns an (optionally) encoded string containing the XML data." msgstr "" "XML 要素を全ての子要素を含めて表現する文字列を生成します。 *element* は :" "class:`Element` のインスタンスです。 *encoding* [1]_ は出力エンコーディング" "(デフォルトは US-ASCII)です。Unicode 文字列を生成するには、" "``encoding=\"unicode\"`` を使用してください。 *method* は ``\"xml\"``, " "``\"html\"``, ``\"text\"`` のいずれか(デフォルトは ``\"xml\"``) です。 " "*xml_declaration*, *default_namespace*, *short_empty_elements* は、 :meth:" "`ElementTree.write` での意味と同じ意味を持ちます。 XML データを含んだ (オプ" "ションで) エンコードされた文字列を返します。" #: ../../library/xml.etree.elementtree.rst:758 #: ../../library/xml.etree.elementtree.rst:785 #: ../../library/xml.etree.elementtree.rst:1245 msgid "Added the *short_empty_elements* parameter." msgstr "*short_empty_elements* 引数を追加しました。" #: ../../library/xml.etree.elementtree.rst:761 #: ../../library/xml.etree.elementtree.rst:788 msgid "Added the *xml_declaration* and *default_namespace* parameters." msgstr "" #: ../../library/xml.etree.elementtree.rst:764 msgid "" "The :func:`tostring` function now preserves the attribute order specified by " "the user." msgstr "" #: ../../library/xml.etree.elementtree.rst:773 msgid "" "Generates a string representation of an XML element, including all " "subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is " "the output encoding (default is US-ASCII). Use ``encoding=\"unicode\"`` to " "generate a Unicode string (otherwise, a bytestring is generated). *method* " "is either ``\"xml\"``, ``\"html\"`` or ``\"text\"`` (default is " "``\"xml\"``). *xml_declaration*, *default_namespace* and " "*short_empty_elements* has the same meaning as in :meth:`ElementTree.write`. " "Returns a list of (optionally) encoded strings containing the XML data. It " "does not guarantee any specific sequence, except that ``b\"\"." "join(tostringlist(element)) == tostring(element)``." msgstr "" "XML 要素を全ての子要素を含めて表現する文字列を生成します。 *element* は :" "class:`Element` のインスタンスです。 *encoding* [1]_ は出力エンコーディング" "(デフォルトは US-ASCII)です。Unicode 文字列を生成するには、" "``encoding=\"unicode\"`` を使用してください。 *method* は ``\"xml\"``, " "``\"html\"``, ``\"text\"`` のいずれか(デフォルトは ``\"xml\"``) です。 " "xml_declaration*, *default_namespace*, *short_empty_elements* は、 :meth:" "`ElementTree.write` での意味と同じ意味を持ちます。 XML データを含んだ (オプ" "ションで) エンコードされた文字列のリストを返します。``b\"\"." "join(tostringlist(element)) == tostring(element)`` となること以外、特定の順序" "になる保証はありません。" #: ../../library/xml.etree.elementtree.rst:791 msgid "" "The :func:`tostringlist` function now preserves the attribute order " "specified by the user." msgstr "" ":func:`tostringlist` 関数はユーザーが指定した属性の順序を保持するようになりま" "した。" #: ../../library/xml.etree.elementtree.rst:798 msgid "" "Parses an XML section from a string constant. This function can be used to " "embed \"XML literals\" in Python code. *text* is a string containing XML " "data. *parser* is an optional parser instance. If not given, the standard :" "class:`XMLParser` parser is used. Returns an :class:`Element` instance." msgstr "" "文字列定数で与えられた XML 断片を解析します。この関数は Python コードに " "\"XML リテラル\" を埋め込むのに使えます。 *text* には XML データを含む文字列" "を指定します。 *parser* はオプションで、パーザのインスタンスを指定します。指" "定されなかった場合、標準の :class:`XMLParser` パーザを使用します。 :class:" "`Element` インスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:806 msgid "" "Parses an XML section from a string constant, and also returns a dictionary " "which maps from element id:s to elements. *text* is a string containing XML " "data. *parser* is an optional parser instance. If not given, the standard :" "class:`XMLParser` parser is used. Returns a tuple containing an :class:" "`Element` instance and a dictionary." msgstr "" "文字列定数で与えられた XML 断片を解析し、要素 ID と要素を対応付ける辞書を返し" "ます。 *text* には XMLデータを含んだ文字列を指定します。 *parser* はオプショ" "ンで、パーザのインスタンスを指定します。指定されなかった場合、標準の :class:" "`XMLParser` パーザを使用します。 :class:`Element` のインスタンスと辞書のタプ" "ルを返します。" #: ../../library/xml.etree.elementtree.rst:816 msgid "XInclude support" msgstr "XInclude サポート" #: ../../library/xml.etree.elementtree.rst:818 msgid "" "This module provides limited support for `XInclude directives `_, via the :mod:`xml.etree.ElementInclude` helper " "module. This module can be used to insert subtrees and text strings into " "element trees, based on information in the tree." msgstr "" #: ../../library/xml.etree.elementtree.rst:824 msgid "" "Here's an example that demonstrates use of the XInclude module. To include " "an XML document in the current document, use the ``{http://www.w3.org/2001/" "XInclude}include`` element and set the **parse** attribute to ``\"xml\"``, " "and use the **href** attribute to specify the document to include." msgstr "" #: ../../library/xml.etree.elementtree.rst:826 msgid "" "\n" "\n" " \n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:833 msgid "" "By default, the **href** attribute is treated as a file name. You can use " "custom loaders to override this behaviour. Also note that the standard " "helper does not support XPointer syntax." msgstr "" #: ../../library/xml.etree.elementtree.rst:835 msgid "" "To process this file, load it as usual, and pass the root element to the :" "mod:`!xml.etree.ElementTree` module:" msgstr "" #: ../../library/xml.etree.elementtree.rst:837 msgid "" "from xml.etree import ElementTree, ElementInclude\n" "\n" "tree = ElementTree.parse(\"document.xml\")\n" "root = tree.getroot()\n" "\n" "ElementInclude.include(root)" msgstr "" #: ../../library/xml.etree.elementtree.rst:846 msgid "" "The ElementInclude module replaces the ``{http://www.w3.org/2001/XInclude}" "include`` element with the root element from the **source.xml** document. " "The result might look something like this:" msgstr "" #: ../../library/xml.etree.elementtree.rst:848 msgid "" "\n" " This is a paragraph.\n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:854 msgid "" "If the **parse** attribute is omitted, it defaults to \"xml\". The href " "attribute is required." msgstr "" #: ../../library/xml.etree.elementtree.rst:856 msgid "" "To include a text document, use the ``{http://www.w3.org/2001/XInclude}" "include`` element, and set the **parse** attribute to \"text\":" msgstr "" #: ../../library/xml.etree.elementtree.rst:858 msgid "" "\n" "\n" " Copyright (c) .\n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:865 msgid "The result might look something like:" msgstr "" #: ../../library/xml.etree.elementtree.rst:867 msgid "" "\n" " Copyright (c) 2003.\n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:885 msgid "" "Default loader. This default loader reads an included resource from disk. " "*href* is a URL. *parse* is for parse mode either \"xml\" or \"text\". " "*encoding* is an optional text encoding. If not given, encoding is " "``utf-8``. Returns the expanded resource. If the parse mode is ``\"xml\"``, " "this is an :class:`~xml.etree.ElementTree.Element` instance. If the parse " "mode is ``\"text\"``, this is a string. If the loader fails, it can return " "``None`` or raise an exception." msgstr "" #: ../../library/xml.etree.elementtree.rst:896 msgid "" "This function expands XInclude directives in-place in tree pointed by " "*elem*. *elem* is either the root :class:`~xml.etree.ElementTree.Element` or " "an :class:`~xml.etree.ElementTree.ElementTree` instance to find such " "element. *loader* is an optional resource loader. If omitted, it defaults " "to :func:`default_loader`. If given, it should be a callable that implements " "the same interface as :func:`default_loader`. *base_url* is base URL of the " "original file, to resolve relative include file references. *max_depth* is " "the maximum number of recursive inclusions. Limited to reduce the risk of " "malicious content explosion. Pass ``None`` to disable the limitation." msgstr "" #: ../../library/xml.etree.elementtree.rst:906 msgid "Added the *base_url* and *max_depth* parameters." msgstr "" #: ../../library/xml.etree.elementtree.rst:913 msgid "Element Objects" msgstr "Element オブジェクト" #: ../../library/xml.etree.elementtree.rst:921 msgid "" "Element class. This class defines the Element interface, and provides a " "reference implementation of this interface." msgstr "" "要素クラスです。この関数は Element インターフェースを定義すると同時に、そのリ" "ファレンス実装を提供します。" #: ../../library/xml.etree.elementtree.rst:924 msgid "" "The element name, attribute names, and attribute values can be either " "bytestrings or Unicode strings. *tag* is the element name. *attrib* is an " "optional dictionary, containing element attributes. *extra* contains " "additional attributes, given as keyword arguments." msgstr "" "要素名、属性名、および属性値はバイト文字列でも Unicode 文字列でも構いませ" "ん。 *tag* には要素名を指定します。*attrib* はオプションで、要素と属性を含む" "辞書を指定します。*extra* は追加の属性で、キーワード引数として与えます。要素" "インスタンスを返します。" #: ../../library/xml.etree.elementtree.rst:932 msgid "*tag* is now a positional-only parameter." msgstr "" #: ../../library/xml.etree.elementtree.rst:938 msgid "" "A string identifying what kind of data this element represents (the element " "type, in other words)." msgstr "" "この要素が表すデータの種類を示す文字列です (言い替えると、要素の型です)。" #: ../../library/xml.etree.elementtree.rst:945 msgid "" "These attributes can be used to hold additional data associated with the " "element. Their values are usually strings but may be any application-" "specific object. If the element is created from an XML file, the *text* " "attribute holds either the text between the element's start tag and its " "first child or end tag, or ``None``, and the *tail* attribute holds either " "the text between the element's end tag and the next tag, or ``None``. For " "the XML data" msgstr "" "これらの属性は要素に結びつけられた付加的なデータを保持するのに使われます。こ" "れらの属性値はたいてい文字列ですが、アプリケーション固有のオブジェクトであっ" "て構いません。要素が XML ファイルから作られる場合、 *text* 属性は要素の開始タ" "グとその最初の子要素または終了タグまでのテキストか、あるいは ``None`` を保持" "し、 *tail* 属性は要素の終了タグと次のタグまでのテキストか、あるいは " "``None`` を保持します。このような XML データ" #: ../../library/xml.etree.elementtree.rst:953 msgid "1234" msgstr "" #: ../../library/xml.etree.elementtree.rst:957 msgid "" "the *a* element has ``None`` for both *text* and *tail* attributes, the *b* " "element has *text* ``\"1\"`` and *tail* ``\"4\"``, the *c* element has " "*text* ``\"2\"`` and *tail* ``None``, and the *d* element has *text* " "``None`` and *tail* ``\"3\"``." msgstr "" "の場合、 *a* 要素は *text*, *tail* 属性ともに ``None``, *b* 要素は *text* に " "``\"1\"`` で *tail* に ``\"4\"``, *c* 要素は *text* に ``\"2\"`` で *tail* " "は ``None``, *d* 要素 は *text* が ``None`` で *tail* に ``\"3\"`` をそれぞれ" "保持します。" #: ../../library/xml.etree.elementtree.rst:962 msgid "" "To collect the inner text of an element, see :meth:`itertext`, for example " "``\"\".join(element.itertext())``." msgstr "" "要素の内側のテキストを収集するためには、:meth:`itertext` を参照してください。" "例えば ``\"\".join(element.itertext())`` のようにします。" #: ../../library/xml.etree.elementtree.rst:965 msgid "Applications may store arbitrary objects in these attributes." msgstr "アプリケーションはこれらの属性に任意のオブジェクトを格納できます。" #: ../../library/xml.etree.elementtree.rst:970 msgid "" "A dictionary containing the element's attributes. Note that while the " "*attrib* value is always a real mutable Python dictionary, an ElementTree " "implementation may choose to use another internal representation, and create " "the dictionary only if someone asks for it. To take advantage of such " "implementations, use the dictionary methods below whenever possible." msgstr "" "要素の属性を保持する辞書です。 *attrib* の値は常に書き換え可能な Python 辞書" "ですが、ElementTree の実装によっては別の内部表現を使用し、要求されたときにだ" "け辞書を作るようにしているかもしれません。そうした実装の利益を享受するため" "に、可能な限り下記の辞書メソッドを通じて使用してください。" #: ../../library/xml.etree.elementtree.rst:976 msgid "The following dictionary-like methods work on the element attributes." msgstr "以下の辞書風メソッドが要素の属性に対して動作します。" #: ../../library/xml.etree.elementtree.rst:981 msgid "" "Resets an element. This function removes all subelements, clears all " "attributes, and sets the text and tail attributes to ``None``." msgstr "" "要素をリセットします。この関数は全ての子要素を削除し、全属性を消去し、テキス" "トとテール属性を ``None`` に設定します。" #: ../../library/xml.etree.elementtree.rst:987 msgid "Gets the element attribute named *key*." msgstr "要素の *key* という名前の属性を取得します。" #: ../../library/xml.etree.elementtree.rst:989 msgid "" "Returns the attribute value, or *default* if the attribute was not found." msgstr "属性の値、または属性がない場合は *default* を返します。" #: ../../library/xml.etree.elementtree.rst:994 msgid "" "Returns the element attributes as a sequence of (name, value) pairs. The " "attributes are returned in an arbitrary order." msgstr "" "要素の属性を (名前, 値) ペアのシーケンスとして返します。返される属性の順番は" "決まっていません。" #: ../../library/xml.etree.elementtree.rst:1000 msgid "" "Returns the elements attribute names as a list. The names are returned in " "an arbitrary order." msgstr "" "要素の属性名をリストとして返します。返される名前の順番は決まっていません。" #: ../../library/xml.etree.elementtree.rst:1006 msgid "Set the attribute *key* on the element to *value*." msgstr "要素の属性 *key* に *value* をセットします。" #: ../../library/xml.etree.elementtree.rst:1008 msgid "The following methods work on the element's children (subelements)." msgstr "以下のメソッドは要素の子要素 (副要素) に対して動作します。" #: ../../library/xml.etree.elementtree.rst:1013 msgid "" "Adds the element *subelement* to the end of this element's internal list of " "subelements. Raises :exc:`TypeError` if *subelement* is not an :class:" "`Element`." msgstr "" "要素 *subelement* を、要素の子要素の内部リストの末尾に追加します。" "*subelement* :class:`Element` でない場合、:exc:`TypeError` を送出します。" #: ../../library/xml.etree.elementtree.rst:1020 msgid "" "Appends *subelements* from an iterable of elements. Raises :exc:`TypeError` " "if a subelement is not an :class:`Element`." msgstr "" #: ../../library/xml.etree.elementtree.rst:1028 msgid "" "Finds the first subelement matching *match*. *match* may be a tag name or " "a :ref:`path `. Returns an element instance or " "``None``. *namespaces* is an optional mapping from namespace prefix to full " "name. Pass ``''`` as prefix to move all unprefixed tag names in the " "expression into the given namespace." msgstr "" #: ../../library/xml.etree.elementtree.rst:1037 msgid "" "Finds all matching subelements, by tag name or :ref:`path `. Returns a list containing all matching elements in document " "order. *namespaces* is an optional mapping from namespace prefix to full " "name. Pass ``''`` as prefix to move all unprefixed tag names in the " "expression into the given namespace." msgstr "" #: ../../library/xml.etree.elementtree.rst:1046 msgid "" "Finds text for the first subelement matching *match*. *match* may be a tag " "name or a :ref:`path `. Returns the text content of the " "first matching element, or *default* if no element was found. Note that if " "the matching element has no text content an empty string is returned. " "*namespaces* is an optional mapping from namespace prefix to full name. " "Pass ``''`` as prefix to move all unprefixed tag names in the expression " "into the given namespace." msgstr "" #: ../../library/xml.etree.elementtree.rst:1057 msgid "" "Inserts *subelement* at the given position in this element. Raises :exc:" "`TypeError` if *subelement* is not an :class:`Element`." msgstr "" "要素内の指定された位置に *subelement* を挿入します。*subelement* が :class:" "`Element` でない場合、:exc:`TypeError` を送出します。" #: ../../library/xml.etree.elementtree.rst:1063 msgid "" "Creates a tree :term:`iterator` with the current element as the root. The " "iterator iterates over this element and all elements below it, in document " "(depth first) order. If *tag* is not ``None`` or ``'*'``, only elements " "whose tag equals *tag* are returned from the iterator. If the tree " "structure is modified during iteration, the result is undefined." msgstr "" "現在の要素を根とする木の :term:`イテレータ ` を作成します。イテレー" "タは現在の要素とそれ以下のすべての要素を、文書内での出現順 (深さ優先順) でイ" "テレートします。 *tag* が ``None`` または ``'*'`` でない場合、与えられたタグ" "に等しいものについてのみイテレータから返されます。イテレート中に木構造が変更" "された場合の結果は未定義です。" #: ../../library/xml.etree.elementtree.rst:1074 msgid "" "Finds all matching subelements, by tag name or :ref:`path `. Returns an iterable yielding all matching elements in document " "order. *namespaces* is an optional mapping from namespace prefix to full " "name." msgstr "" "タグ名または :ref:`パス ` にマッチするすべての子要素を検索" "します。マッチしたすべての要素を文書内での出現順で yield するイテレータを返し" "ます。*namespaces* はオプションで、名前空間接頭辞と完全名を対応付けるマップオ" "ブジェクトを指定します。" #: ../../library/xml.etree.elementtree.rst:1085 msgid "" "Creates a text iterator. The iterator loops over this element and all " "subelements, in document order, and returns all inner text." msgstr "" "テキストのイテレータを作成します。イテレータは、この要素とすべての子要素を文" "書上の順序で巡回し、すべての内部のテキストを返します。" #: ../../library/xml.etree.elementtree.rst:1093 msgid "" "Creates a new element object of the same type as this element. Do not call " "this method, use the :func:`SubElement` factory function instead." msgstr "" "現在の要素と同じ型の新しい要素オブジェクトを作成します。このメソッドは呼び出" "さずに、 :func:`SubElement` ファクトリ関数を使って下さい。" #: ../../library/xml.etree.elementtree.rst:1099 msgid "" "Removes *subelement* from the element. Unlike the find\\* methods this " "method compares elements based on the instance identity, not on tag value or " "contents." msgstr "" "要素から *subelement* を削除します。find\\* メソッド群と異なり、このメソッド" "は要素をインスタンスの同一性で比較します。タグや内容では比較しません。" #: ../../library/xml.etree.elementtree.rst:1103 msgid "" ":class:`Element` objects also support the following sequence type methods " "for working with subelements: :meth:`~object.__delitem__`, :meth:`~object." "__getitem__`, :meth:`~object.__setitem__`, :meth:`~object.__len__`." msgstr "" ":class:`Element` オブジェクトは以下のシーケンス型のメソッドを、サブ要素を操作" "するためにサポートします: :meth:`~object.__delitem__`, :meth:`~object." "__getitem__`, :meth:`~object.__setitem__`, :meth:`~object.__len__`." #: ../../library/xml.etree.elementtree.rst:1108 msgid "" "Caution: Elements with no subelements will test as ``False``. In a future " "release of Python, all elements will test as ``True`` regardless of whether " "subelements exist. Instead, prefer explicit ``len(elem)`` or ``elem is not " "None`` tests.::" msgstr "" #: ../../library/xml.etree.elementtree.rst:1113 msgid "" "element = root.find('foo')\n" "\n" "if not element: # careful!\n" " print(\"element not found, or element has no subelements\")\n" "\n" "if element is None:\n" " print(\"element not found\")" msgstr "" #: ../../library/xml.etree.elementtree.rst:1121 msgid "Testing the truth value of an Element emits :exc:`DeprecationWarning`." msgstr "" #: ../../library/xml.etree.elementtree.rst:1124 msgid "" "Prior to Python 3.8, the serialisation order of the XML attributes of " "elements was artificially made predictable by sorting the attributes by " "their name. Based on the now guaranteed ordering of dicts, this arbitrary " "reordering was removed in Python 3.8 to preserve the order in which " "attributes were originally parsed or created by user code." msgstr "" #: ../../library/xml.etree.elementtree.rst:1130 msgid "" "In general, user code should try not to depend on a specific ordering of " "attributes, given that the `XML Information Set `_ explicitly excludes the attribute order from conveying " "information. Code should be prepared to deal with any ordering on input. In " "cases where deterministic XML output is required, e.g. for cryptographic " "signing or test data sets, canonical serialisation is available with the :" "func:`canonicalize` function." msgstr "" #: ../../library/xml.etree.elementtree.rst:1138 msgid "" "In cases where canonical output is not applicable but a specific attribute " "order is still desirable on output, code should aim for creating the " "attributes directly in the desired order, to avoid perceptual mismatches for " "readers of the code. In cases where this is difficult to achieve, a recipe " "like the following can be applied prior to serialisation to enforce an order " "independently from the Element creation::" msgstr "" #: ../../library/xml.etree.elementtree.rst:1145 msgid "" "def reorder_attributes(root):\n" " for el in root.iter():\n" " attrib = el.attrib\n" " if len(attrib) > 1:\n" " # adjust attribute order, e.g. by sorting\n" " attribs = sorted(attrib.items())\n" " attrib.clear()\n" " attrib.update(attribs)" msgstr "" #: ../../library/xml.etree.elementtree.rst:1158 msgid "ElementTree Objects" msgstr "ElementTree オブジェクト" #: ../../library/xml.etree.elementtree.rst:1163 msgid "" "ElementTree wrapper class. This class represents an entire element " "hierarchy, and adds some extra support for serialization to and from " "standard XML." msgstr "" "ElementTree ラッパークラスです。このクラスは要素の全階層を表現し、さらに標準 " "XML との相互変換を追加しています。" #: ../../library/xml.etree.elementtree.rst:1167 msgid "" "*element* is the root element. The tree is initialized with the contents of " "the XML *file* if given." msgstr "" "*element* は根要素です。*file* が指定されている場合、その XML ファイルの内容" "により木は初期化されます。" #: ../../library/xml.etree.elementtree.rst:1173 msgid "" "Replaces the root element for this tree. This discards the current contents " "of the tree, and replaces it with the given element. Use with care. " "*element* is an element instance." msgstr "" "この木の根要素を置き換えます。従って現在の木の内容は破棄され、与えられた要素" "が代わりに使われます。注意して使ってください。 *element* は要素インスタンスで" "す。" #: ../../library/xml.etree.elementtree.rst:1180 msgid "Same as :meth:`Element.find`, starting at the root of the tree." msgstr ":meth:`Element.find` と同じで、木の根要素を起点とします。" #: ../../library/xml.etree.elementtree.rst:1185 msgid "Same as :meth:`Element.findall`, starting at the root of the tree." msgstr ":meth:`Element.findall` と同じで、木の根要素を起点とします。" #: ../../library/xml.etree.elementtree.rst:1190 msgid "Same as :meth:`Element.findtext`, starting at the root of the tree." msgstr ":meth:`Element.findtext` と同じで、木の根要素を起点とします。" #: ../../library/xml.etree.elementtree.rst:1195 msgid "Returns the root element for this tree." msgstr "この木のルート要素を返します。" #: ../../library/xml.etree.elementtree.rst:1200 msgid "" "Creates and returns a tree iterator for the root element. The iterator " "loops over all elements in this tree, in section order. *tag* is the tag to " "look for (default is to return all elements)." msgstr "" "根要素に対する、木を巡回するイテレータを返します。イテレータは木のすべての要" "素に渡ってセクション順にループします。*tag* は探したいタグです (デフォルトで" "はすべての要素を返します)。" #: ../../library/xml.etree.elementtree.rst:1207 msgid "Same as :meth:`Element.iterfind`, starting at the root of the tree." msgstr ":meth:`Element.iterfind` と同じで、木の根要素を起点とします。" #: ../../library/xml.etree.elementtree.rst:1214 msgid "" "Loads an external XML section into this element tree. *source* is a file " "name or :term:`file object`. *parser* is an optional parser instance. If " "not given, the standard :class:`XMLParser` parser is used. Returns the " "section root element." msgstr "" "外部の XML 断片をこの要素木に入れます。*source* にはファイル名か :term:`ファ" "イルオブジェクト ` を指定します。*parser* はオプションで、パーザ" "インスタンスを指定します。パーザが指定されない場合、標準の :class:" "`XMLParser` パーザが使用されます。断片の根要素を返します。" #: ../../library/xml.etree.elementtree.rst:1224 msgid "" "Writes the element tree to a file, as XML. *file* is a file name, or a :" "term:`file object` opened for writing. *encoding* [1]_ is the output " "encoding (default is US-ASCII). *xml_declaration* controls if an XML " "declaration should be added to the file. Use ``False`` for never, ``True`` " "for always, ``None`` for only if not US-ASCII or UTF-8 or Unicode (default " "is ``None``). *default_namespace* sets the default XML namespace (for " "\"xmlns\"). *method* is either ``\"xml\"``, ``\"html\"`` or ``\"text\"`` " "(default is ``\"xml\"``). The keyword-only *short_empty_elements* parameter " "controls the formatting of elements that contain no content. If ``True`` " "(the default), they are emitted as a single self-closed tag, otherwise they " "are emitted as a pair of start/end tags." msgstr "" "要素の木をファイルに XML として書き込みます。\n" "*file* は、書き込み用に開かれたファイル名または :term:`ファイルオブジェクト " "` です。\n" "*encoding* [1]_ は出力エンコーディング(デフォルトは US-ASCII)です。\n" "*xml_declaration* は、 XML 宣言がファイルに書かれるかどうかを制御します。\n" "``False`` の場合は常に書かれず、 ``True`` の場合は常に書かれ、 ``None`` の場" "合は US-ASCII 、 UTF-8 、 Unicode 以外の場合に書かれます (デフォルトは " "``None`` です)。\n" "*default_namespace* でデフォルトの XML 名前空間 (\"xmlns\" 用) を指定しま" "す。\n" "*method* は ``\"xml\"``, ``\"html\"``, ``\"text\"`` のいずれかです (デフォル" "トは ``\"xml\"`` です)。\n" "キーワード専用の *short_empty_elements* 引数は、内容がない属性のフォーマット" "を制御します。\n" "``True`` (既定) の場合、単一の空要素タグとして書かれ、``False`` の場合、開始" "タグと終了タグのペアとしてかかれます。" #: ../../library/xml.etree.elementtree.rst:1238 msgid "" "The output is either a string (:class:`str`) or binary (:class:`bytes`). " "This is controlled by the *encoding* argument. If *encoding* is " "``\"unicode\"``, the output is a string; otherwise, it's binary. Note that " "this may conflict with the type of *file* if it's an open :term:`file " "object`; make sure you do not try to write a string to a binary stream and " "vice versa." msgstr "" "出力は引数 *encoding* によって、文字列 (:class:`str`) かバイト列 (:class:" "`bytes`) になります。*encoding* が ``\"unicode\"`` の場合、出力は文字列にな" "り、それ以外ではバイト列になります。*file* が :term:`ファイルオブジェクト " "` の場合、型が衝突する場合があります。文字列をバイト列ファイルへ" "書き込んだり、その逆を行わないよう注意してください。" #: ../../library/xml.etree.elementtree.rst:1248 msgid "" "The :meth:`write` method now preserves the attribute order specified by the " "user." msgstr "" ":meth:`write` メソッドはユーザーが指定した属性の順序を保持するようになりまし" "た。 " #: ../../library/xml.etree.elementtree.rst:1253 msgid "This is the XML file that is going to be manipulated::" msgstr "以下はこれから操作する XML ファイルです::" #: ../../library/xml.etree.elementtree.rst:1255 msgid "" "\n" " \n" " Example page\n" " \n" " \n" "

Moved to example.org\n" " or example.com.

\n" " \n" "" msgstr "" #: ../../library/xml.etree.elementtree.rst:1265 msgid "" "Example of changing the attribute \"target\" of every link in first " "paragraph::" msgstr "第 1 段落のすべてのリンクの \"target\" 属性を変更する例::" #: ../../library/xml.etree.elementtree.rst:1267 msgid "" ">>> from xml.etree.ElementTree import ElementTree\n" ">>> tree = ElementTree()\n" ">>> tree.parse(\"index.xhtml\")\n" "\n" ">>> p = tree.find(\"body/p\") # Finds first occurrence of tag p in body\n" ">>> p\n" "\n" ">>> links = list(p.iter(\"a\")) # Returns list of all links\n" ">>> links\n" "[, ]\n" ">>> for i in links: # Iterates through all found links\n" "... i.attrib[\"target\"] = \"blank\"\n" "...\n" ">>> tree.write(\"output.xhtml\")" msgstr "" #: ../../library/xml.etree.elementtree.rst:1285 msgid "QName Objects" msgstr "QName オブジェクト" #: ../../library/xml.etree.elementtree.rst:1290 msgid "" "QName wrapper. This can be used to wrap a QName attribute value, in order " "to get proper namespace handling on output. *text_or_uri* is a string " "containing the QName value, in the form {uri}local, or, if the tag argument " "is given, the URI part of a QName. If *tag* is given, the first argument is " "interpreted as a URI, and this argument is interpreted as a local name. :" "class:`QName` instances are opaque." msgstr "" "QName ラッパーです。\n" "このクラスは QName 属性値をラップし、出力時に適切な名前空間の扱いを得るために" "使われます。\n" "*text_or_uri* は {uri}local という形式の QName 値を含む文字列、または tag 引" "数が与えられた場合には QName の URI 部分の文字列です。\n" "*tag* が与えられた場合、一つめの引数は URI と解釈され、この引数はローカル名と" "解釈されます。\n" ":class:`QName` インスタンスは不透明です。" #: ../../library/xml.etree.elementtree.rst:1302 msgid "TreeBuilder Objects" msgstr "TreeBuilder オブジェクト" #: ../../library/xml.etree.elementtree.rst:1308 msgid "" "Generic element structure builder. This builder converts a sequence of " "start, data, end, comment and pi method calls to a well-formed element " "structure. You can use this class to build an element structure using a " "custom XML parser, or a parser for some other XML-like format." msgstr "" "汎用の要素構造ビルダー。これは start, data, end, comment, pi のメソッド呼び出" "しの列を整形式の要素構造に変換します。このクラスを使うと、好みの XML 構文解析" "器、または他の XML に似た形式の構文解析器を使って、要素構造を作り出すことがで" "きます。" #: ../../library/xml.etree.elementtree.rst:1313 msgid "" "*element_factory*, when given, must be a callable accepting two positional " "arguments: a tag and a dict of attributes. It is expected to return a new " "element instance." msgstr "" #: ../../library/xml.etree.elementtree.rst:1317 msgid "" "The *comment_factory* and *pi_factory* functions, when given, should behave " "like the :func:`Comment` and :func:`ProcessingInstruction` functions to " "create comments and processing instructions. When not given, the default " "factories will be used. When *insert_comments* and/or *insert_pis* is true, " "comments/pis will be inserted into the tree if they appear within the root " "element (but not outside of it)." msgstr "" #: ../../library/xml.etree.elementtree.rst:1326 msgid "" "Flushes the builder buffers, and returns the toplevel document element. " "Returns an :class:`Element` instance." msgstr "" "ビルダのバッファをフラッシュし、最上位の文書要素を返します。戻り値は :class:" "`Element` インスタンスになります。" #: ../../library/xml.etree.elementtree.rst:1332 msgid "" "Adds text to the current element. *data* is a string. This should be " "either a bytestring, or a Unicode string." msgstr "" "現在の要素にテキストを追加します。 *data* は文字列です。バイト文字列もしくは " "Unicode 文字列でなければなりません。" #: ../../library/xml.etree.elementtree.rst:1338 msgid "" "Closes the current element. *tag* is the element name. Returns the closed " "element." msgstr "" "現在の要素を閉じます。 *tag* は要素の名前です。閉じられた要素を返します。" #: ../../library/xml.etree.elementtree.rst:1344 msgid "" "Opens a new element. *tag* is the element name. *attrs* is a dictionary " "containing element attributes. Returns the opened element." msgstr "" "新しい要素を開きます。 *tag* は要素の名前です。 *attrs* は要素の属性を保持し" "た辞書です。開かれた要素を返します。" #: ../../library/xml.etree.elementtree.rst:1350 msgid "" "Creates a comment with the given *text*. If ``insert_comments`` is true, " "this will also add it to the tree." msgstr "" #: ../../library/xml.etree.elementtree.rst:1358 msgid "" "Creates a process instruction with the given *target* name and *text*. If " "``insert_pis`` is true, this will also add it to the tree." msgstr "" #: ../../library/xml.etree.elementtree.rst:1364 msgid "" "In addition, a custom :class:`TreeBuilder` object can provide the following " "methods:" msgstr "" "加えて、カスタムの :class:`TreeBuilder` オブジェクトは以下のメソッドを提供で" "きます:" #: ../../library/xml.etree.elementtree.rst:1369 msgid "" "Handles a doctype declaration. *name* is the doctype name. *pubid* is the " "public identifier. *system* is the system identifier. This method does not " "exist on the default :class:`TreeBuilder` class." msgstr "" "doctype 宣言を処理します。 *name* は doctype 名です。 *pubid* は公式の識別子" "です。 *system* はシステム識別子です。このメソッドはデフォルトの :class:" "`TreeBuilder` クラスには存在しません。" #: ../../library/xml.etree.elementtree.rst:1377 msgid "" "Is called whenever the parser encounters a new namespace declaration, before " "the ``start()`` callback for the opening element that defines it. *prefix* " "is ``''`` for the default namespace and the declared namespace prefix name " "otherwise. *uri* is the namespace URI." msgstr "" #: ../../library/xml.etree.elementtree.rst:1386 msgid "" "Is called after the ``end()`` callback of an element that declared a " "namespace prefix mapping, with the name of the *prefix* that went out of " "scope." msgstr "" #: ../../library/xml.etree.elementtree.rst:1398 msgid "" "A `C14N 2.0 `_ writer. Arguments are the " "same as for the :func:`canonicalize` function. This class does not build a " "tree but translates the callback events directly into a serialised form " "using the *write* function." msgstr "" #: ../../library/xml.etree.elementtree.rst:1409 msgid "XMLParser Objects" msgstr "XMLParser オブジェクト" #: ../../library/xml.etree.elementtree.rst:1414 msgid "" "This class is the low-level building block of the module. It uses :mod:`xml." "parsers.expat` for efficient, event-based parsing of XML. It can be fed XML " "data incrementally with the :meth:`feed` method, and parsing events are " "translated to a push API - by invoking callbacks on the *target* object. If " "*target* is omitted, the standard :class:`TreeBuilder` is used. If " "*encoding* [1]_ is given, the value overrides the encoding specified in the " "XML file." msgstr "" "このクラスは、このモジュールの構成要素のうち、低水準のものです。効率的でイベ" "ントベースのXMLパースのため、:mod:`xml.parsers.expat` を使用します。:meth:" "`feed` メソッドで XML データをインクリメンタルに受け取り、*target* オブジェク" "トのコールバックを呼び出すことで、パースイベントをプッシュ API に変換します。" "*target* が省略された場合、標準の :class:`TreeBuilder` が使用されます。 " "*encoding* [1]_ が指定された場合、このあたいは XML ファイル内で指定されたエン" "コーディングを上書きします。" #: ../../library/xml.etree.elementtree.rst:1422 msgid "" "Parameters are now :ref:`keyword-only `. The *html* " "argument is no longer supported." msgstr "" #: ../../library/xml.etree.elementtree.rst:1429 msgid "" "Finishes feeding data to the parser. Returns the result of calling the " "``close()`` method of the *target* passed during construction; by default, " "this is the toplevel document element." msgstr "" "パーザへのデータの提供を完了します。構築中に渡される *target* の ``close()`` " "メソッドを呼び出す結果を返します。既定では、これがトップレベルのドキュメント" "要素になります。" #: ../../library/xml.etree.elementtree.rst:1436 msgid "Feeds data to the parser. *data* is encoded data." msgstr "パーザへデータを入力します。 *data* はエンコードされたデータです。" #: ../../library/xml.etree.elementtree.rst:1441 #: ../../library/xml.etree.elementtree.rst:1519 msgid "" "Triggers parsing of any previously fed unparsed data, which can be used to " "ensure more immediate feedback, in particular with Expat >=2.6.0. The " "implementation of :meth:`flush` temporarily disables reparse deferral with " "Expat (if currently enabled) and triggers a reparse. Disabling reparse " "deferral has security consequences; please see :meth:`xml.parsers.expat." "xmlparser.SetReparseDeferralEnabled` for details." msgstr "" #: ../../library/xml.etree.elementtree.rst:1448 #: ../../library/xml.etree.elementtree.rst:1526 msgid "" ":meth:`!flush` has been backported to some prior releases of CPython as a " "security fix. Check for availability using :func:`hasattr` if used in code " "running across a variety of Python versions." msgstr "" #: ../../library/xml.etree.elementtree.rst:1456 msgid "" ":meth:`XMLParser.feed` calls *target*\\'s ``start(tag, attrs_dict)`` method " "for each opening tag, its ``end(tag)`` method for each closing tag, and data " "is processed by method ``data(data)``. For further supported callback " "methods, see the :class:`TreeBuilder` class. :meth:`XMLParser.close` calls " "*target*\\'s method ``close()``. :class:`XMLParser` can be used not only for " "building a tree structure. This is an example of counting the maximum depth " "of an XML file::" msgstr "" ":meth:`XMLParser.feed` は *target* の ``start(tag, attrs_dict)`` メソッドをそ" "れぞれの開始タグに対して呼び、また ``end(tag)`` メソッドを終了タグに対して呼" "び、そしてデータを ``data(data)`` メソッドで処理します。サポートされているそ" "の他のコールバックメソッドについては、 :class:`TreeBuilder` クラスを参照して" "ください。:meth:`XMLParser.close` は *target* の ``close()`` メソッドを呼びま" "す。 :class:`XMLParser` は木構造を構築する以外にも使えます。以下の例では、" "XML ファイルの最高の深さを数えます。" #: ../../library/xml.etree.elementtree.rst:1464 msgid "" ">>> from xml.etree.ElementTree import XMLParser\n" ">>> class MaxDepth: # The target object of the parser\n" "... maxDepth = 0\n" "... depth = 0\n" "... def start(self, tag, attrib): # Called for each opening tag.\n" "... self.depth += 1\n" "... if self.depth > self.maxDepth:\n" "... self.maxDepth = self.depth\n" "... def end(self, tag): # Called for each closing tag.\n" "... self.depth -= 1\n" "... def data(self, data):\n" "... pass # We do not need to do anything with data.\n" "... def close(self): # Called when all data has been parsed.\n" "... return self.maxDepth\n" "...\n" ">>> target = MaxDepth()\n" ">>> parser = XMLParser(target=target)\n" ">>> exampleXml = \"\"\"\n" "... \n" "... \n" "... \n" "... \n" "... \n" "... \n" "... \n" "... \n" "... \n" "... \"\"\"\n" ">>> parser.feed(exampleXml)\n" ">>> parser.close()\n" "4" msgstr "" #: ../../library/xml.etree.elementtree.rst:1500 msgid "XMLPullParser Objects" msgstr "XMLPullParser オブジェクト" #: ../../library/xml.etree.elementtree.rst:1504 msgid "" "A pull parser suitable for non-blocking applications. Its input-side API is " "similar to that of :class:`XMLParser`, but instead of pushing calls to a " "callback target, :class:`XMLPullParser` collects an internal list of parsing " "events and lets the user read from it. *events* is a sequence of events to " "report back. The supported events are the strings ``\"start\"``, " "``\"end\"``, ``\"comment\"``, ``\"pi\"``, ``\"start-ns\"`` and ``\"end-" "ns\"`` (the \"ns\" events are used to get detailed namespace information). " "If *events* is omitted, only ``\"end\"`` events are reported." msgstr "" "非ブロックアプリケーションに適したプルパーザです。入力側の API は :class:" "`XMLParser` のものと似ていますが、コールバックターゲットに呼び出しをプッシュ" "するのではなく、 :class:`XMLPullParser` はパースイベントの内部リストを収集" "し、ユーザーがそこから読み出すことができます。*events* は、呼び出し元に報告す" "るイベントのシーケンスです。サポートされているイベントは、文字列の " "``\"start\"``, ``\"end\"``, ``\"comment\"``, ``\"pi\"``, ``\"start-ns\"``, " "``\"end-ns\"`` (\"ns\" イベントは、名前空間の詳細情報の取得に使用) です。" "*events* が省略された場合、 ``\"end\"`` イベントのみが報告されます。" #: ../../library/xml.etree.elementtree.rst:1515 msgid "Feed the given bytes data to the parser." msgstr "指定したバイトデータをパーザに与えます。" #: ../../library/xml.etree.elementtree.rst:1535 msgid "" "Signal the parser that the data stream is terminated. Unlike :meth:" "`XMLParser.close`, this method always returns :const:`None`. Any events not " "yet retrieved when the parser is closed can still be read with :meth:" "`read_events`." msgstr "" "パーザに、データストリームが終了したことを伝えます。:meth:`XMLParser.close` " "とは異なり、このメソッドは常に :const:`None` を返します。パーザがクローズした" "時にまだ帰って来ていないイベントは、まだ :meth:`read_events` で読むことができ" "ます。" #: ../../library/xml.etree.elementtree.rst:1542 msgid "" "Return an iterator over the events which have been encountered in the data " "fed to the parser. The iterator yields ``(event, elem)`` pairs, where " "*event* is a string representing the type of event (e.g. ``\"end\"``) and " "*elem* is the encountered :class:`Element` object, or other context value as " "follows." msgstr "" #: ../../library/xml.etree.elementtree.rst:1548 msgid "``start``, ``end``: the current Element." msgstr "" #: ../../library/xml.etree.elementtree.rst:1549 msgid "``comment``, ``pi``: the current comment / processing instruction" msgstr "" #: ../../library/xml.etree.elementtree.rst:1550 msgid "" "``start-ns``: a tuple ``(prefix, uri)`` naming the declared namespace " "mapping." msgstr "" #: ../../library/xml.etree.elementtree.rst:1552 msgid "``end-ns``: :const:`None` (this may change in a future version)" msgstr "" #: ../../library/xml.etree.elementtree.rst:1554 msgid "" "Events provided in a previous call to :meth:`read_events` will not be " "yielded again. Events are consumed from the internal queue only when they " "are retrieved from the iterator, so multiple readers iterating in parallel " "over iterators obtained from :meth:`read_events` will have unpredictable " "results." msgstr "" ":meth:`read_events` の前の呼び出しで提供されたイベントは、再度 yield されるこ" "とはありません。イベントは、イテレータから取得された場合にのみ内部キューから" "消費されるため、:meth:`read_events` から取得されたイテレータに対して複数の読" "み出しを並行して反復的に行うと、予期せぬ結果が引き起こされます。" #: ../../library/xml.etree.elementtree.rst:1562 msgid "" ":class:`XMLPullParser` only guarantees that it has seen the \">\" character " "of a starting tag when it emits a \"start\" event, so the attributes are " "defined, but the contents of the text and tail attributes are undefined at " "that point. The same applies to the element children; they may or may not " "be present." msgstr "" ":class:`XMLPullParser` は \"start\" イベントを発行した時に開始タグの文字 " "\">\" が現れたことだけを保証します。そのため、属性は定義されますが、その時点" "ではテキストの内容も tail 属性も定義されていません。子要素にもそれが存在す" "る、しないにかかわらず同じ物が適用されます。" #: ../../library/xml.etree.elementtree.rst:1577 msgid "Exceptions" msgstr "例外" #: ../../library/xml.etree.elementtree.rst:1581 msgid "" "XML parse error, raised by the various parsing methods in this module when " "parsing fails. The string representation of an instance of this exception " "will contain a user-friendly error message. In addition, it will have the " "following attributes available:" msgstr "" "解析に失敗した時、このモジュールの様々なメソッドから送出される XML 解析エラー" "です。この例外のインスタンスが表す文字列は、ユーザフレンドリなメッセージを含" "んでいます。その他に、以下の属性も利用できます:" #: ../../library/xml.etree.elementtree.rst:1588 msgid "" "A numeric error code from the expat parser. See the documentation of :mod:" "`xml.parsers.expat` for the list of error codes and their meanings." msgstr "" "expat パーザからの数値エラーコードです。エラーコードの一覧とそれらの意味につ" "いては、:mod:`xml.parsers.expat` のドキュメントを参照してください。" #: ../../library/xml.etree.elementtree.rst:1593 msgid "" "A tuple of *line*, *column* numbers, specifying where the error occurred." msgstr "エラーが発生した場所を示す *line* と *column* 番号のタプルです。" #: ../../library/xml.etree.elementtree.rst:1596 msgid "Footnotes" msgstr "脚注" #: ../../library/xml.etree.elementtree.rst:1597 msgid "" "The encoding string included in XML output should conform to the appropriate " "standards. For example, \"UTF-8\" is valid, but \"UTF8\" is not. See " "https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl and https://" "www.iana.org/assignments/character-sets/character-sets.xhtml." msgstr "" "XML 出力に含まれるエンコーディング文字列は適切な規格に従っていなければなりま" "せん。例えば、\"UTF-8\" は有効ですが、\"UTF8\" はそうではありません。https://" "www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl と https://www.iana." "org/assignments/character-sets/character-sets.xhtml を参照してください。"