libxslt-ruby19 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.project +12 -0
- data/CHANGES +81 -0
- data/Gemfile +13 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +164 -0
- data/Rakefile +163 -0
- data/Rakefile-jewel +0 -0
- data/VERSION +1 -0
- data/ext/libxslt/Makefile +187 -0
- data/ext/libxslt/extconf.h +6 -0
- data/ext/libxslt/extconf.rb +134 -0
- data/ext/libxslt/gem_make.out +36 -0
- data/ext/libxslt/libxslt.c +66 -0
- data/ext/libxslt/libxslt.h +31 -0
- data/ext/libxslt/libxslt.o +0 -0
- data/ext/libxslt/mkmf.log +371 -0
- data/ext/libxslt/ruby_xslt_stylesheet.c +277 -0
- data/ext/libxslt/ruby_xslt_stylesheet.h +16 -0
- data/ext/libxslt/version.h +5 -0
- data/ext/mingw/Rakefile +28 -0
- data/ext/vc/libxslt_ruby.sln +26 -0
- data/ext/vc/libxslt_ruby.vcproj +224 -0
- data/lib/libxslt/deprecated.rb +67 -0
- data/lib/libxslt-ruby19.rb +0 -0
- data/lib/libxslt.rb +13 -0
- data/lib/xslt.rb +15 -0
- data/setup.rb +1585 -0
- data/test/files/commentary.dtd +34 -0
- data/test/files/fuzface.xml +154 -0
- data/test/files/fuzface.xsl +4 -0
- data/test/files/params.xml +2 -0
- data/test/files/params.xsl +11 -0
- data/test/files/ramblings.xsl +46 -0
- data/test/helper.rb +18 -0
- data/test/test_deprecated.rb +97 -0
- data/test/test_libxslt-ruby19.rb +7 -0
- data/test/test_libxslt.rb +21 -0
- data/test/test_stylesheet.rb +108 -0
- data/test/test_suite.rb +3 -0
- metadata +167 -0
@@ -0,0 +1,277 @@
|
|
1
|
+
/* $Id: ruby_xslt_stylesheet.c 42 2007-12-07 06:09:35Z transami $ */
|
2
|
+
|
3
|
+
/* See the LICENSE file for copyright and distribution information. */
|
4
|
+
|
5
|
+
#include "libxslt.h"
|
6
|
+
#include "ruby_xslt_stylesheet.h"
|
7
|
+
|
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
|
+
*/
|
16
|
+
|
17
|
+
VALUE cXSLTStylesheet;
|
18
|
+
|
19
|
+
static VALUE
|
20
|
+
ruby_xslt_stylesheet_document_klass() {
|
21
|
+
VALUE mXML = rb_const_get(rb_cObject, rb_intern("XML"));
|
22
|
+
return rb_const_get(mXML, rb_intern("Document"));
|
23
|
+
}
|
24
|
+
|
25
|
+
void
|
26
|
+
ruby_xslt_stylesheet_free(xsltStylesheetPtr xstylesheet) {
|
27
|
+
xsltFreeStylesheet(xstylesheet);
|
28
|
+
}
|
29
|
+
|
30
|
+
static VALUE
|
31
|
+
ruby_xslt_stylesheet_alloc(VALUE klass) {
|
32
|
+
return Data_Wrap_Struct(cXSLTStylesheet,
|
33
|
+
NULL, ruby_xslt_stylesheet_free,
|
34
|
+
NULL);
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
/* call-seq:
|
39
|
+
* XSLT::Stylesheet.new(document) -> XSLT::Stylesheet
|
40
|
+
*
|
41
|
+
* Creates a new XSLT stylesheet based on the specified document.
|
42
|
+
* For memory management reasons, a copy of the specified document
|
43
|
+
* will be made, so its best to create a single copy of a stylesheet
|
44
|
+
* and use it multiple times.
|
45
|
+
*
|
46
|
+
* stylesheet_doc = XML::Document.file('stylesheet_file')
|
47
|
+
* stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
48
|
+
*
|
49
|
+
*/
|
50
|
+
static VALUE
|
51
|
+
ruby_xslt_stylesheet_initialize(VALUE self, VALUE document) {
|
52
|
+
xmlDocPtr xdoc;
|
53
|
+
xmlDocPtr xcopy;
|
54
|
+
xsltStylesheetPtr xstylesheet;
|
55
|
+
|
56
|
+
if (!rb_obj_is_kind_of(document, ruby_xslt_stylesheet_document_klass()))
|
57
|
+
rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
|
58
|
+
|
59
|
+
/* NOTE!! Since the stylesheet own the specified document, the easiest
|
60
|
+
* thing to do from a memory standpoint is too copy it and not expose
|
61
|
+
* the copy to Ruby. The other solution is expose a memory management
|
62
|
+
* API on the document object for taking ownership of the document
|
63
|
+
* and specifying when it has been freed. Then the document class
|
64
|
+
* has to be updated to always check and see if the document is
|
65
|
+
* still valid. That's all doable, but seems like a pain, so
|
66
|
+
* just copy the document for now. */
|
67
|
+
Data_Get_Struct(document, xmlDoc, xdoc);
|
68
|
+
xcopy = xmlCopyDoc(xdoc, 1);
|
69
|
+
xstylesheet = xsltParseStylesheetDoc(xcopy);
|
70
|
+
xstylesheet->_private = (void *)self;
|
71
|
+
DATA_PTR(self) = xstylesheet;
|
72
|
+
|
73
|
+
/* Save a reference to the document as an attribute accessable to ruby*/
|
74
|
+
return self;
|
75
|
+
}
|
76
|
+
|
77
|
+
/* Helper method to convert Ruby params to C params */
|
78
|
+
char **
|
79
|
+
ruby_xslt_coerce_params(VALUE params) {
|
80
|
+
char** result;
|
81
|
+
size_t length;
|
82
|
+
size_t i;
|
83
|
+
|
84
|
+
length = RARRAY_LEN(params);
|
85
|
+
result = ALLOC_N(char *, length + 2);
|
86
|
+
|
87
|
+
for (i=0; i<length; i++) {
|
88
|
+
VALUE str = rb_String(RARRAY_PTR(params)[i]);
|
89
|
+
int strLen = RSTRING_LEN(str);
|
90
|
+
result[i] = ALLOC_N(char, strLen + 1);
|
91
|
+
memset(result[i], 0, strLen + 1);
|
92
|
+
strncpy(result[i], RSTRING_PTR(str), strLen);
|
93
|
+
}
|
94
|
+
|
95
|
+
/* Null terminate the array - need to empty elements */
|
96
|
+
result[i] = NULL;
|
97
|
+
result[i+1] = NULL;
|
98
|
+
|
99
|
+
return result;
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
/* call-seq:
|
104
|
+
* stylesheet.apply(document, {params}) -> XML::Document
|
105
|
+
*
|
106
|
+
* Apply this stylesheet transformation to the provided document.
|
107
|
+
* This method may be invoked multiple times.
|
108
|
+
*
|
109
|
+
* Params:
|
110
|
+
* * document - An instance of an XML::Document
|
111
|
+
* * params - An optional hash table that specifies the values for xsl:param values embedded in the stylesheet.
|
112
|
+
*
|
113
|
+
* Example:
|
114
|
+
*
|
115
|
+
* stylesheet_doc = XML::Document.file('stylesheet_file')
|
116
|
+
* stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
117
|
+
*
|
118
|
+
* xml_doc = XML::Document.file('xml_file')
|
119
|
+
* result = stylesheet.apply(xml_doc)
|
120
|
+
* result = stylesheet.apply(xml_doc, {:foo => 'bar'})
|
121
|
+
*/
|
122
|
+
static VALUE
|
123
|
+
ruby_xslt_stylesheet_apply(int argc, VALUE *argv, VALUE self) {
|
124
|
+
xmlDocPtr xdoc;
|
125
|
+
xsltStylesheetPtr xstylesheet;
|
126
|
+
xmlDocPtr result;
|
127
|
+
VALUE document;
|
128
|
+
VALUE params;
|
129
|
+
int i;
|
130
|
+
|
131
|
+
char** pParams;
|
132
|
+
|
133
|
+
if (argc > 2 || argc < 1)
|
134
|
+
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
135
|
+
|
136
|
+
document = argv[0];
|
137
|
+
|
138
|
+
if (!rb_obj_is_kind_of(document, ruby_xslt_stylesheet_document_klass()))
|
139
|
+
rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
|
140
|
+
|
141
|
+
/* Make sure params is a flat array */
|
142
|
+
params = (argc == 2 ? argv[1]: Qnil);
|
143
|
+
params = rb_Array(params);
|
144
|
+
rb_funcall(params, rb_intern("flatten!"), 0);
|
145
|
+
pParams = ruby_xslt_coerce_params(params);
|
146
|
+
|
147
|
+
Data_Get_Struct(document, xmlDoc, xdoc);
|
148
|
+
Data_Get_Struct(self, xsltStylesheet, xstylesheet);
|
149
|
+
|
150
|
+
result = xsltApplyStylesheet(xstylesheet, xdoc, (const char**)pParams);
|
151
|
+
|
152
|
+
if (!result)
|
153
|
+
rb_raise(eXSLTError, "Transformation failed");
|
154
|
+
|
155
|
+
/* Free allocated array of *chars. Note we don't have to
|
156
|
+
free the last array item since its set to NULL. */
|
157
|
+
for (i=0; i<(RARRAY_LEN(params)); i++) {
|
158
|
+
ruby_xfree(pParams[i]);
|
159
|
+
}
|
160
|
+
ruby_xfree(pParams);
|
161
|
+
|
162
|
+
return rxml_document_wrap(result);
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
/* call-seq:
|
167
|
+
* sheet.debug(to = $stdout) => (true|false)
|
168
|
+
*
|
169
|
+
* Output a debug dump of this stylesheet to the specified output
|
170
|
+
* stream (an instance of IO, defaults to $stdout). Requires
|
171
|
+
* libxml/libxslt be compiled with debugging enabled. If this
|
172
|
+
* is not the case, a warning is triggered and the method returns
|
173
|
+
* false.
|
174
|
+
*/
|
175
|
+
/*VALUE
|
176
|
+
ruby_xslt_stylesheet_debug(int argc, VALUE *argv, VALUE self) {
|
177
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
178
|
+
OpenFile *fptr;
|
179
|
+
VALUE io;
|
180
|
+
FILE *out;
|
181
|
+
rxml_document_t *parsed;
|
182
|
+
ruby_xslt_stylesheet *xss;
|
183
|
+
|
184
|
+
Data_Get_Struct(self, ruby_xslt_stylesheet, xss);
|
185
|
+
if (NIL_P(xss->parsed))
|
186
|
+
rb_raise(eXMLXSLTStylesheetRequireParsedDoc, "must have a parsed XML result");
|
187
|
+
|
188
|
+
switch (argc) {
|
189
|
+
case 0:
|
190
|
+
io = rb_stdout;
|
191
|
+
break;
|
192
|
+
case 1:
|
193
|
+
io = argv[0];
|
194
|
+
if (rb_obj_is_kind_of(io, rb_cIO) == Qfalse)
|
195
|
+
rb_raise(rb_eTypeError, "need an IO object");
|
196
|
+
break;
|
197
|
+
default:
|
198
|
+
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
199
|
+
}
|
200
|
+
|
201
|
+
Data_Get_Struct(xss->parsed, rxml_document_t, parsed);
|
202
|
+
if (parsed->doc == NULL)
|
203
|
+
return(Qnil);
|
204
|
+
|
205
|
+
GetOpenFile(io, fptr);
|
206
|
+
rb_io_check_writable(fptr);
|
207
|
+
out = GetWriteFile(fptr);
|
208
|
+
xmlDebugDumpDocument(out, parsed->doc);
|
209
|
+
return(Qtrue);
|
210
|
+
#else
|
211
|
+
rb_warn("libxml/libxslt was compiled without debugging support. Please recompile libxml/libxslt and their Ruby modules");
|
212
|
+
return(Qfalse);
|
213
|
+
#endif
|
214
|
+
}
|
215
|
+
*/
|
216
|
+
|
217
|
+
// TODO should this automatically apply the sheet if not already,
|
218
|
+
// given that we're unlikely to do much else with it?
|
219
|
+
|
220
|
+
/* call-seq:
|
221
|
+
* sheet.print(to = $stdout) => number_of_bytes
|
222
|
+
*
|
223
|
+
* Output the result of the transform to the specified output
|
224
|
+
* stream (an IO instance, defaults to $stdout). You *must* call
|
225
|
+
* +apply+ before this method or an exception will be raised.
|
226
|
+
*/
|
227
|
+
/*VALUE
|
228
|
+
ruby_xslt_stylesheet_print(int argc, VALUE *argv, VALUE self) {
|
229
|
+
OpenFile *fptr;
|
230
|
+
VALUE io;
|
231
|
+
FILE *out;
|
232
|
+
rxml_document_t *parsed;
|
233
|
+
ruby_xslt_stylesheet *xss;
|
234
|
+
int bytes;
|
235
|
+
|
236
|
+
Data_Get_Struct(self, ruby_xslt_stylesheet, xss);
|
237
|
+
if (NIL_P(xss->parsed))
|
238
|
+
rb_raise(eXMLXSLTStylesheetRequireParsedDoc, "must have a parsed XML result");
|
239
|
+
|
240
|
+
switch (argc) {
|
241
|
+
case 0:
|
242
|
+
io = rb_stdout;
|
243
|
+
break;
|
244
|
+
case 1:
|
245
|
+
io = argv[0];
|
246
|
+
if (rb_obj_is_kind_of(io, rb_cIO) == Qfalse)
|
247
|
+
rb_raise(rb_eTypeError, "need an IO object");
|
248
|
+
break;
|
249
|
+
default:
|
250
|
+
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
251
|
+
}
|
252
|
+
|
253
|
+
Data_Get_Struct(xss->parsed, rxml_document_t, parsed);
|
254
|
+
if (parsed->doc == NULL)
|
255
|
+
return(Qnil);
|
256
|
+
|
257
|
+
GetOpenFile(io, fptr);
|
258
|
+
rb_io_check_writable(fptr);
|
259
|
+
out = GetWriteFile(fptr);
|
260
|
+
bytes = xsltSaveResultToFile(out, parsed->doc, xss->xsp);
|
261
|
+
|
262
|
+
return(INT2NUM(bytes));
|
263
|
+
}*/
|
264
|
+
|
265
|
+
|
266
|
+
#ifdef RDOC_NEVER_DEFINED
|
267
|
+
cLibXSLT = rb_define_module("LibXSLT");
|
268
|
+
cXSLT = rb_define_module_under(cLibXSLT, "XSLT");
|
269
|
+
#endif
|
270
|
+
|
271
|
+
void
|
272
|
+
ruby_init_xslt_stylesheet(void) {
|
273
|
+
cXSLTStylesheet = rb_define_class_under(cXSLT, "Stylesheet", rb_cObject);
|
274
|
+
rb_define_alloc_func(cXSLTStylesheet, ruby_xslt_stylesheet_alloc);
|
275
|
+
rb_define_method(cXSLTStylesheet, "initialize", ruby_xslt_stylesheet_initialize, 1);
|
276
|
+
rb_define_method(cXSLTStylesheet, "apply", ruby_xslt_stylesheet_apply, -1);
|
277
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/* $Id: ruby_xslt_stylesheet.h 42 2007-12-07 06:09:35Z transami $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information. */
|
4
|
+
|
5
|
+
#ifndef __RUBY_LIBXSLT_STYLESHEET__
|
6
|
+
#define __RUBY_LIBXSLT_STYLESHEET__
|
7
|
+
|
8
|
+
// Includes from libxml-ruby
|
9
|
+
#include <libxml/ruby_libxml.h>
|
10
|
+
#include <libxml/ruby_xml_document.h>
|
11
|
+
|
12
|
+
extern VALUE cXSLTStylesheet;
|
13
|
+
|
14
|
+
void ruby_init_xslt_stylesheet(void);
|
15
|
+
|
16
|
+
#endif
|
data/ext/mingw/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# We can't use Ruby's standard build procedures
|
2
|
+
# on Windows because the Ruby executable is
|
3
|
+
# built with VC++ while here we want to build
|
4
|
+
# with MingW. So just roll our own...
|
5
|
+
|
6
|
+
require 'fileutils'
|
7
|
+
require 'rbconfig'
|
8
|
+
|
9
|
+
EXTENSION_NAME = "libxslt_ruby.#{Config::CONFIG["DLEXT"]}"
|
10
|
+
|
11
|
+
# This is called when the Windows GEM is installed!
|
12
|
+
task :install do
|
13
|
+
# Gems will pass these two environment variables:
|
14
|
+
# RUBYARCHDIR=#{dest_path}
|
15
|
+
# RUBYLIBDIR=#{dest_path}
|
16
|
+
|
17
|
+
dest_path = ENV['RUBYLIBDIR']
|
18
|
+
|
19
|
+
# Copy the extension
|
20
|
+
cp(EXTENSION_NAME, dest_path)
|
21
|
+
|
22
|
+
# Copy dllss
|
23
|
+
Dir.glob('*.dll').each do |dll|
|
24
|
+
cp(dll, dest_path)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => :install
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
Microsoft Visual Studio Solution File, Format Version 10.00
|
3
|
+
# Visual Studio 2008
|
4
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxslt_ruby", "libxslt_ruby.vcproj", "{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}"
|
5
|
+
EndProject
|
6
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml_ruby", "..\..\..\libxml-ruby\ext\vc\libxml_ruby.vcproj", "{0B65CD1D-EEB9-41AE-93BB-75496E504152}"
|
7
|
+
EndProject
|
8
|
+
Global
|
9
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
10
|
+
Debug|Win32 = Debug|Win32
|
11
|
+
Release|Win32 = Release|Win32
|
12
|
+
EndGlobalSection
|
13
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
14
|
+
{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Debug|Win32.ActiveCfg = Debug|Win32
|
15
|
+
{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Debug|Win32.Build.0 = Debug|Win32
|
16
|
+
{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Release|Win32.ActiveCfg = Release|Win32
|
17
|
+
{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Release|Win32.Build.0 = Release|Win32
|
18
|
+
{0B65CD1D-EEB9-41AE-93BB-75496E504152}.Debug|Win32.ActiveCfg = Debug|Win32
|
19
|
+
{0B65CD1D-EEB9-41AE-93BB-75496E504152}.Debug|Win32.Build.0 = Debug|Win32
|
20
|
+
{0B65CD1D-EEB9-41AE-93BB-75496E504152}.Release|Win32.ActiveCfg = Release|Win32
|
21
|
+
{0B65CD1D-EEB9-41AE-93BB-75496E504152}.Release|Win32.Build.0 = Release|Win32
|
22
|
+
EndGlobalSection
|
23
|
+
GlobalSection(SolutionProperties) = preSolution
|
24
|
+
HideSolutionNode = FALSE
|
25
|
+
EndGlobalSection
|
26
|
+
EndGlobal
|
@@ -0,0 +1,224 @@
|
|
1
|
+
<?xml version="1.0" encoding="Windows-1252"?>
|
2
|
+
<VisualStudioProject
|
3
|
+
ProjectType="Visual C++"
|
4
|
+
Version="9.00"
|
5
|
+
Name="libxslt_ruby"
|
6
|
+
ProjectGUID="{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}"
|
7
|
+
RootNamespace="libxsl"
|
8
|
+
Keyword="Win32Proj"
|
9
|
+
TargetFrameworkVersion="131072"
|
10
|
+
>
|
11
|
+
<Platforms>
|
12
|
+
<Platform
|
13
|
+
Name="Win32"
|
14
|
+
/>
|
15
|
+
</Platforms>
|
16
|
+
<ToolFiles>
|
17
|
+
</ToolFiles>
|
18
|
+
<Configurations>
|
19
|
+
<Configuration
|
20
|
+
Name="Debug|Win32"
|
21
|
+
OutputDirectory="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxslt-ruby-0.8.2-x86-mswin32-60\lib"
|
22
|
+
IntermediateDirectory="$(ConfigurationName)"
|
23
|
+
ConfigurationType="2"
|
24
|
+
CharacterSet="1"
|
25
|
+
>
|
26
|
+
<Tool
|
27
|
+
Name="VCPreBuildEventTool"
|
28
|
+
/>
|
29
|
+
<Tool
|
30
|
+
Name="VCCustomBuildTool"
|
31
|
+
/>
|
32
|
+
<Tool
|
33
|
+
Name="VCXMLDataGeneratorTool"
|
34
|
+
/>
|
35
|
+
<Tool
|
36
|
+
Name="VCWebServiceProxyGeneratorTool"
|
37
|
+
/>
|
38
|
+
<Tool
|
39
|
+
Name="VCMIDLTool"
|
40
|
+
/>
|
41
|
+
<Tool
|
42
|
+
Name="VCCLCompilerTool"
|
43
|
+
Optimization="0"
|
44
|
+
AdditionalIncludeDirectories=""C:\Development\src\libxml-ruby\ext";"C:\Development\ruby\lib\ruby\1.8\i386-mswin32";C:\Development\msys\local\include;C:\Development\msys\local\include\libxml2"
|
45
|
+
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;libxsl_EXPORTS"
|
46
|
+
MinimalRebuild="true"
|
47
|
+
BasicRuntimeChecks="3"
|
48
|
+
RuntimeLibrary="3"
|
49
|
+
UsePrecompiledHeader="0"
|
50
|
+
WarningLevel="3"
|
51
|
+
Detect64BitPortabilityProblems="true"
|
52
|
+
DebugInformationFormat="4"
|
53
|
+
/>
|
54
|
+
<Tool
|
55
|
+
Name="VCManagedResourceCompilerTool"
|
56
|
+
/>
|
57
|
+
<Tool
|
58
|
+
Name="VCResourceCompilerTool"
|
59
|
+
/>
|
60
|
+
<Tool
|
61
|
+
Name="VCPreLinkEventTool"
|
62
|
+
/>
|
63
|
+
<Tool
|
64
|
+
Name="VCLinkerTool"
|
65
|
+
AdditionalDependencies="msvcrt-ruby18.lib libxml2.lib libxslt.lib libexslt.lib"
|
66
|
+
OutputFile="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxslt-ruby-0.9.1-x86-mswin32-60\lib\$(ProjectName).so"
|
67
|
+
LinkIncremental="2"
|
68
|
+
AdditionalLibraryDirectories="C:\Development\ruby\lib;C:\Development\msys\local\lib"
|
69
|
+
GenerateDebugInformation="true"
|
70
|
+
SubSystem="2"
|
71
|
+
RandomizedBaseAddress="1"
|
72
|
+
DataExecutionPrevention="0"
|
73
|
+
TargetMachine="1"
|
74
|
+
/>
|
75
|
+
<Tool
|
76
|
+
Name="VCALinkTool"
|
77
|
+
/>
|
78
|
+
<Tool
|
79
|
+
Name="VCManifestTool"
|
80
|
+
/>
|
81
|
+
<Tool
|
82
|
+
Name="VCXDCMakeTool"
|
83
|
+
/>
|
84
|
+
<Tool
|
85
|
+
Name="VCBscMakeTool"
|
86
|
+
/>
|
87
|
+
<Tool
|
88
|
+
Name="VCFxCopTool"
|
89
|
+
/>
|
90
|
+
<Tool
|
91
|
+
Name="VCAppVerifierTool"
|
92
|
+
/>
|
93
|
+
<Tool
|
94
|
+
Name="VCPostBuildEventTool"
|
95
|
+
/>
|
96
|
+
</Configuration>
|
97
|
+
<Configuration
|
98
|
+
Name="Release|Win32"
|
99
|
+
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
100
|
+
IntermediateDirectory="$(ConfigurationName)"
|
101
|
+
ConfigurationType="2"
|
102
|
+
CharacterSet="1"
|
103
|
+
WholeProgramOptimization="1"
|
104
|
+
>
|
105
|
+
<Tool
|
106
|
+
Name="VCPreBuildEventTool"
|
107
|
+
/>
|
108
|
+
<Tool
|
109
|
+
Name="VCCustomBuildTool"
|
110
|
+
/>
|
111
|
+
<Tool
|
112
|
+
Name="VCXMLDataGeneratorTool"
|
113
|
+
/>
|
114
|
+
<Tool
|
115
|
+
Name="VCWebServiceProxyGeneratorTool"
|
116
|
+
/>
|
117
|
+
<Tool
|
118
|
+
Name="VCMIDLTool"
|
119
|
+
/>
|
120
|
+
<Tool
|
121
|
+
Name="VCCLCompilerTool"
|
122
|
+
AdditionalIncludeDirectories=""C:\Development\msys\src\libiconv-1.12\include";"C:\Development\ruby\lib\ruby\1.8\i386-mswin32";"C:\Development\msys\src\libxml2-2.6.32\include";"C:\Development\msys\src\libxslt-1.1.24";C:\Development\msys\src\rlibxml\ext"
|
123
|
+
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBXML_EXPORTS"
|
124
|
+
RuntimeLibrary="2"
|
125
|
+
UsePrecompiledHeader="0"
|
126
|
+
WarningLevel="3"
|
127
|
+
Detect64BitPortabilityProblems="true"
|
128
|
+
DebugInformationFormat="3"
|
129
|
+
/>
|
130
|
+
<Tool
|
131
|
+
Name="VCManagedResourceCompilerTool"
|
132
|
+
/>
|
133
|
+
<Tool
|
134
|
+
Name="VCResourceCompilerTool"
|
135
|
+
/>
|
136
|
+
<Tool
|
137
|
+
Name="VCPreLinkEventTool"
|
138
|
+
/>
|
139
|
+
<Tool
|
140
|
+
Name="VCLinkerTool"
|
141
|
+
AdditionalDependencies="msvcrt-ruby18.lib libxml2.lib libxslt.lib libexslt.lib"
|
142
|
+
OutputFile="$(OutDir)\$(ProjectName).so"
|
143
|
+
LinkIncremental="1"
|
144
|
+
AdditionalLibraryDirectories="C:\Development\ruby\lib;"C:\Development\msys\src\libxslt-1.1.24\win32\bin.msvc""
|
145
|
+
GenerateDebugInformation="true"
|
146
|
+
SubSystem="2"
|
147
|
+
OptimizeReferences="2"
|
148
|
+
EnableCOMDATFolding="2"
|
149
|
+
RandomizedBaseAddress="1"
|
150
|
+
DataExecutionPrevention="0"
|
151
|
+
TargetMachine="1"
|
152
|
+
/>
|
153
|
+
<Tool
|
154
|
+
Name="VCALinkTool"
|
155
|
+
/>
|
156
|
+
<Tool
|
157
|
+
Name="VCManifestTool"
|
158
|
+
/>
|
159
|
+
<Tool
|
160
|
+
Name="VCXDCMakeTool"
|
161
|
+
/>
|
162
|
+
<Tool
|
163
|
+
Name="VCBscMakeTool"
|
164
|
+
/>
|
165
|
+
<Tool
|
166
|
+
Name="VCFxCopTool"
|
167
|
+
/>
|
168
|
+
<Tool
|
169
|
+
Name="VCAppVerifierTool"
|
170
|
+
/>
|
171
|
+
<Tool
|
172
|
+
Name="VCPostBuildEventTool"
|
173
|
+
/>
|
174
|
+
</Configuration>
|
175
|
+
</Configurations>
|
176
|
+
<References>
|
177
|
+
<ProjectReference
|
178
|
+
ReferencedProjectIdentifier="{0B65CD1D-EEB9-41AE-93BB-75496E504152}"
|
179
|
+
RelativePathToProject="..\..\..\libxml-ruby\ext\vc\libxml_ruby.vcproj"
|
180
|
+
/>
|
181
|
+
</References>
|
182
|
+
<Files>
|
183
|
+
<Filter
|
184
|
+
Name="Source Files"
|
185
|
+
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
186
|
+
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
187
|
+
>
|
188
|
+
<File
|
189
|
+
RelativePath="..\libxslt\libxslt.c"
|
190
|
+
>
|
191
|
+
</File>
|
192
|
+
<File
|
193
|
+
RelativePath="..\libxslt\ruby_xslt_stylesheet.c"
|
194
|
+
>
|
195
|
+
</File>
|
196
|
+
</Filter>
|
197
|
+
<Filter
|
198
|
+
Name="Header Files"
|
199
|
+
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
200
|
+
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
201
|
+
>
|
202
|
+
<File
|
203
|
+
RelativePath="..\libxslt\libxslt.h"
|
204
|
+
>
|
205
|
+
</File>
|
206
|
+
<File
|
207
|
+
RelativePath="..\libxslt\ruby_xslt_stylesheet.h"
|
208
|
+
>
|
209
|
+
</File>
|
210
|
+
<File
|
211
|
+
RelativePath="..\libxslt\version.h"
|
212
|
+
>
|
213
|
+
</File>
|
214
|
+
</Filter>
|
215
|
+
<Filter
|
216
|
+
Name="Resource Files"
|
217
|
+
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
218
|
+
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
219
|
+
>
|
220
|
+
</Filter>
|
221
|
+
</Files>
|
222
|
+
<Globals>
|
223
|
+
</Globals>
|
224
|
+
</VisualStudioProject>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# :enddoc:
|
2
|
+
# These classes provide provide backwards compatibility with
|
3
|
+
# versions of libxslt-ruby prior to version 0.7.0
|
4
|
+
|
5
|
+
module LibXML
|
6
|
+
module XML
|
7
|
+
module XSLT
|
8
|
+
MAX_DEPTH = LibXSLT::XSLT::MAX_DEPTH
|
9
|
+
MAX_SORT = LibXSLT::XSLT::MAX_SORT
|
10
|
+
ENGINE_VERSION = LibXSLT::XSLT::ENGINE_VERSION
|
11
|
+
LIBXSLT_VERSION = LibXSLT::XSLT::LIBXSLT_VERSION
|
12
|
+
LIBXML_VERSION = LibXSLT::XSLT::LIBXML_VERSION
|
13
|
+
XSLT_NAMESPACE = LibXSLT::XSLT::XSLT_NAMESPACE
|
14
|
+
DEFAULT_VENDOR = LibXSLT::XSLT::DEFAULT_VENDOR
|
15
|
+
DEFAULT_VERSION = LibXSLT::XSLT::DEFAULT_VERSION
|
16
|
+
DEFAULT_URL = LibXSLT::XSLT::DEFAULT_URL
|
17
|
+
NAMESPACE_LIBXSLT = LibXSLT::XSLT::NAMESPACE_LIBXSLT
|
18
|
+
NAMESPACE_NORM_SAXON = LibXSLT::XSLT::NAMESPACE_NORM_SAXON
|
19
|
+
NAMESPACE_SAXON = LibXSLT::XSLT::NAMESPACE_SAXON
|
20
|
+
NAMESPACE_XT = LibXSLT::XSLT::NAMESPACE_XT
|
21
|
+
NAMESPACE_XALAN = LibXSLT::XSLT::NAMESPACE_XALAN
|
22
|
+
|
23
|
+
def self.new
|
24
|
+
Stylesheet.new(nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.file(filename)
|
28
|
+
doc = ::LibXML::XML::Document.file(filename)
|
29
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(doc)
|
30
|
+
|
31
|
+
result = Stylesheet.new(stylesheet)
|
32
|
+
result.filename = filename
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
class Stylesheet
|
37
|
+
attr_accessor :doc, :filename
|
38
|
+
|
39
|
+
def initialize(stylesheet)
|
40
|
+
@stylesheet = stylesheet
|
41
|
+
end
|
42
|
+
|
43
|
+
def filename=(value)
|
44
|
+
@doc = ::LibXML::XML::Document.file(value)
|
45
|
+
@filename = value
|
46
|
+
end
|
47
|
+
|
48
|
+
def parse
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def apply
|
53
|
+
@result = @stylesheet.apply(@doc)
|
54
|
+
end
|
55
|
+
|
56
|
+
def save(filename)
|
57
|
+
raise(ArgumentError) unless @result
|
58
|
+
@result.save(filename)
|
59
|
+
end
|
60
|
+
|
61
|
+
def print(filename)
|
62
|
+
raise(ArgumentError) unless @result
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
File without changes
|
data/lib/libxslt.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# First make sure libxml is loaded
|
2
|
+
require 'libxml'
|
3
|
+
|
4
|
+
# Now if running on Windows, then add the current directory to the PATH
|
5
|
+
# for the current process so it can find the pre-built libxml2 and
|
6
|
+
# iconv2 shared libraries (dlls).
|
7
|
+
if RUBY_PLATFORM.match(/mswin/i)
|
8
|
+
ENV['PATH'] += ";#{File.dirname(__FILE__)}"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'libxslt_ruby'
|
12
|
+
|
13
|
+
require 'libxslt/deprecated'
|
data/lib/xslt.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file loads libxslt and adds the LibXSLT namespace
|
2
|
+
# to the toplevel for conveneience. The end result
|
3
|
+
# is to have XSLT:: universally exposed.
|
4
|
+
#
|
5
|
+
# It is recommend that you only load this file for libs
|
6
|
+
# that do not have their own namespace, eg. administrative
|
7
|
+
# scripts, personal programs, etc. For other applications
|
8
|
+
# require 'libxslt' instead and include LibXSLT into your
|
9
|
+
# app/libs namespace.
|
10
|
+
|
11
|
+
require 'libxslt'
|
12
|
+
|
13
|
+
include LibXML
|
14
|
+
include LibXSLT
|
15
|
+
|