nokogiri 1.13.0-x86_64-linux → 1.13.1-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +1 -1
- data/ext/nokogiri/xslt_stylesheet.c +107 -9
- data/lib/nokogiri/css/parser.rb +351 -340
- data/lib/nokogiri/css/parser.y +241 -244
- data/lib/nokogiri/css/tokenizer.rb +2 -2
- data/lib/nokogiri/css/tokenizer.rex +1 -1
- data/lib/nokogiri/css/xpath_visitor.rb +16 -18
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/searchable.rb +51 -40
- data/lib/nokogiri/xslt.rb +19 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d2711cceb8e53569e6aab5eafd143c8897ebc448f5bf97ce8479ab673c12601
|
4
|
+
data.tar.gz: 6580abc74f864e34ea6b75c000e86790290ec25d9fa2b5959dca2d04a0495762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca960b5d040668c861ddc5fae057d7f9be12b591dd2bcaced07e60bc7371493e8e33e945e62ca655eb46d4b61b38ee765c1265bc755c03de7a90d5f37849137
|
7
|
+
data.tar.gz: 1771a0d92475fe823978e167f42008c0fed1323bbaff1c16f77e282140b7ea442af54cf3850cc2ba042a145c759e36a4e9316677e61a615cbd42f73e98766e13
|
data/Gemfile
CHANGED
@@ -133,7 +133,7 @@ extern "C" {
|
|
133
133
|
#ifndef WITH_MODULES
|
134
134
|
#define WITH_MODULES
|
135
135
|
#endif
|
136
|
-
#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/home/flavorjones/code/oss/nokogiri/ports/
|
136
|
+
#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/home/flavorjones/code/oss/nokogiri/ports/x86-linux/libxslt/1.1.34/lib/libxslt-plugins"
|
137
137
|
#endif
|
138
138
|
|
139
139
|
/**
|
@@ -107,19 +107,117 @@ serialize(VALUE self, VALUE xmlobj)
|
|
107
107
|
}
|
108
108
|
|
109
109
|
/*
|
110
|
-
*
|
111
|
-
*
|
110
|
+
* call-seq:
|
111
|
+
* transform(document)
|
112
|
+
* transform(document, params = {})
|
113
|
+
*
|
114
|
+
* Apply an XSLT stylesheet to an XML::Document.
|
115
|
+
*
|
116
|
+
* [Parameters]
|
117
|
+
* - +document+ (Nokogiri::XML::Document) the document to be transformed.
|
118
|
+
* - +params+ (Hash, Array) strings used as XSLT parameters.
|
119
|
+
*
|
120
|
+
* [Returns] Nokogiri::XML::Document
|
121
|
+
*
|
122
|
+
* *Example* of basic transformation:
|
123
|
+
*
|
124
|
+
* xslt = <<~XSLT
|
125
|
+
* <xsl:stylesheet version="1.0"
|
126
|
+
* xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
127
|
+
*
|
128
|
+
* <xsl:param name="title"/>
|
129
|
+
*
|
130
|
+
* <xsl:template match="/">
|
131
|
+
* <html>
|
132
|
+
* <body>
|
133
|
+
* <h1><xsl:value-of select="$title"/></h1>
|
134
|
+
* <ol>
|
135
|
+
* <xsl:for-each select="staff/employee">
|
136
|
+
* <li><xsl:value-of select="employeeId"></li>
|
137
|
+
* </xsl:for-each>
|
138
|
+
* </ol>
|
139
|
+
* </body>
|
140
|
+
* </html>
|
141
|
+
* </xsl:stylesheet>
|
142
|
+
* XSLT
|
143
|
+
*
|
144
|
+
* xml = <<~XML
|
145
|
+
* <?xml version="1.0"?>
|
146
|
+
* <staff>
|
147
|
+
* <employee>
|
148
|
+
* <employeeId>EMP0001</employeeId>
|
149
|
+
* <position>Accountant</position>
|
150
|
+
* </employee>
|
151
|
+
* <employee>
|
152
|
+
* <employeeId>EMP0002</employeeId>
|
153
|
+
* <position>Developer</position>
|
154
|
+
* </employee>
|
155
|
+
* </staff>
|
156
|
+
* XML
|
157
|
+
*
|
158
|
+
* doc = Nokogiri::XML::Document.parse(xml)
|
159
|
+
* stylesheet = Nokogiri::XSLT.parse(xslt)
|
160
|
+
*
|
161
|
+
* ⚠ Note that the +h1+ element is empty because no param has been provided!
|
162
|
+
*
|
163
|
+
* stylesheet.transform(doc).to_xml
|
164
|
+
* # => "<html><body>\n" +
|
165
|
+
* # "<h1></h1>\n" +
|
166
|
+
* # "<ol>\n" +
|
167
|
+
* # "<li>EMP0001</li>\n" +
|
168
|
+
* # "<li>EMP0002</li>\n" +
|
169
|
+
* # "</ol>\n" +
|
170
|
+
* # "</body></html>\n"
|
171
|
+
*
|
172
|
+
* *Example* of using an input parameter hash:
|
173
|
+
*
|
174
|
+
* ⚠ The title is populated, but note how we need to quote-escape the value.
|
175
|
+
*
|
176
|
+
* stylesheet.transform(doc, { "title" => "'Employee List'" }).to_xml
|
177
|
+
* # => "<html><body>\n" +
|
178
|
+
* # "<h1>Employee List</h1>\n" +
|
179
|
+
* # "<ol>\n" +
|
180
|
+
* # "<li>EMP0001</li>\n" +
|
181
|
+
* # "<li>EMP0002</li>\n" +
|
182
|
+
* # "</ol>\n" +
|
183
|
+
* # "</body></html>\n"
|
184
|
+
*
|
185
|
+
* *Example* using the XSLT.quote_params helper method to safely quote-escape strings:
|
186
|
+
*
|
187
|
+
* stylesheet.transform(doc, Nokogiri::XSLT.quote_params({ "title" => "Aaron's List" })).to_xml
|
188
|
+
* # => "<html><body>\n" +
|
189
|
+
* # "<h1>Aaron's List</h1>\n" +
|
190
|
+
* # "<ol>\n" +
|
191
|
+
* # "<li>EMP0001</li>\n" +
|
192
|
+
* # "<li>EMP0002</li>\n" +
|
193
|
+
* # "</ol>\n" +
|
194
|
+
* # "</body></html>\n"
|
195
|
+
*
|
196
|
+
* *Example* using an array of XSLT parameters
|
197
|
+
*
|
198
|
+
* You can also use an array if you want to.
|
112
199
|
*
|
113
|
-
*
|
114
|
-
*
|
115
|
-
*
|
200
|
+
* stylesheet.transform(doc, ["title", "'Employee List'"]).to_xml
|
201
|
+
* # => "<html><body>\n" +
|
202
|
+
* # "<h1>Employee List</h1>\n" +
|
203
|
+
* # "<ol>\n" +
|
204
|
+
* # "<li>EMP0001</li>\n" +
|
205
|
+
* # "<li>EMP0002</li>\n" +
|
206
|
+
* # "</ol>\n" +
|
207
|
+
* # "</body></html>\n"
|
116
208
|
*
|
117
|
-
*
|
209
|
+
* Or pass an array to XSLT.quote_params:
|
118
210
|
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
211
|
+
* stylesheet.transform(doc, Nokogiri::XSLT.quote_params(["title", "Aaron's List"])).to_xml
|
212
|
+
* # => "<html><body>\n" +
|
213
|
+
* # "<h1>Aaron's List</h1>\n" +
|
214
|
+
* # "<ol>\n" +
|
215
|
+
* # "<li>EMP0001</li>\n" +
|
216
|
+
* # "<li>EMP0002</li>\n" +
|
217
|
+
* # "</ol>\n" +
|
218
|
+
* # "</body></html>\n"
|
122
219
|
*
|
220
|
+
* See: Nokogiri::XSLT.quote_params
|
123
221
|
*/
|
124
222
|
static VALUE
|
125
223
|
transform(int argc, VALUE *argv, VALUE self)
|