libxslt-ruby 0.7.0-x86-mswin32-60 → 0.8.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/README +141 -141
- data/doc/classes/LibXSLT.html +120 -0
- data/doc/classes/LibXSLT/XSLT.html +207 -0
- data/doc/classes/{XSLT → LibXSLT/XSLT}/Stylesheet.html +22 -17
- data/doc/classes/LibXSLT/XSLT/TransformContext.html +111 -0
- data/doc/classes/{XSLT/TransformContext.html → LibXSLT/XSLTError.html} +5 -5
- data/doc/classes/XSLT.html +12 -103
- data/doc/created.rid +1 -1
- data/doc/files/CHANGES.html +18 -3
- data/doc/files/README.html +4 -4
- data/doc/files/ext/libxslt/libxslt_c.html +1 -1
- data/doc/files/ext/libxslt/ruby_xslt_stylesheet_c.html +1 -1
- data/doc/files/ext/libxslt/ruby_xslt_transform_context_c.html +1 -1
- data/doc/files/lib/{deprecated_rb.html → libxslt/deprecated_rb.html} +3 -3
- data/doc/files/lib/libxslt_rb.html +3 -3
- data/doc/fr_class_index.html +5 -2
- data/doc/fr_file_index.html +1 -1
- data/doc/fr_method_index.html +2 -2
- data/ext/libxslt/libxslt.c +22 -18
- data/ext/libxslt/libxslt.h +4 -6
- data/ext/libxslt/ruby_xslt_stylesheet.c +59 -41
- data/ext/libxslt/ruby_xslt_transform_context.c +3 -3
- data/ext/libxslt/version.h +2 -2
- data/lib/libxslt.rb +8 -2
- data/lib/libxslt/deprecated.rb +66 -0
- data/lib/libxslt_ruby.so +0 -0
- data/mingw/libxslt_ruby.so +0 -0
- data/setup.rb +1585 -0
- data/vc/libxslt_ruby.vcproj +2 -2
- metadata +16 -19
- data/lib/deprecated.rb +0 -66
- data/tests/files/commentary.dtd +0 -34
- data/tests/files/fuzface.xml +0 -154
- data/tests/files/fuzface.xsl +0 -4
- data/tests/files/params.xml +0 -2
- data/tests/files/params.xsl +0 -11
- data/tests/files/ramblings.xsl +0 -46
- data/tests/test_deprecated.rb +0 -99
- data/tests/test_libxslt.rb +0 -21
- data/tests/test_stylesheet.rb +0 -64
- data/tests/test_suite.rb +0 -3
@@ -8,7 +8,7 @@
|
|
8
8
|
<title>File: deprecated.rb</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
12
|
<script type="text/javascript">
|
13
13
|
// <![CDATA[
|
14
14
|
|
@@ -51,12 +51,12 @@
|
|
51
51
|
<table class="header-table">
|
52
52
|
<tr class="top-aligned-row">
|
53
53
|
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/deprecated.rb
|
54
|
+
<td>lib/libxslt/deprecated.rb
|
55
55
|
</td>
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Jul 15 15:48:02 Mountain Daylight Time 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Jul 15 15:41:51 Mountain Daylight Time 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -74,8 +74,8 @@
|
|
74
74
|
|
75
75
|
<div class="name-list">
|
76
76
|
libxml
|
77
|
-
libxslt_ruby
|
78
|
-
deprecated
|
77
|
+
libxslt_ruby
|
78
|
+
libxslt/deprecated
|
79
79
|
</div>
|
80
80
|
</div>
|
81
81
|
|
data/doc/fr_class_index.html
CHANGED
@@ -20,9 +20,12 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Classes</h1>
|
22
22
|
<div id="index-entries">
|
23
|
+
<a href="classes/LibXSLT.html">LibXSLT</a><br />
|
24
|
+
<a href="classes/LibXSLT/XSLT.html">LibXSLT::XSLT</a><br />
|
25
|
+
<a href="classes/LibXSLT/XSLT/Stylesheet.html">LibXSLT::XSLT::Stylesheet</a><br />
|
26
|
+
<a href="classes/LibXSLT/XSLT/TransformContext.html">LibXSLT::XSLT::TransformContext</a><br />
|
27
|
+
<a href="classes/LibXSLT/XSLTError.html">LibXSLT::XSLTError</a><br />
|
23
28
|
<a href="classes/XSLT.html">XSLT</a><br />
|
24
|
-
<a href="classes/XSLT/Stylesheet.html">XSLT::Stylesheet</a><br />
|
25
|
-
<a href="classes/XSLT/TransformContext.html">XSLT::TransformContext</a><br />
|
26
29
|
</div>
|
27
30
|
</div>
|
28
31
|
</body>
|
data/doc/fr_file_index.html
CHANGED
@@ -26,8 +26,8 @@
|
|
26
26
|
<a href="files/ext/libxslt/libxslt_c.html">ext/libxslt/libxslt.c</a><br />
|
27
27
|
<a href="files/ext/libxslt/ruby_xslt_stylesheet_c.html">ext/libxslt/ruby_xslt_stylesheet.c</a><br />
|
28
28
|
<a href="files/ext/libxslt/ruby_xslt_transform_context_c.html">ext/libxslt/ruby_xslt_transform_context.c</a><br />
|
29
|
-
<a href="files/lib/deprecated_rb.html">lib/deprecated.rb</a><br />
|
30
29
|
<a href="files/lib/libxslt_rb.html">lib/libxslt.rb</a><br />
|
30
|
+
<a href="files/lib/libxslt/deprecated_rb.html">lib/libxslt/deprecated.rb</a><br />
|
31
31
|
</div>
|
32
32
|
</div>
|
33
33
|
</body>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,8 +20,8 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/XSLT/Stylesheet.html#M000002">apply (XSLT::Stylesheet)</a><br />
|
24
|
-
<a href="classes/XSLT/Stylesheet.html#M000001">new (XSLT::Stylesheet)</a><br />
|
23
|
+
<a href="classes/LibXSLT/XSLT/Stylesheet.html#M000002">apply (LibXSLT::XSLT::Stylesheet)</a><br />
|
24
|
+
<a href="classes/LibXSLT/XSLT/Stylesheet.html#M000001">new (LibXSLT::XSLT::Stylesheet)</a><br />
|
25
25
|
</div>
|
26
26
|
</div>
|
27
27
|
</body>
|
data/ext/libxslt/libxslt.c
CHANGED
@@ -5,40 +5,42 @@
|
|
5
5
|
#include "libxslt.h"
|
6
6
|
#include "libxml/xmlversion.h"
|
7
7
|
|
8
|
+
VALUE cLibXSLT;
|
8
9
|
VALUE cXSLT;
|
9
|
-
VALUE
|
10
|
-
|
11
|
-
/*
|
12
|
-
* Document-class: XSLT
|
13
|
-
*
|
14
|
-
* The libxslt gem provides Ruby language bindings for GNOME's Libxslt
|
15
|
-
* toolkit. It is free software, released under the MIT License.
|
16
|
-
*
|
17
|
-
* Using the bindings is straightforward:
|
18
|
-
*
|
10
|
+
VALUE eXSLTError;
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Document-class: LibXSLT::XSLT
|
14
|
+
*
|
15
|
+
* The libxslt gem provides Ruby language bindings for GNOME's Libxslt
|
16
|
+
* toolkit. It is free software, released under the MIT License.
|
17
|
+
*
|
18
|
+
* Using the bindings is straightforward:
|
19
|
+
*
|
19
20
|
* stylesheet_doc = XML::Document.file('stylesheet_file')
|
20
21
|
* stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
21
22
|
*
|
22
23
|
* xml_doc = XML::Document.file('xml_file')
|
23
24
|
* result = stylesheet.apply(xml_doc)
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*/
|
25
|
+
*
|
26
|
+
*
|
27
|
+
*/
|
27
28
|
|
28
29
|
#ifdef RDOC_NEVER_DEFINED
|
29
|
-
|
30
|
+
cLibXSLT = rb_define_module("XSLT");
|
30
31
|
#endif
|
31
32
|
|
32
33
|
|
33
|
-
#if defined(_WIN32)
|
34
|
-
__declspec(dllexport)
|
35
|
-
#endif
|
34
|
+
#if defined(_WIN32)
|
35
|
+
__declspec(dllexport)
|
36
|
+
#endif
|
36
37
|
|
37
38
|
void
|
38
39
|
Init_libxslt_ruby(void) {
|
39
40
|
LIBXML_TEST_VERSION;
|
40
41
|
|
41
|
-
|
42
|
+
cLibXSLT = rb_define_module("LibXSLT");
|
43
|
+
cXSLT = rb_define_module_under(cLibXSLT, "XSLT");
|
42
44
|
|
43
45
|
rb_define_const(cXSLT, "MAX_DEPTH", INT2NUM(xsltMaxDepth));
|
44
46
|
rb_define_const(cXSLT, "MAX_SORT", INT2NUM(XSLT_MAX_SORT));
|
@@ -55,6 +57,8 @@ Init_libxslt_ruby(void) {
|
|
55
57
|
rb_define_const(cXSLT, "NAMESPACE_XT", rb_str_new2((const char*)XSLT_XT_NAMESPACE));
|
56
58
|
rb_define_const(cXSLT, "NAMESPACE_XALAN", rb_str_new2((const char*)XSLT_XALAN_NAMESPACE));
|
57
59
|
|
60
|
+
eXSLTError = rb_define_class_under(cLibXSLT, "XSLTError", rb_eRuntimeError);
|
61
|
+
|
58
62
|
ruby_init_xslt_stylesheet();
|
59
63
|
ruby_init_xslt_transform_context();
|
60
64
|
}
|
data/ext/libxslt/libxslt.h
CHANGED
@@ -21,14 +21,12 @@
|
|
21
21
|
|
22
22
|
#include "version.h"
|
23
23
|
|
24
|
-
#define RUBY_LIBXSLT_SRC_TYPE_NULL 0
|
25
|
-
#define RUBY_LIBXSLT_SRC_TYPE_FILE 1
|
26
|
-
|
27
|
-
extern VALUE cXSLT;
|
28
|
-
extern VALUE eXMLXSLTStylesheetRequireParsedDoc;
|
29
|
-
|
30
24
|
#if ((RUBY_LIBXML_VER_MAJ != RUBY_LIBXSLT_VER_MAJ) || (RUBY_LIBXML_VER_MIN != RUBY_LIBXSLT_VER_MIN))
|
31
25
|
#error "Incompatible LibXML-Ruby headers - please install same major/micro version"
|
32
26
|
#endif
|
33
27
|
|
28
|
+
extern VALUE cLibXSLT;
|
29
|
+
extern VALUE cXSLT;
|
30
|
+
extern VALUE eXSLTError;
|
31
|
+
|
34
32
|
#endif
|
@@ -5,15 +5,14 @@
|
|
5
5
|
#include "libxslt.h"
|
6
6
|
#include "ruby_xslt_stylesheet.h"
|
7
7
|
|
8
|
-
/*
|
9
|
-
* Document-class: XSLT::Stylesheet
|
10
|
-
*
|
11
|
-
* The XSLT::Stylesheet represents a XSL stylesheet that
|
12
|
-
* can be used to transform an XML document. For usage information
|
13
|
-
* refer to XSLT::Stylesheet#apply
|
14
|
-
*
|
15
|
-
*/
|
16
|
-
|
8
|
+
/*
|
9
|
+
* Document-class: LibXSLT::XSLT::Stylesheet
|
10
|
+
*
|
11
|
+
* The XSLT::Stylesheet represents a XSL stylesheet that
|
12
|
+
* can be used to transform an XML document. For usage information
|
13
|
+
* refer to XSLT::Stylesheet#apply
|
14
|
+
*
|
15
|
+
*/
|
17
16
|
|
18
17
|
VALUE cXSLTStylesheet;
|
19
18
|
|
@@ -23,9 +22,9 @@ ruby_xslt_stylesheet_document_klass() {
|
|
23
22
|
return rb_const_get(mXML, rb_intern("Document"));
|
24
23
|
}
|
25
24
|
|
26
|
-
|
27
25
|
void
|
28
26
|
ruby_xslt_stylesheet_free(xsltStylesheetPtr xstylesheet) {
|
27
|
+
|
29
28
|
xsltFreeStylesheet(xstylesheet);
|
30
29
|
}
|
31
30
|
|
@@ -40,7 +39,10 @@ ruby_xslt_stylesheet_alloc(VALUE klass) {
|
|
40
39
|
/* call-seq:
|
41
40
|
* XSLT::Stylesheet.new(document) -> XSLT::Stylesheet
|
42
41
|
*
|
43
|
-
* Creates a new XSLT stylesheet based on the
|
42
|
+
* Creates a new XSLT stylesheet based on the specified document.
|
43
|
+
* For memory management reasons, a copy of the specified document
|
44
|
+
* will be made, so its best to create a single copy of a stylesheet
|
45
|
+
* and use it multiple times.
|
44
46
|
*
|
45
47
|
* stylesheet_doc = XML::Document.file('stylesheet_file')
|
46
48
|
* stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
@@ -48,13 +50,28 @@ ruby_xslt_stylesheet_alloc(VALUE klass) {
|
|
48
50
|
*/
|
49
51
|
VALUE
|
50
52
|
ruby_xslt_stylesheet_initialize(VALUE self, VALUE document) {
|
51
|
-
ruby_xml_document_t *rdocument;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
ruby_xml_document_t *rdocument;
|
54
|
+
xmlDocPtr xcopy;
|
55
|
+
xsltStylesheetPtr xstylesheet;
|
56
|
+
|
57
|
+
if (!rb_obj_is_kind_of(document, ruby_xslt_stylesheet_document_klass()))
|
58
|
+
rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
|
59
|
+
|
60
|
+
/* NOTE!! Since the stylesheet own the specified document, the easiest
|
61
|
+
* thing to do from a memory standpoint is too copy it and not expose
|
62
|
+
* the copy to Ruby. The other solution is expose a memory management
|
63
|
+
* API on the document object for taking ownership of the document
|
64
|
+
* and specifying when it has been freed. Then the document class
|
65
|
+
* has to be updated to always check and see if the document is
|
66
|
+
* still valid. That's all doable, but seems like a pain, so
|
67
|
+
* just copy the document for now. */
|
68
|
+
Data_Get_Struct(document, ruby_xml_document_t, rdocument);
|
69
|
+
xcopy = xmlCopyDoc(rdocument->doc, 1);
|
70
|
+
xstylesheet = xsltParseStylesheetDoc(xcopy);
|
71
|
+
xstylesheet->_private = (void *)self;
|
72
|
+
DATA_PTR(self) = xstylesheet;
|
73
|
+
|
74
|
+
/* Save a reference to the document as an attribute accessable to ruby*/
|
58
75
|
return self;
|
59
76
|
}
|
60
77
|
|
@@ -71,9 +88,9 @@ ruby_xslt_coerce_params(VALUE params) {
|
|
71
88
|
for (i=0; i<length; i++) {
|
72
89
|
VALUE str = rb_String(RARRAY(params)->ptr[i]);
|
73
90
|
int strLen = RSTRING(str)->len;
|
74
|
-
result[i] = ALLOC_N(char, strLen + 1);
|
75
|
-
memset(result[i], 0, strLen + 1);
|
76
|
-
strncpy(result[i], RSTRING(str)->ptr, strLen);
|
91
|
+
result[i] = ALLOC_N(char, strLen + 1);
|
92
|
+
memset(result[i], 0, strLen + 1);
|
93
|
+
strncpy(result[i], RSTRING(str)->ptr, strLen);
|
77
94
|
}
|
78
95
|
|
79
96
|
/* Null terminate the array - need to empty elements */
|
@@ -91,10 +108,8 @@ ruby_xslt_coerce_params(VALUE params) {
|
|
91
108
|
* This method may be invoked multiple times.
|
92
109
|
*
|
93
110
|
* Params:
|
94
|
-
*
|
95
|
-
*
|
96
|
-
* params = An optional hash table that specifies the values
|
97
|
-
* for xsl:param values embedded in the stylesheet.
|
111
|
+
* * document - An instance of an XML::Document
|
112
|
+
* * params - An optional hash table that specifies the values for xsl:param values embedded in the stylesheet.
|
98
113
|
*
|
99
114
|
* Example:
|
100
115
|
*
|
@@ -107,33 +122,36 @@ ruby_xslt_coerce_params(VALUE params) {
|
|
107
122
|
*/
|
108
123
|
VALUE
|
109
124
|
ruby_xslt_stylesheet_apply(int argc, VALUE *argv, VALUE self) {
|
110
|
-
ruby_xml_document_t *rdocument;
|
111
|
-
xsltStylesheetPtr xstylesheet;
|
125
|
+
ruby_xml_document_t *rdocument;
|
126
|
+
xsltStylesheetPtr xstylesheet;
|
112
127
|
xmlDocPtr result;
|
113
128
|
VALUE document;
|
114
129
|
VALUE params;
|
115
130
|
int i;
|
116
131
|
|
117
132
|
char** pParams;
|
118
|
-
|
119
|
-
if (argc > 2 || argc < 1)
|
120
|
-
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
121
|
-
|
133
|
+
|
134
|
+
if (argc > 2 || argc < 1)
|
135
|
+
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
136
|
+
|
122
137
|
document = argv[0];
|
123
138
|
|
124
|
-
if (!rb_obj_is_kind_of(document, ruby_xslt_stylesheet_document_klass()))
|
125
|
-
rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
|
139
|
+
if (!rb_obj_is_kind_of(document, ruby_xslt_stylesheet_document_klass()))
|
140
|
+
rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
|
126
141
|
|
127
142
|
/* Make sure params is a flat array */
|
128
143
|
params = (argc == 2 ? argv[1]: Qnil);
|
129
144
|
params = rb_Array(params);
|
130
|
-
rb_funcall(params, rb_intern("flatten!"), 0);
|
131
|
-
pParams = ruby_xslt_coerce_params(params);
|
132
|
-
|
133
|
-
Data_Get_Struct(document, ruby_xml_document_t, rdocument);
|
134
|
-
Data_Get_Struct(self, xsltStylesheet, xstylesheet);
|
145
|
+
rb_funcall(params, rb_intern("flatten!"), 0);
|
146
|
+
pParams = ruby_xslt_coerce_params(params);
|
135
147
|
|
136
|
-
|
148
|
+
Data_Get_Struct(document, ruby_xml_document_t, rdocument);
|
149
|
+
Data_Get_Struct(self, xsltStylesheet, xstylesheet);
|
150
|
+
|
151
|
+
result = xsltApplyStylesheet(xstylesheet, rdocument->doc, (const char**)pParams);
|
152
|
+
|
153
|
+
if (!result)
|
154
|
+
rb_raise(eXSLTError, "Transformation failed");
|
137
155
|
|
138
156
|
/* Free allocated array of *chars. Note we don't have to
|
139
157
|
free the last array item since its set to NULL. */
|
@@ -247,8 +265,8 @@ ruby_xslt_stylesheet_print(int argc, VALUE *argv, VALUE self) {
|
|
247
265
|
|
248
266
|
|
249
267
|
#ifdef RDOC_NEVER_DEFINED
|
250
|
-
|
251
|
-
|
268
|
+
cLibXSLT = rb_define_module("LibXSLT");
|
269
|
+
cXSLT = rb_define_module_under(cLibXSLT, "XSLT");
|
252
270
|
#endif
|
253
271
|
|
254
272
|
void
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "ruby_xslt_transform_context.h"
|
7
7
|
|
8
8
|
|
9
|
-
/* :nodoc: */
|
9
|
+
/* :nodoc: */
|
10
10
|
|
11
11
|
VALUE cXSLTTransformContext;
|
12
12
|
|
@@ -53,8 +53,8 @@ ruby_xslt_transform_context_new3(VALUE xslt) {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
#ifdef RDOC_NEVER_DEFINED
|
56
|
-
|
57
|
-
|
56
|
+
cLibXSLT = rb_define_module("LibXSLT");
|
57
|
+
cXSLT = rb_define_module_under(cLibXSLT, "XSLT");
|
58
58
|
#endif
|
59
59
|
|
60
60
|
void
|
data/ext/libxslt/version.h
CHANGED
data/lib/libxslt.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
1
|
require 'libxml'
|
2
|
-
require 'libxslt_ruby
|
3
|
-
require 'deprecated'
|
2
|
+
require 'libxslt_ruby'
|
3
|
+
require 'libxslt/deprecated'
|
4
|
+
|
5
|
+
# Map the LibXSLT module into the XSLT module for both backwards
|
6
|
+
# compatibility and ease of use.
|
7
|
+
module XSLT
|
8
|
+
include LibXSLT::XSLT
|
9
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# :enddoc:
|
2
|
+
# These classes provide provide backwards compatibility with
|
3
|
+
# versions of libxslt-ruby prior to version 0.7.0
|
4
|
+
|
5
|
+
module XML
|
6
|
+
module XSLT
|
7
|
+
MAX_DEPTH = LibXSLT::XSLT::MAX_DEPTH
|
8
|
+
MAX_SORT = LibXSLT::XSLT::MAX_SORT
|
9
|
+
ENGINE_VERSION = LibXSLT::XSLT::ENGINE_VERSION
|
10
|
+
LIBXSLT_VERSION = LibXSLT::XSLT::LIBXSLT_VERSION
|
11
|
+
LIBXML_VERSION = LibXSLT::XSLT::LIBXML_VERSION
|
12
|
+
XSLT_NAMESPACE = LibXSLT::XSLT::XSLT_NAMESPACE
|
13
|
+
DEFAULT_VENDOR = LibXSLT::XSLT::DEFAULT_VENDOR
|
14
|
+
DEFAULT_VERSION = LibXSLT::XSLT::DEFAULT_VERSION
|
15
|
+
DEFAULT_URL = LibXSLT::XSLT::DEFAULT_URL
|
16
|
+
NAMESPACE_LIBXSLT = LibXSLT::XSLT::NAMESPACE_LIBXSLT
|
17
|
+
NAMESPACE_NORM_SAXON = LibXSLT::XSLT::NAMESPACE_NORM_SAXON
|
18
|
+
NAMESPACE_SAXON = LibXSLT::XSLT::NAMESPACE_SAXON
|
19
|
+
NAMESPACE_XT = LibXSLT::XSLT::NAMESPACE_XT
|
20
|
+
NAMESPACE_XALAN = LibXSLT::XSLT::NAMESPACE_XALAN
|
21
|
+
|
22
|
+
def self.new
|
23
|
+
Stylesheet.new(nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.file(filename)
|
27
|
+
doc = XML::Document.file(filename)
|
28
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(doc)
|
29
|
+
|
30
|
+
result = Stylesheet.new(stylesheet)
|
31
|
+
result.filename = filename
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
class Stylesheet
|
36
|
+
attr_accessor :doc, :filename
|
37
|
+
|
38
|
+
def initialize(stylesheet)
|
39
|
+
@stylesheet = stylesheet
|
40
|
+
end
|
41
|
+
|
42
|
+
def filename=(value)
|
43
|
+
@doc = XML::Document.file(value)
|
44
|
+
@filename = value
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def apply
|
52
|
+
@result = @stylesheet.apply(@doc)
|
53
|
+
end
|
54
|
+
|
55
|
+
def save(filename)
|
56
|
+
raise(ArgumentError) unless @result
|
57
|
+
@result.save(filename)
|
58
|
+
end
|
59
|
+
|
60
|
+
def print(filename)
|
61
|
+
raise(ArgumentError) unless @result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|