rexml 3.2.4 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +37 -0
- data/README.md +2 -14
- data/doc/rexml/context.rdoc +143 -0
- data/doc/rexml/tasks/rdoc/child.rdoc +87 -0
- data/doc/rexml/tasks/rdoc/document.rdoc +276 -0
- data/doc/rexml/tasks/rdoc/element.rdoc +602 -0
- data/doc/rexml/tasks/rdoc/node.rdoc +97 -0
- data/doc/rexml/tasks/rdoc/parent.rdoc +267 -0
- data/doc/rexml/tasks/tocs/child_toc.rdoc +12 -0
- data/doc/rexml/tasks/tocs/document_toc.rdoc +30 -0
- data/doc/rexml/tasks/tocs/element_toc.rdoc +55 -0
- data/doc/rexml/tasks/tocs/master_toc.rdoc +135 -0
- data/doc/rexml/tasks/tocs/node_toc.rdoc +16 -0
- data/doc/rexml/tasks/tocs/parent_toc.rdoc +25 -0
- data/lib/rexml.rb +3 -0
- data/lib/rexml/doctype.rb +55 -31
- data/lib/rexml/document.rb +194 -34
- data/lib/rexml/element.rb +1786 -456
- data/lib/rexml/light/node.rb +0 -8
- data/lib/rexml/parsers/baseparser.rb +139 -39
- data/lib/rexml/parsers/xpathparser.rb +25 -11
- data/lib/rexml/rexml.rb +27 -22
- data/lib/rexml/xpath_parser.rb +36 -30
- metadata +49 -11
- data/.gitignore +0 -9
- data/.travis.yml +0 -24
- data/Gemfile +0 -6
- data/Rakefile +0 -8
- data/rexml.gemspec +0 -84
@@ -0,0 +1,135 @@
|
|
1
|
+
== Tasks
|
2
|
+
|
3
|
+
=== {Child}[../../tasks/rdoc/child_rdoc.html]
|
4
|
+
- {Relationships}[../../tasks/rdoc/child_rdoc.html#label-Relationships]
|
5
|
+
- {Task: Set the Parent}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Set+the+Parent]
|
6
|
+
- {Task: Insert Previous Sibling}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Insert+Previous+Sibling]
|
7
|
+
- {Task: Insert Next Sibling}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Insert+Next+Sibling]
|
8
|
+
- {Removal or Replacement}[../../tasks/rdoc/child_rdoc.html#label-Removal+or+Replacement]
|
9
|
+
- {Task: Remove Child from Parent}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Remove+Child+from+Parent]
|
10
|
+
- {Task: Replace Child}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Replace+Child]
|
11
|
+
- {Document}[../../tasks/rdoc/child_rdoc.html#label-Document]
|
12
|
+
- {Task: Get the Document}[../../tasks/rdoc/child_rdoc.html#label-Task-3A+Get+the+Document]
|
13
|
+
|
14
|
+
=== {Document}[../../tasks/rdoc/document_rdoc.html]
|
15
|
+
- {New Document}[../../tasks/rdoc/document_rdoc.html#label-New+Document]
|
16
|
+
- {Task: Create an Empty Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Create+an+Empty+Document]
|
17
|
+
- {Task: Parse a String into a New Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Parse+a+String+into+a+New+Document]
|
18
|
+
- {Task: Parse an IO Stream into a New Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Parse+an+IO+Stream+into+a+New+Document]
|
19
|
+
- {Task: Create a Document from an Existing Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Create+a+Document+from+an+Existing+Document]
|
20
|
+
- {Task: Clone a Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Clone+a+Document]
|
21
|
+
- {Document Type}[../../tasks/rdoc/document_rdoc.html#label-Document+Type]
|
22
|
+
- {Task: Get the Document Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Document+Type]
|
23
|
+
- {Task: Set the Document Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Set+the+Document+Type]
|
24
|
+
- {XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-XML+Declaration]
|
25
|
+
- {Task: Get the XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+XML+Declaration]
|
26
|
+
- {Task: Set the XML Declaration}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Set+the+XML+Declaration]
|
27
|
+
- {Children}[../../tasks/rdoc/document_rdoc.html#label-Children]
|
28
|
+
- {Task: Add an Element Child}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Add+an+Element+Child]
|
29
|
+
- {Task: Add a Non-Element Child}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Add+a+Non-Element+Child]
|
30
|
+
- {Writing}[../../tasks/rdoc/document_rdoc.html#label-Writing]
|
31
|
+
- {Task: Write to $stdout}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+to+-24stdout]
|
32
|
+
- {Task: Write to IO Stream}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+to+IO+Stream]
|
33
|
+
- {Task: Write with No Indentation}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+with+No+Indentation]
|
34
|
+
- {Task: Write with Specified Indentation}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Write+with+Specified+Indentation]
|
35
|
+
- {Querying}[../../tasks/rdoc/document_rdoc.html#label-Querying]
|
36
|
+
- {Task: Get the Document}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Document]
|
37
|
+
- {Task: Get the Encoding}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Encoding]
|
38
|
+
- {Task: Get the Node Type}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Node+Type]
|
39
|
+
- {Task: Get the Root Element}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Root+Element]
|
40
|
+
- {Task: Determine Whether Stand-Alone}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Determine+Whether+Stand-Alone]
|
41
|
+
- {Task: Get the Version}[../../tasks/rdoc/document_rdoc.html#label-Task-3A+Get+the+Version]
|
42
|
+
|
43
|
+
=== {Element}[../../tasks/rdoc/element_rdoc.html]
|
44
|
+
- {New Element}[../../tasks/rdoc/element_rdoc.html#label-New+Element]
|
45
|
+
- {Task: Create a Default Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Default+Element]
|
46
|
+
- {Task: Create a Named Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Named+Element]
|
47
|
+
- {Task: Create an Element with Name and Parent}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+an+Element+with+Name+and+Parent]
|
48
|
+
- {Task: Create an Element with Name, Parent, and Context}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+an+Element+with+Name-2C+Parent-2C+and+Context]
|
49
|
+
- {Task: Create a Shallow Clone}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+a+Shallow+Clone]
|
50
|
+
- {Attributes}[../../tasks/rdoc/element_rdoc.html#label-Attributes]
|
51
|
+
- {Task: Create and Add an Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Attribute]
|
52
|
+
- {Task: Add an Existing Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Attribute]
|
53
|
+
- {Task: Add Multiple Attributes from a Hash}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+Multiple+Attributes+from+a+Hash]
|
54
|
+
- {Task: Add Multiple Attributes from an Array}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+Multiple+Attributes+from+an+Array]
|
55
|
+
- {Task: Retrieve the Value for an Attribute Name}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+Value+for+an+Attribute+Name]
|
56
|
+
- {Task: Retrieve the Attribute Value for a Name and Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+Attribute+Value+for+a+Name+and+Namespace]
|
57
|
+
- {Task: Delete an Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Attribute]
|
58
|
+
- {Task: Determine Whether the Element Has Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+the+Element+Has+Attributes]
|
59
|
+
- {Children}[../../tasks/rdoc/element_rdoc.html#label-Children]
|
60
|
+
- {Task: Create and Add an Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Element]
|
61
|
+
- {Task: Add an Existing Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Element]
|
62
|
+
- {Task: Create and Add an Element with Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Create+and+Add+an+Element+with+Attributes]
|
63
|
+
- {Task: Add an Existing Element with Added Attributes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+an+Existing+Element+with+Added+Attributes]
|
64
|
+
- {Task: Delete a Specified Element}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+a+Specified+Element]
|
65
|
+
- {Task: Delete an Element by Index}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Element+by+Index]
|
66
|
+
- {Task: Delete an Element by XPath}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+an+Element+by+XPath]
|
67
|
+
- {Task: Determine Whether Element Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+Element+Children]
|
68
|
+
- {Task: Get Element Descendants by XPath}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Element+Descendants+by+XPath]
|
69
|
+
- {Task: Get Next Element Sibling}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Next+Element+Sibling]
|
70
|
+
- {Task: Get Previous Element Sibling}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+Previous+Element+Sibling]
|
71
|
+
- {Task: Add a Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+a+Text+Node]
|
72
|
+
- {Task: Replace the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Replace+the+First+Text+Node]
|
73
|
+
- {Task: Remove the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Remove+the+First+Text+Node]
|
74
|
+
- {Task: Retrieve the First Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+the+First+Text+Node]
|
75
|
+
- {Task: Retrieve a Specific Text Node}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+a+Specific+Text+Node]
|
76
|
+
- {Task: Determine Whether the Element has Text Nodes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Determine+Whether+the+Element+has+Text+Nodes]
|
77
|
+
- {Task: Get the Child at a Given Index}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+the+Child+at+a+Given+Index]
|
78
|
+
- {Task: Get All CDATA Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+CDATA+Children]
|
79
|
+
- {Task: Get All Comment Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Comment+Children]
|
80
|
+
- {Task: Get All Processing Instruction Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Processing+Instruction+Children]
|
81
|
+
- {Task: Get All Text Children}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+All+Text+Children]
|
82
|
+
- {Namespaces}[../../tasks/rdoc/element_rdoc.html#label-Namespaces]
|
83
|
+
- {Task: Add a Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Add+a+Namespace]
|
84
|
+
- {Task: Delete the Default Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+the+Default+Namespace]
|
85
|
+
- {Task: Delete a Specific Namespace}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Delete+a+Specific+Namespace]
|
86
|
+
- {Task: Get a Namespace URI}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Get+a+Namespace+URI]
|
87
|
+
- {Task: Retrieve Namespaces}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+Namespaces]
|
88
|
+
- {Task: Retrieve Namespace Prefixes}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Retrieve+Namespace+Prefixes]
|
89
|
+
- {Iteration}[../../tasks/rdoc/element_rdoc.html#label-Iteration]
|
90
|
+
- {Task: Iterate Over Elements}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements]
|
91
|
+
- {Task: Iterate Over Elements Having a Specified Attribute}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute]
|
92
|
+
- {Task: Iterate Over Elements Having a Specified Attribute and Value}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+a+Specified+Attribute+and+Value]
|
93
|
+
- {Task: Iterate Over Elements Having Specified Text}[../../tasks/rdoc/element_rdoc.html#label-Task-3A+Iterate+Over+Elements+Having+Specified+Text]
|
94
|
+
- {Context}[../../tasks/rdoc/element_rdoc.html#label-Context]
|
95
|
+
- {Other Getters}[../../tasks/rdoc/element_rdoc.html#label-Other+Getters]
|
96
|
+
|
97
|
+
=== {Node}[../../tasks/rdoc/node_rdoc.html]
|
98
|
+
- {Siblings}[../../tasks/rdoc/node_rdoc.html#label-Siblings]
|
99
|
+
- {Task: Find Previous Sibling}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Previous+Sibling]
|
100
|
+
- {Task: Find Next Sibling}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Next+Sibling]
|
101
|
+
- {Position}[../../tasks/rdoc/node_rdoc.html#label-Position]
|
102
|
+
- {Task: Find Own Index Among Siblings}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Find+Own+Index+Among+Siblings]
|
103
|
+
- {Recursive Traversal}[../../tasks/rdoc/node_rdoc.html#label-Recursive+Traversal]
|
104
|
+
- {Task: Traverse Each Recursively}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Traverse+Each+Recursively]
|
105
|
+
- {Recursive Search}[../../tasks/rdoc/node_rdoc.html#label-Recursive+Search]
|
106
|
+
- {Task: Traverse Each Recursively}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Traverse+Each+Recursively]
|
107
|
+
- {Representation}[../../tasks/rdoc/node_rdoc.html#label-Representation]
|
108
|
+
- {Task: Represent a String}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Represent+a+String]
|
109
|
+
- {Parent?}[../../tasks/rdoc/node_rdoc.html#label-Parent-3F]
|
110
|
+
- {Task: Determine Whether the Node is a Parent}[../../tasks/rdoc/node_rdoc.html#label-Task-3A+Determine+Whether+the+Node+is+a+Parent]
|
111
|
+
|
112
|
+
=== {Parent}[../../tasks/rdoc/parent_rdoc.html]
|
113
|
+
- {Queries}[../../tasks/rdoc/parent_rdoc.html#label-Queries]
|
114
|
+
- {Task: Get the Count of Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Count+of+Children]
|
115
|
+
- {Task: Get the Child at a Given Index}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Child+at+a+Given+Index]
|
116
|
+
- {Task: Get the Index of a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Index+of+a+Given+Child]
|
117
|
+
- {Task: Get the Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Get+the+Children]
|
118
|
+
- {Task: Determine Whether the Node is a Parent}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Determine+Whether+the+Node+is+a+Parent]
|
119
|
+
- {Additions}[../../tasks/rdoc/parent_rdoc.html#label-Additions]
|
120
|
+
- {Task: Add a Child at the Beginning}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Add+a+Child+at+the+Beginning]
|
121
|
+
- {Task: Add a Child at the End}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Add+a+Child+at+the+End]
|
122
|
+
- {Task: Replace a Child with Another Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Replace+a+Child+with+Another+Child]
|
123
|
+
- {Task: Replace Multiple Children with Another Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Replace+Multiple+Children+with+Another+Child]
|
124
|
+
- {Task: Insert Child Before a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Insert+Child+Before+a+Given+Child]
|
125
|
+
- {Task: Insert Child After a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Insert+Child+After+a+Given+Child]
|
126
|
+
- {Deletions}[../../tasks/rdoc/parent_rdoc.html#label-Deletions]
|
127
|
+
- {Task: Remove a Given Child}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+a+Given+Child]
|
128
|
+
- {Task: Remove the Child at a Specified Offset}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+the+Child+at+a+Specified+Offset]
|
129
|
+
- {Task: Remove Children That Meet Specified Criteria}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria]
|
130
|
+
- {Iterations}[../../tasks/rdoc/parent_rdoc.html#label-Iterations]
|
131
|
+
- {Task: Iterate Over Children}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Iterate+Over+Children]
|
132
|
+
- {Task: Iterate Over Child Indexes}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Iterate+Over+Child+Indexes]
|
133
|
+
- {Clones}[../../tasks/rdoc/parent_rdoc.html#label-Clones]
|
134
|
+
- {Task: Clone Deeply}[../../tasks/rdoc/parent_rdoc.html#label-Task-3A+Clone+Deeply]
|
135
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Tasks on this page:
|
2
|
+
|
3
|
+
- {Siblings}[#label-Siblings]
|
4
|
+
- {Task: Find Previous Sibling}[#label-Task-3A+Find+Previous+Sibling]
|
5
|
+
- {Task: Find Next Sibling}[#label-Task-3A+Find+Next+Sibling]
|
6
|
+
- {Position}[#label-Position]
|
7
|
+
- {Task: Find Own Index Among Siblings}[#label-Task-3A+Find+Own+Index+Among+Siblings]
|
8
|
+
- {Recursive Traversal}[#label-Recursive+Traversal]
|
9
|
+
- {Task: Traverse Each Recursively}[#label-Task-3A+Traverse+Each+Recursively]
|
10
|
+
- {Recursive Search}[#label-Recursive+Search]
|
11
|
+
- {Task: Traverse Each Recursively}[#label-Task-3A+Traverse+Each+Recursively]
|
12
|
+
- {Representation}[#label-Representation]
|
13
|
+
- {Task: Represent a String}[#label-Task-3A+Represent+a+String]
|
14
|
+
- {Parent?}[#label-Parent-3F]
|
15
|
+
- {Task: Determine Whether the Node is a Parent}[#label-Task-3A+Determine+Whether+the+Node+is+a+Parent]
|
16
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Tasks on this page:
|
2
|
+
|
3
|
+
- {Queries}[#label-Queries]
|
4
|
+
- {Task: Get the Count of Children}[#label-Task-3A+Get+the+Count+of+Children]
|
5
|
+
- {Task: Get the Child at a Given Index}[#label-Task-3A+Get+the+Child+at+a+Given+Index]
|
6
|
+
- {Task: Get the Index of a Given Child}[#label-Task-3A+Get+the+Index+of+a+Given+Child]
|
7
|
+
- {Task: Get the Children}[#label-Task-3A+Get+the+Children]
|
8
|
+
- {Task: Determine Whether the Node is a Parent}[#label-Task-3A+Determine+Whether+the+Node+is+a+Parent]
|
9
|
+
- {Additions}[#label-Additions]
|
10
|
+
- {Task: Add a Child at the Beginning}[#label-Task-3A+Add+a+Child+at+the+Beginning]
|
11
|
+
- {Task: Add a Child at the End}[#label-Task-3A+Add+a+Child+at+the+End]
|
12
|
+
- {Task: Replace a Child with Another Child}[#label-Task-3A+Replace+a+Child+with+Another+Child]
|
13
|
+
- {Task: Replace Multiple Children with Another Child}[#label-Task-3A+Replace+Multiple+Children+with+Another+Child]
|
14
|
+
- {Task: Insert Child Before a Given Child}[#label-Task-3A+Insert+Child+Before+a+Given+Child]
|
15
|
+
- {Task: Insert Child After a Given Child}[#label-Task-3A+Insert+Child+After+a+Given+Child]
|
16
|
+
- {Deletions}[#label-Deletions]
|
17
|
+
- {Task: Remove a Given Child}[#label-Task-3A+Remove+a+Given+Child]
|
18
|
+
- {Task: Remove the Child at a Specified Offset}[#label-Task-3A+Remove+the+Child+at+a+Specified+Offset]
|
19
|
+
- {Task: Remove Children That Meet Specified Criteria}[#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria]
|
20
|
+
- {Iterations}[#label-Iterations]
|
21
|
+
- {Task: Iterate Over Children}[#label-Task-3A+Iterate+Over+Children]
|
22
|
+
- {Task: Iterate Over Child Indexes}[#label-Task-3A+Iterate+Over+Child+Indexes]
|
23
|
+
- {Clones}[#label-Clones]
|
24
|
+
- {Task: Clone Deeply}[#label-Task-3A+Clone+Deeply]
|
25
|
+
|
data/lib/rexml.rb
ADDED
data/lib/rexml/doctype.rb
CHANGED
@@ -7,6 +7,44 @@ require_relative 'attlistdecl'
|
|
7
7
|
require_relative 'xmltokens'
|
8
8
|
|
9
9
|
module REXML
|
10
|
+
class ReferenceWriter
|
11
|
+
def initialize(id_type,
|
12
|
+
public_id_literal,
|
13
|
+
system_literal,
|
14
|
+
context=nil)
|
15
|
+
@id_type = id_type
|
16
|
+
@public_id_literal = public_id_literal
|
17
|
+
@system_literal = system_literal
|
18
|
+
if context and context[:prologue_quote] == :apostrophe
|
19
|
+
@default_quote = "'"
|
20
|
+
else
|
21
|
+
@default_quote = "\""
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def write(output)
|
26
|
+
output << " #{@id_type}"
|
27
|
+
if @public_id_literal
|
28
|
+
if @public_id_literal.include?("'")
|
29
|
+
quote = "\""
|
30
|
+
else
|
31
|
+
quote = @default_quote
|
32
|
+
end
|
33
|
+
output << " #{quote}#{@public_id_literal}#{quote}"
|
34
|
+
end
|
35
|
+
if @system_literal
|
36
|
+
if @system_literal.include?("'")
|
37
|
+
quote = "\""
|
38
|
+
elsif @system_literal.include?("\"")
|
39
|
+
quote = "'"
|
40
|
+
else
|
41
|
+
quote = @default_quote
|
42
|
+
end
|
43
|
+
output << " #{quote}#{@system_literal}#{quote}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
10
48
|
# Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
|
11
49
|
# ... >. DOCTYPES can be used to declare the DTD of a document, as well as
|
12
50
|
# being used to declare entities used in the document.
|
@@ -50,6 +88,8 @@ module REXML
|
|
50
88
|
super( parent )
|
51
89
|
@name = first.name
|
52
90
|
@external_id = first.external_id
|
91
|
+
@long_name = first.instance_variable_get(:@long_name)
|
92
|
+
@uri = first.instance_variable_get(:@uri)
|
53
93
|
elsif first.kind_of? Array
|
54
94
|
super( parent )
|
55
95
|
@name = first[0]
|
@@ -108,19 +148,17 @@ module REXML
|
|
108
148
|
# Ignored
|
109
149
|
def write( output, indent=0, transitive=false, ie_hack=false )
|
110
150
|
f = REXML::Formatters::Default.new
|
111
|
-
c = context
|
112
|
-
if c and c[:prologue_quote] == :apostrophe
|
113
|
-
quote = "'"
|
114
|
-
else
|
115
|
-
quote = "\""
|
116
|
-
end
|
117
151
|
indent( output, indent )
|
118
152
|
output << START
|
119
153
|
output << ' '
|
120
154
|
output << @name
|
121
|
-
|
122
|
-
|
123
|
-
|
155
|
+
if @external_id
|
156
|
+
reference_writer = ReferenceWriter.new(@external_id,
|
157
|
+
@long_name,
|
158
|
+
@uri,
|
159
|
+
context)
|
160
|
+
reference_writer.write(output)
|
161
|
+
end
|
124
162
|
unless @children.empty?
|
125
163
|
output << ' ['
|
126
164
|
@children.each { |child|
|
@@ -159,7 +197,7 @@ module REXML
|
|
159
197
|
when "SYSTEM"
|
160
198
|
nil
|
161
199
|
when "PUBLIC"
|
162
|
-
|
200
|
+
@long_name
|
163
201
|
end
|
164
202
|
end
|
165
203
|
|
@@ -169,9 +207,9 @@ module REXML
|
|
169
207
|
def system
|
170
208
|
case @external_id
|
171
209
|
when "SYSTEM"
|
172
|
-
|
210
|
+
@long_name
|
173
211
|
when "PUBLIC"
|
174
|
-
@uri.kind_of?(String) ?
|
212
|
+
@uri.kind_of?(String) ? @uri : nil
|
175
213
|
end
|
176
214
|
end
|
177
215
|
|
@@ -193,15 +231,6 @@ module REXML
|
|
193
231
|
notation_decl.name == name
|
194
232
|
}
|
195
233
|
end
|
196
|
-
|
197
|
-
private
|
198
|
-
|
199
|
-
# Method contributed by Henrik Martensson
|
200
|
-
def strip_quotes(quoted_string)
|
201
|
-
quoted_string =~ /^[\'\"].*[\'\"]$/ ?
|
202
|
-
quoted_string[1, quoted_string.length-2] :
|
203
|
-
quoted_string
|
204
|
-
end
|
205
234
|
end
|
206
235
|
|
207
236
|
# We don't really handle any of these since we're not a validating
|
@@ -259,16 +288,11 @@ module REXML
|
|
259
288
|
end
|
260
289
|
|
261
290
|
def to_s
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
quote = "\""
|
268
|
-
end
|
269
|
-
notation = "<!NOTATION #{@name} #{@middle}"
|
270
|
-
notation << " #{quote}#{@public}#{quote}" if @public
|
271
|
-
notation << " #{quote}#{@system}#{quote}" if @system
|
291
|
+
context = nil
|
292
|
+
context = parent.context if parent
|
293
|
+
notation = "<!NOTATION #{@name}"
|
294
|
+
reference_writer = ReferenceWriter.new(@middle, @public, @system, context)
|
295
|
+
reference_writer.write(notation)
|
272
296
|
notation << ">"
|
273
297
|
notation
|
274
298
|
end
|
data/lib/rexml/document.rb
CHANGED
@@ -14,25 +14,81 @@ require_relative "parsers/streamparser"
|
|
14
14
|
require_relative "parsers/treeparser"
|
15
15
|
|
16
16
|
module REXML
|
17
|
-
# Represents
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
17
|
+
# Represents an XML document.
|
18
|
+
#
|
19
|
+
# A document may have:
|
20
|
+
#
|
21
|
+
# - A single child that may be accessed via method #root.
|
22
|
+
# - An XML declaration.
|
23
|
+
# - A document type.
|
24
|
+
# - Processing instructions.
|
25
|
+
#
|
26
|
+
# == In a Hurry?
|
27
|
+
#
|
28
|
+
# If you're somewhat familiar with XML
|
29
|
+
# and have a particular task in mind,
|
30
|
+
# you may want to see the
|
31
|
+
# {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html],
|
32
|
+
# and in particular, the
|
33
|
+
# {tasks page for documents}[../doc/rexml/tasks/tocs/document_toc_rdoc.html].
|
34
|
+
#
|
22
35
|
class Document < Element
|
23
|
-
# A convenient default XML declaration.
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
36
|
+
# A convenient default XML declaration. Use:
|
37
|
+
#
|
38
|
+
# mydoc << XMLDecl.default
|
39
|
+
#
|
27
40
|
DECLARATION = XMLDecl.default
|
28
41
|
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
42
|
+
# :call-seq:
|
43
|
+
# new(string = nil, context = {}) -> new_document
|
44
|
+
# new(io_stream = nil, context = {}) -> new_document
|
45
|
+
# new(document = nil, context = {}) -> new_document
|
46
|
+
#
|
47
|
+
# Returns a new \REXML::Document object.
|
48
|
+
#
|
49
|
+
# When no arguments are given,
|
50
|
+
# returns an empty document:
|
51
|
+
#
|
52
|
+
# d = REXML::Document.new
|
53
|
+
# d.to_s # => ""
|
54
|
+
#
|
55
|
+
# When argument +string+ is given, it must be a string
|
56
|
+
# containing a valid XML document:
|
57
|
+
#
|
58
|
+
# xml_string = '<root><foo>Foo</foo><bar>Bar</bar></root>'
|
59
|
+
# d = REXML::Document.new(xml_string)
|
60
|
+
# d.to_s # => "<root><foo>Foo</foo><bar>Bar</bar></root>"
|
61
|
+
#
|
62
|
+
# When argument +io_stream+ is given, it must be an \IO object
|
63
|
+
# that is opened for reading, and when read must return a valid XML document:
|
64
|
+
#
|
65
|
+
# File.write('t.xml', xml_string)
|
66
|
+
# d = File.open('t.xml', 'r') do |io|
|
67
|
+
# REXML::Document.new(io)
|
68
|
+
# end
|
69
|
+
# d.to_s # => "<root><foo>Foo</foo><bar>Bar</bar></root>"
|
70
|
+
#
|
71
|
+
# When argument +document+ is given, it must be an existing
|
72
|
+
# document object, whose context and attributes (but not chidren)
|
73
|
+
# are cloned into the new document:
|
74
|
+
#
|
75
|
+
# d = REXML::Document.new(xml_string)
|
76
|
+
# d.children # => [<root> ... </>]
|
77
|
+
# d.context = {raw: :all, compress_whitespace: :all}
|
78
|
+
# d.add_attributes({'bar' => 0, 'baz' => 1})
|
79
|
+
# d1 = REXML::Document.new(d)
|
80
|
+
# d1.children # => []
|
81
|
+
# d1.context # => {:raw=>:all, :compress_whitespace=>:all}
|
82
|
+
# d1.attributes # => {"bar"=>bar='0', "baz"=>baz='1'}
|
83
|
+
#
|
84
|
+
# When argument +context+ is given, it must be a hash
|
85
|
+
# containing context entries for the document;
|
86
|
+
# see {Element Context}[../doc/rexml/context_rdoc.html]:
|
87
|
+
#
|
88
|
+
# context = {raw: :all, compress_whitespace: :all}
|
89
|
+
# d = REXML::Document.new(xml_string, context)
|
90
|
+
# d.context # => {:raw=>:all, :compress_whitespace=>:all}
|
91
|
+
#
|
36
92
|
def initialize( source = nil, context = {} )
|
37
93
|
@entity_expansion_count = 0
|
38
94
|
super()
|
@@ -46,26 +102,71 @@ module REXML
|
|
46
102
|
end
|
47
103
|
end
|
48
104
|
|
105
|
+
# :call-seq:
|
106
|
+
# node_type -> :document
|
107
|
+
#
|
108
|
+
# Returns the symbol +:document+.
|
109
|
+
#
|
49
110
|
def node_type
|
50
111
|
:document
|
51
112
|
end
|
52
113
|
|
53
|
-
#
|
114
|
+
# :call-seq:
|
115
|
+
# clone -> new_document
|
116
|
+
#
|
117
|
+
# Returns the new document resulting from executing
|
118
|
+
# <tt>Document.new(self)</tt>. See Document.new.
|
119
|
+
#
|
54
120
|
def clone
|
55
121
|
Document.new self
|
56
122
|
end
|
57
123
|
|
58
|
-
#
|
124
|
+
# :call-seq:
|
125
|
+
# expanded_name -> empty_string
|
126
|
+
#
|
127
|
+
# Returns an empty string.
|
128
|
+
#
|
59
129
|
def expanded_name
|
60
130
|
''
|
61
131
|
#d = doc_type
|
62
132
|
#d ? d.name : "UNDEFINED"
|
63
133
|
end
|
64
|
-
|
65
134
|
alias :name :expanded_name
|
66
135
|
|
67
|
-
#
|
68
|
-
#
|
136
|
+
# :call-seq:
|
137
|
+
# add(xml_decl) -> self
|
138
|
+
# add(doc_type) -> self
|
139
|
+
# add(object) -> self
|
140
|
+
#
|
141
|
+
# Adds an object to the document; returns +self+.
|
142
|
+
#
|
143
|
+
# When argument +xml_decl+ is given,
|
144
|
+
# it must be an REXML::XMLDecl object,
|
145
|
+
# which becomes the XML declaration for the document,
|
146
|
+
# replacing the previous XML declaration if any:
|
147
|
+
#
|
148
|
+
# d = REXML::Document.new
|
149
|
+
# d.xml_decl.to_s # => ""
|
150
|
+
# d.add(REXML::XMLDecl.new('2.0'))
|
151
|
+
# d.xml_decl.to_s # => "<?xml version='2.0'?>"
|
152
|
+
#
|
153
|
+
# When argument +doc_type+ is given,
|
154
|
+
# it must be an REXML::DocType object,
|
155
|
+
# which becomes the document type for the document,
|
156
|
+
# replacing the previous document type, if any:
|
157
|
+
#
|
158
|
+
# d = REXML::Document.new
|
159
|
+
# d.doctype.to_s # => ""
|
160
|
+
# d.add(REXML::DocType.new('foo'))
|
161
|
+
# d.doctype.to_s # => "<!DOCTYPE foo>"
|
162
|
+
#
|
163
|
+
# When argument +object+ (not an REXML::XMLDecl or REXML::DocType object)
|
164
|
+
# is given it is added as the last child:
|
165
|
+
#
|
166
|
+
# d = REXML::Document.new
|
167
|
+
# d.add(REXML::Element.new('foo'))
|
168
|
+
# d.to_s # => "<foo/>"
|
169
|
+
#
|
69
170
|
def add( child )
|
70
171
|
if child.kind_of? XMLDecl
|
71
172
|
if @children[0].kind_of? XMLDecl
|
@@ -99,49 +200,108 @@ module REXML
|
|
99
200
|
end
|
100
201
|
alias :<< :add
|
101
202
|
|
203
|
+
# :call-seq:
|
204
|
+
# add_element(name_or_element = nil, attributes = nil) -> new_element
|
205
|
+
#
|
206
|
+
# Adds an element to the document by calling REXML::Element.add_element:
|
207
|
+
#
|
208
|
+
# REXML::Element.add_element(name_or_element, attributes)
|
102
209
|
def add_element(arg=nil, arg2=nil)
|
103
210
|
rv = super
|
104
211
|
raise "attempted adding second root element to document" if @elements.size > 1
|
105
212
|
rv
|
106
213
|
end
|
107
214
|
|
108
|
-
#
|
109
|
-
#
|
215
|
+
# :call-seq:
|
216
|
+
# root -> root_element or nil
|
217
|
+
#
|
218
|
+
# Returns the root element of the document, if it exists, otherwise +nil+:
|
219
|
+
#
|
220
|
+
# d = REXML::Document.new('<root></root>')
|
221
|
+
# d.root # => <root/>
|
222
|
+
# d = REXML::Document.new('')
|
223
|
+
# d.root # => nil
|
224
|
+
#
|
110
225
|
def root
|
111
226
|
elements[1]
|
112
227
|
#self
|
113
228
|
#@children.find { |item| item.kind_of? Element }
|
114
229
|
end
|
115
230
|
|
116
|
-
#
|
117
|
-
#
|
231
|
+
# :call-seq:
|
232
|
+
# doctype -> doc_type or nil
|
233
|
+
#
|
234
|
+
# Returns the DocType object for the document, if it exists, otherwise +nil+:
|
235
|
+
#
|
236
|
+
# d = REXML::Document.new('<!DOCTYPE document SYSTEM "subjects.dtd">')
|
237
|
+
# d.doctype.class # => REXML::DocType
|
238
|
+
# d = REXML::Document.new('')
|
239
|
+
# d.doctype.class # => nil
|
240
|
+
#
|
118
241
|
def doctype
|
119
242
|
@children.find { |item| item.kind_of? DocType }
|
120
243
|
end
|
121
244
|
|
122
|
-
#
|
123
|
-
#
|
245
|
+
# :call-seq:
|
246
|
+
# xml_decl -> xml_decl
|
247
|
+
#
|
248
|
+
# Returns the XMLDecl object for the document, if it exists,
|
249
|
+
# otherwise the default XMLDecl object:
|
250
|
+
#
|
251
|
+
# d = REXML::Document.new('<?xml version="1.0" encoding="UTF-8"?>')
|
252
|
+
# d.xml_decl.class # => REXML::XMLDecl
|
253
|
+
# d.xml_decl.to_s # => "<?xml version='1.0' encoding='UTF-8'?>"
|
254
|
+
# d = REXML::Document.new('')
|
255
|
+
# d.xml_decl.class # => REXML::XMLDecl
|
256
|
+
# d.xml_decl.to_s # => ""
|
257
|
+
#
|
124
258
|
def xml_decl
|
125
259
|
rv = @children[0]
|
126
260
|
return rv if rv.kind_of? XMLDecl
|
127
261
|
@children.unshift(XMLDecl.default)[0]
|
128
262
|
end
|
129
263
|
|
130
|
-
#
|
131
|
-
#
|
264
|
+
# :call-seq:
|
265
|
+
# version -> version_string
|
266
|
+
#
|
267
|
+
# Returns the XMLDecl version of this document as a string,
|
268
|
+
# if it has been set, otherwise the default version:
|
269
|
+
#
|
270
|
+
# d = REXML::Document.new('<?xml version="2.0" encoding="UTF-8"?>')
|
271
|
+
# d.version # => "2.0"
|
272
|
+
# d = REXML::Document.new('')
|
273
|
+
# d.version # => "1.0"
|
274
|
+
#
|
132
275
|
def version
|
133
276
|
xml_decl().version
|
134
277
|
end
|
135
278
|
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
279
|
+
# :call-seq:
|
280
|
+
# encoding -> encoding_string
|
281
|
+
#
|
282
|
+
# Returns the XMLDecl encoding of the document,
|
283
|
+
# if it has been set, otherwise the default encoding:
|
284
|
+
#
|
285
|
+
# d = REXML::Document.new('<?xml version="1.0" encoding="UTF-16"?>')
|
286
|
+
# d.encoding # => "UTF-16"
|
287
|
+
# d = REXML::Document.new('')
|
288
|
+
# d.encoding # => "UTF-8"
|
289
|
+
#
|
139
290
|
def encoding
|
140
291
|
xml_decl().encoding
|
141
292
|
end
|
142
293
|
|
143
|
-
#
|
144
|
-
#
|
294
|
+
# :call-seq:
|
295
|
+
# stand_alone?
|
296
|
+
#
|
297
|
+
# Returns the XMLDecl standalone value of the document as a string,
|
298
|
+
# if it has been set, otherwise the default standalone value:
|
299
|
+
#
|
300
|
+
# d = REXML::Document.new('<?xml standalone="yes"?>')
|
301
|
+
# d.stand_alone? # => "yes"
|
302
|
+
# d = REXML::Document.new('')
|
303
|
+
# d.stand_alone? # => nil
|
304
|
+
#
|
145
305
|
def stand_alone?
|
146
306
|
xml_decl().stand_alone?
|
147
307
|
end
|