-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathxml.etree.elementtree.po
More file actions
2348 lines (2071 loc) · 102 KB
/
Copy pathxml.etree.elementtree.po
File metadata and controls
2348 lines (2071 loc) · 102 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
# Cheesecake, 2025
# Takanori Suzuki <takanori@takanory.net>, 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 <takanori@takanory.net>, 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 ""
"<?xml version=\"1.0\"?>\n"
"<data>\n"
" <country name=\"Liechtenstein\">\n"
" <rank>1</rank>\n"
" <year>2008</year>\n"
" <gdppc>141100</gdppc>\n"
" <neighbor name=\"Austria\" direction=\"E\"/>\n"
" <neighbor name=\"Switzerland\" direction=\"W\"/>\n"
" </country>\n"
" <country name=\"Singapore\">\n"
" <rank>4</rank>\n"
" <year>2011</year>\n"
" <gdppc>59900</gdppc>\n"
" <neighbor name=\"Malaysia\" direction=\"N\"/>\n"
" </country>\n"
" <country name=\"Panama\">\n"
" <rank>68</rank>\n"
" <year>2011</year>\n"
" <gdppc>13600</gdppc>\n"
" <neighbor name=\"Costa Rica\" direction=\"W\"/>\n"
" <neighbor name=\"Colombia\" direction=\"E\"/>\n"
" </country>\n"
"</data>"
msgstr ""
"<?xml version=\"1.0\"?>\n"
"<data>\n"
" <country name=\"Liechtenstein\">\n"
" <rank>1</rank>\n"
" <year>2008</year>\n"
" <gdppc>141100</gdppc>\n"
" <neighbor name=\"Austria\" direction=\"E\"/>\n"
" <neighbor name=\"Switzerland\" direction=\"W\"/>\n"
" </country>\n"
" <country name=\"Singapore\">\n"
" <rank>4</rank>\n"
" <year>2011</year>\n"
" <gdppc>59900</gdppc>\n"
" <neighbor name=\"Malaysia\" direction=\"N\"/>\n"
" </country>\n"
" <country name=\"Panama\">\n"
" <rank>68</rank>\n"
" <year>2011</year>\n"
" <gdppc>13600</gdppc>\n"
" <neighbor name=\"Costa Rica\" direction=\"W\"/>\n"
" <neighbor name=\"Colombia\" direction=\"E\"/>\n"
" </country>\n"
"</data>"
#: ../../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('<mytag>sometext')\n"
">>> list(parser.read_events())\n"
"[('start', <Element 'mytag' at 0x7fa66db2be58>)]\n"
">>> parser.feed(' more text</mytag>')\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 <elementtree-xpath>`."
msgstr ""
":ref:`XPath <elementtree-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 ""
"<?xml version=\"1.0\"?>\n"
"<data>\n"
" <country name=\"Liechtenstein\">\n"
" <rank updated=\"yes\">2</rank>\n"
" <year>2008</year>\n"
" <gdppc>141100</gdppc>\n"
" <neighbor name=\"Austria\" direction=\"E\"/>\n"
" <neighbor name=\"Switzerland\" direction=\"W\"/>\n"
" </country>\n"
" <country name=\"Singapore\">\n"
" <rank updated=\"yes\">5</rank>\n"
" <year>2011</year>\n"
" <gdppc>59900</gdppc>\n"
" <neighbor name=\"Malaysia\" direction=\"N\"/>\n"
" </country>\n"
" <country name=\"Panama\">\n"
" <rank updated=\"yes\">69</rank>\n"
" <year>2011</year>\n"
" <gdppc>13600</gdppc>\n"
" <neighbor name=\"Costa Rica\" direction=\"W\"/>\n"
" <neighbor name=\"Colombia\" direction=\"E\"/>\n"
" </country>\n"
"</data>"
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 ""
"<?xml version=\"1.0\"?>\n"
"<data>\n"
" <country name=\"Liechtenstein\">\n"
" <rank updated=\"yes\">2</rank>\n"
" <year>2008</year>\n"
" <gdppc>141100</gdppc>\n"
" <neighbor name=\"Austria\" direction=\"E\"/>\n"
" <neighbor name=\"Switzerland\" direction=\"W\"/>\n"
" </country>\n"
" <country name=\"Singapore\">\n"
" <rank updated=\"yes\">5</rank>\n"
" <year>2011</year>\n"
" <gdppc>59900</gdppc>\n"
" <neighbor name=\"Malaysia\" direction=\"N\"/>\n"
" </country>\n"
"</data>"
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"
"<a><b /><c><d /></c></a>"
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 <https://en.wikipedia.org/wiki/"
"XML_namespace>`__, 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 <https://www.w3.org/"
"TR/xml-names/#defaulting>`__, that full URI gets prepended to all of the non-"
"prefixed tags."
msgstr ""
"XML 入力が `名前空間 <https://en.wikipedia.org/wiki/XML_namespace>`__ を持っ"
"ている場合、 ``prefix:sometag`` の形式で修飾されたタグと属性が、その "
"*prefix* が完全な *URI* で置換された ``{uri}sometag`` の形に展開されます。さ"
"らに、 `デフォルトの XML 名前空間 <https://www.w3.org/TR/xml-names/"
"#defaulting>`__ があると、修飾されていない全てのタグにその完全 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 ""
"<?xml version=\"1.0\"?>\n"
"<actors xmlns:fictional=\"http://characters.example.com\"\n"
" xmlns=\"http://people.example.com\">\n"
" <actor>\n"
" <name>John Cleese</name>\n"
" <fictional:character>Lancelot</fictional:character>\n"
" <fictional:character>Archie Leach</fictional:character>\n"
" </actor>\n"
" <actor>\n"
" <name>Eric Idle</name>\n"
" <fictional:character>Sir Robin</fictional:character>\n"
" <fictional:character>Gunther</fictional:character>\n"
" <fictional:character>Commander Clement</fictional:character>\n"
" </actor>\n"
"</actors>"
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 <https://www.w3."
"org/TR/xpath>`_ 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 式 <https://www.w3."
"org/TR/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 <elementtree-parsing-xml>` section::"
msgstr ""
"以下はこのモジュールの XPath 機能の一部を紹介する例です。:ref:`XML の解析 "
"<elementtree-parsing-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 <https://www.w3.org/TR/xml-c14n2/>`_ 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 = \"<root>...</root>\"\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