libxslt-ruby 0.6.0-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/README +153 -0
- data/ext/libxslt/extconf.rb +104 -0
- data/ext/libxslt/libxslt.c +251 -0
- data/ext/libxslt/libxslt.h +51 -0
- data/ext/libxslt/ruby_xslt_stylesheet.c +298 -0
- data/ext/libxslt/ruby_xslt_stylesheet.h +21 -0
- data/ext/libxslt/ruby_xslt_transform_context.c +61 -0
- data/ext/libxslt/ruby_xslt_transform_context.h +22 -0
- data/ext/libxslt/version.h +5 -0
- data/lib/libxslt.rb +2 -0
- data/lib/libxslt_ruby.so +0 -0
- data/mingw/libxslt-1.dll +0 -0
- data/mingw/libxslt_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/vc/libxslt_ruby.sln +26 -0
- data/vc/libxslt_ruby.vcproj +233 -0
- metadata +81 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# $Id: LICENSE 33 2007-08-29 18:18:15Z transami $
|
2
|
+
|
3
|
+
Copyright (c) 2002-2006 Sean Chittenden <sean@chittenden.org> and contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
== INSTALLATION
|
2
|
+
|
3
|
+
Installation is simple. Follow the following steps:
|
4
|
+
|
5
|
+
=== Rubygems
|
6
|
+
|
7
|
+
gem install libxsl-ruby
|
8
|
+
|
9
|
+
=== Tarball/zip
|
10
|
+
|
11
|
+
$ rake test
|
12
|
+
$ rake install
|
13
|
+
|
14
|
+
If extconf yacks up an error, follow the instructions it provides.
|
15
|
+
You will need to chdir to ext/xml and run 'ruby extconf.rb' to provide
|
16
|
+
options, after which you can either use Rake for everything or
|
17
|
+
do with make (make && make install).
|
18
|
+
|
19
|
+
Once installed, look at the test scripts (tests/*.rb), and run
|
20
|
+
'rake doc' to generate API documentation.
|
21
|
+
|
22
|
+
== DOCUMENTATION
|
23
|
+
|
24
|
+
RDoc comments are included - run 'rake doc' to generate documentation.
|
25
|
+
You can find the latest documentation at:
|
26
|
+
|
27
|
+
* http://libxsl.rubyforge.org
|
28
|
+
|
29
|
+
== USAGE EXAMPLE
|
30
|
+
|
31
|
+
*Note*: To use libxsl-ruby, you have to require both 'xml/libxml' and
|
32
|
+
'xml/libxslt'. The following example is an abridged version of that
|
33
|
+
included with the distribution, which you can run with:
|
34
|
+
|
35
|
+
$ cd tests
|
36
|
+
$ ruby fuzface.rb
|
37
|
+
|
38
|
+
Given an XML file like:
|
39
|
+
|
40
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
41
|
+
<?xml-stylesheet href="fuzface.xsl" type="text/xsl"?>
|
42
|
+
|
43
|
+
<commentary>
|
44
|
+
<meta>
|
45
|
+
<author>
|
46
|
+
<first_name>Sean</first_name>
|
47
|
+
<last_name>Chittenden</last_name>
|
48
|
+
<email>sean@chittenden.org</email>
|
49
|
+
</author>
|
50
|
+
<version>$Version$</version>
|
51
|
+
<date>$Date: 2007-08-29 12:18:15 -0600 (Wed, 29 Aug 2007) $</date>
|
52
|
+
<id>$Id: README 33 2007-08-29 18:18:15Z transami $</id> <title>Fuzface...</title>
|
53
|
+
<subtitle>The Internet's a big place and here's some proof...</subtitle>
|
54
|
+
</meta>
|
55
|
+
|
56
|
+
<body>
|
57
|
+
<para>
|
58
|
+
I think it's a tragedy that I'm going to start off my new
|
59
|
+
commentary by talking about facial hair and the Internet.
|
60
|
+
Something about that just screams pathetic, but whatever: it's
|
61
|
+
humor and that's life.
|
62
|
+
</para>
|
63
|
+
</body>
|
64
|
+
</commentary>
|
65
|
+
|
66
|
+
And an XSLT like:
|
67
|
+
|
68
|
+
<?xml version="1.0" ?>
|
69
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
70
|
+
<xsl:template match="/">
|
71
|
+
<xsl:element name="html">
|
72
|
+
<xsl:element name="head">
|
73
|
+
<xsl:element name="title">Ramblings - <xsl:value-of select="commentary/meta/title" /> - <xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
|
74
|
+
</xsl:element>
|
75
|
+
|
76
|
+
<xsl:element name="body">
|
77
|
+
<xsl:element name="h1"><xsl:value-of select="commentary/meta/title" /></xsl:element>
|
78
|
+
<xsl:element name="h3"><xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
|
79
|
+
By: <xsl:value-of select="commentary/meta/author/first_name" /> <xsl:value-of select="commentary/meta/author/last_name" /><xsl:element name="br" />
|
80
|
+
Date: <xsl:value-of select="commentary/meta/date" /><xsl:element name="br" />
|
81
|
+
|
82
|
+
<xsl:for-each select="./commentary/body">
|
83
|
+
<xsl:apply-templates />
|
84
|
+
</xsl:for-each>
|
85
|
+
|
86
|
+
</xsl:element>
|
87
|
+
</xsl:element>
|
88
|
+
</xsl:template>
|
89
|
+
|
90
|
+
<xsl:template match="para">
|
91
|
+
<xsl:element name="p">
|
92
|
+
<xsl:value-of select="." />
|
93
|
+
</xsl:element>
|
94
|
+
</xsl:template>
|
95
|
+
</xsl:stylesheet>
|
96
|
+
|
97
|
+
We can easily transform the XML with the following ruby code:
|
98
|
+
|
99
|
+
# require 'rubygems' # if installed via gems
|
100
|
+
require 'xml/libxml'
|
101
|
+
require 'xml/libxslt'
|
102
|
+
|
103
|
+
# Create a new XSL Transform
|
104
|
+
xslt = XML::XSLT.file('fuzface.xsl')
|
105
|
+
xslt.doc = XML::Document.file('fuzface.xml')
|
106
|
+
|
107
|
+
# Parse to create a stylesheet, then apply.
|
108
|
+
s = xslt.parse
|
109
|
+
s.apply
|
110
|
+
|
111
|
+
# To save the result to a file:
|
112
|
+
File.open('fuzface.html', 'w') do |f|
|
113
|
+
s.save(f)
|
114
|
+
end
|
115
|
+
|
116
|
+
# To output the result to stdout
|
117
|
+
s.print
|
118
|
+
|
119
|
+
To give the following result:
|
120
|
+
|
121
|
+
<html>
|
122
|
+
<head>
|
123
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
124
|
+
<title>Ramblings - Fuzface... - The Internet's a big place and here's some proof...</title>
|
125
|
+
</head>
|
126
|
+
<body>
|
127
|
+
<h1>Fuzface...</h1>
|
128
|
+
<h3>The Internet's a big place and here's some proof...</h3>
|
129
|
+
By: SeanChittenden<br>
|
130
|
+
Date: $Date: 2007-08-29 12:18:15 -0600 (Wed, 29 Aug 2007) $<br>
|
131
|
+
<p>
|
132
|
+
I think it's a tragedy that I'm going to start off my new
|
133
|
+
commentary by talking about facial hair and the Internet.
|
134
|
+
Something about that just screams pathetic, but whatever: it's
|
135
|
+
humor and that's life.
|
136
|
+
</p>
|
137
|
+
</body>
|
138
|
+
</html>
|
139
|
+
|
140
|
+
== If you checked out from CVS
|
141
|
+
|
142
|
+
If you checked out the source from CVS, you must install a copy of
|
143
|
+
the current (or matching) libxml-ruby headers in:
|
144
|
+
|
145
|
+
ext/xml/libxml-ruby
|
146
|
+
|
147
|
+
prior to running the above. This can be done via rake, and will
|
148
|
+
happen automatically if ../libxml/ext/xml is found, or the
|
149
|
+
LIBXMLH=/path/to/headers commandline option is supplied.
|
150
|
+
|
151
|
+
# $Id: README 33 2007-08-29 18:18:15Z transami $
|
152
|
+
|
153
|
+
# See the LICENSE file for copyright and distribution information
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
# $Id: extconf.rb 43 2007-12-07 12:38:59Z transami $
|
4
|
+
#
|
5
|
+
# See the LICENSE file for copyright and distribution information
|
6
|
+
|
7
|
+
require 'mkmf'
|
8
|
+
|
9
|
+
$preload = nil
|
10
|
+
$LIBPATH.push(Config::CONFIG['libdir'])
|
11
|
+
|
12
|
+
def crash(str)
|
13
|
+
print(" extconf failure: %s\n", str)
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
gem_specs = Gem::SourceIndex.from_installed_gems.search('libxml-ruby')
|
19
|
+
if gem_specs.empty?
|
20
|
+
crash(<<EOL)
|
21
|
+
libxml-ruby bindings must be installed
|
22
|
+
EOL
|
23
|
+
end
|
24
|
+
|
25
|
+
# Sort by version, newest first
|
26
|
+
gem_specs = gem_specs.sort_by {|spec| spec.version}.reverse
|
27
|
+
|
28
|
+
libxml_ruby_path = gem_specs.first.full_gem_path
|
29
|
+
|
30
|
+
$INCFLAGS += " -I#{libxml_ruby_path}/ext"
|
31
|
+
|
32
|
+
# Directories
|
33
|
+
dir_config('xml2')
|
34
|
+
dir_config('xslt')
|
35
|
+
|
36
|
+
unless have_library('m', 'atan')
|
37
|
+
# try again for gcc 4.0
|
38
|
+
saveflags = $CFLAGS
|
39
|
+
$CFLAGS += ' -fno-builtin'
|
40
|
+
unless have_library('m', 'atan')
|
41
|
+
crash('need libm')
|
42
|
+
end
|
43
|
+
$CFLAGS = saveflags
|
44
|
+
end
|
45
|
+
|
46
|
+
unless have_library("z", "inflate")
|
47
|
+
crash("need zlib")
|
48
|
+
else
|
49
|
+
$defs.push('-DHAVE_ZLIB_H')
|
50
|
+
end
|
51
|
+
|
52
|
+
unless (have_library('xml2', 'xmlXPtrNewRange') or
|
53
|
+
find_library('xml2', 'xmlXPtrNewRange', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
|
54
|
+
(have_header('libxml/xmlversion.h') or
|
55
|
+
find_header('libxml/xmlversion.h',
|
56
|
+
'/opt/include/libxml2',
|
57
|
+
'/usr/local/include/libxml2',
|
58
|
+
'/usr/include/libxml2'))
|
59
|
+
crash(<<EOL)
|
60
|
+
need libxml2.
|
61
|
+
|
62
|
+
Install the library or try one of the following options to extconf.rb:
|
63
|
+
|
64
|
+
--with-xml2-dir=/path/to/libxml2
|
65
|
+
--with-xml2-lib=/path/to/libxml2/lib
|
66
|
+
--with-xml2-include=/path/to/libxml2/include
|
67
|
+
EOL
|
68
|
+
end
|
69
|
+
|
70
|
+
unless (have_library('xslt','xsltApplyStylesheet') or
|
71
|
+
find_library('xslt', 'xsltApplyStylesheet', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
|
72
|
+
(have_header('xslt.h') or
|
73
|
+
find_header('xslt.h',
|
74
|
+
'/opt/include/libxslt',
|
75
|
+
'/usr/local/include/libxslt',
|
76
|
+
'/usr/include/libxslt'))
|
77
|
+
crash(<<EOL)
|
78
|
+
need libxslt.
|
79
|
+
|
80
|
+
Install the library or try one of the following options to extconf.rb:
|
81
|
+
|
82
|
+
--with-xslt-dir=/path/to/libxslt
|
83
|
+
--with-xslt-lib=/path/to/libxslt/lib
|
84
|
+
--with-xslt-include=/path/to/libxslt/include
|
85
|
+
EOL
|
86
|
+
end
|
87
|
+
|
88
|
+
unless have_header('libxml/ruby_libxml.h') and
|
89
|
+
have_header('libxml/ruby_xml_document.h')
|
90
|
+
crash(<<EOL)
|
91
|
+
need headers for libxml-ruby.
|
92
|
+
|
93
|
+
If you downloaded a release, this is a bug - please inform
|
94
|
+
libxml-devel@rubyforge.org including the release version and
|
95
|
+
download URL you obtained it from.
|
96
|
+
|
97
|
+
If you checked libxslt-ruby out from CVS, you will need to
|
98
|
+
obtain the headers from CVS (using the same version tag if
|
99
|
+
applicable) and place them in directory 'ext/xml/libxml-ruby'.
|
100
|
+
EOL
|
101
|
+
end
|
102
|
+
|
103
|
+
create_header()
|
104
|
+
create_makefile("libxslt_ruby")
|
@@ -0,0 +1,251 @@
|
|
1
|
+
/* $Id: libxslt.c 42 2007-12-07 06:09:35Z transami $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxslt.h"
|
6
|
+
#include "libxml/xmlversion.h"
|
7
|
+
|
8
|
+
VALUE mXML;
|
9
|
+
VALUE cXMLDocument;
|
10
|
+
|
11
|
+
VALUE cXSLT;
|
12
|
+
VALUE eXMLXSLTStylesheetRequireParsedDoc;
|
13
|
+
|
14
|
+
/* call-seq:
|
15
|
+
* xslt.doc => #<XML::Document...>
|
16
|
+
*
|
17
|
+
* Obtain the source XML::Document.
|
18
|
+
*/
|
19
|
+
VALUE
|
20
|
+
ruby_xslt_doc_get(VALUE self) {
|
21
|
+
ruby_xslt *rxslt;
|
22
|
+
Data_Get_Struct(self, ruby_xslt, rxslt);
|
23
|
+
return(rxslt->xml_doc_obj);
|
24
|
+
}
|
25
|
+
|
26
|
+
/* call-seq:
|
27
|
+
* xslt.doc = some_xml_document
|
28
|
+
*
|
29
|
+
* Set the source XML::Document.
|
30
|
+
*/
|
31
|
+
VALUE
|
32
|
+
ruby_xslt_doc_set(VALUE self, VALUE xml_doc_obj) {
|
33
|
+
ruby_xslt *rxslt;
|
34
|
+
ruby_xml_document_t *rxd;
|
35
|
+
ruby_xslt_transform_context *rxtc;
|
36
|
+
|
37
|
+
if (rb_obj_is_kind_of(xml_doc_obj, cXMLDocument) == Qfalse)
|
38
|
+
rb_raise(rb_eTypeError, "Invalid argument: must be of type XML::Document");
|
39
|
+
|
40
|
+
Data_Get_Struct(self, ruby_xslt, rxslt);
|
41
|
+
rxslt->xml_doc_obj = xml_doc_obj;
|
42
|
+
|
43
|
+
Data_Get_Struct(xml_doc_obj, ruby_xml_document_t, rxd);
|
44
|
+
if (rxd->doc == NULL)
|
45
|
+
return(Qnil);
|
46
|
+
|
47
|
+
rxslt->ctxt = ruby_xslt_transform_context_new3(self);
|
48
|
+
Data_Get_Struct(rxslt->ctxt, ruby_xslt_transform_context, rxtc);
|
49
|
+
|
50
|
+
if (rxslt->xsp == NULL || rxd->doc == NULL)
|
51
|
+
return(Qnil);
|
52
|
+
|
53
|
+
rxtc->ctxt = xsltNewTransformContext(rxslt->xsp, rxd->doc) ;
|
54
|
+
|
55
|
+
return(rxslt->xml_doc_obj);
|
56
|
+
}
|
57
|
+
|
58
|
+
/* call-seq:
|
59
|
+
* xslt.filename => "filename.xsl"
|
60
|
+
*
|
61
|
+
* Obtain the stylesheet filename.
|
62
|
+
*/
|
63
|
+
VALUE
|
64
|
+
ruby_xslt_filename_get(VALUE self) {
|
65
|
+
ruby_xslt *rxslt;
|
66
|
+
Data_Get_Struct(self, ruby_xslt, rxslt);
|
67
|
+
|
68
|
+
if (rxslt->data_type != RUBY_LIBXSLT_SRC_TYPE_FILE)
|
69
|
+
return(Qnil);
|
70
|
+
else
|
71
|
+
return((VALUE)rxslt->data);
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
/* call-seq:
|
76
|
+
* xslt.filename = "filename.xsl"
|
77
|
+
*
|
78
|
+
* Set the stylesheet filename.
|
79
|
+
*/
|
80
|
+
VALUE
|
81
|
+
ruby_xslt_filename_set(VALUE self, VALUE filename) {
|
82
|
+
ruby_xslt *rxslt;
|
83
|
+
Check_Type(filename, T_STRING);
|
84
|
+
Data_Get_Struct(self, ruby_xslt, rxslt);
|
85
|
+
|
86
|
+
if (rxslt->data_type != RUBY_LIBXSLT_SRC_TYPE_NULL)
|
87
|
+
return(Qnil);
|
88
|
+
|
89
|
+
rxslt->data_type = RUBY_LIBXSLT_SRC_TYPE_FILE;
|
90
|
+
rxslt->data = (void *)filename;
|
91
|
+
return(filename);
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
void
|
96
|
+
ruby_xslt_free(ruby_xslt *rxslt) {
|
97
|
+
if (rxslt != NULL)
|
98
|
+
ruby_xfree(rxslt);
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
void
|
103
|
+
ruby_xslt_mark(ruby_xslt *rxslt) {
|
104
|
+
if (rxslt == NULL) return;
|
105
|
+
if (!NIL_P(rxslt->ctxt)) rb_gc_mark(rxslt->ctxt);
|
106
|
+
if (!NIL_P(rxslt->str)) rb_gc_mark(rxslt->str);
|
107
|
+
if (!NIL_P(rxslt->xml_doc_obj)) rb_gc_mark(rxslt->xml_doc_obj);
|
108
|
+
|
109
|
+
switch(rxslt->data_type) {
|
110
|
+
case RUBY_LIBXSLT_SRC_TYPE_FILE:
|
111
|
+
if (rxslt->data != NULL)
|
112
|
+
rb_gc_mark((VALUE)rxslt->data);
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
/* call-seq:
|
119
|
+
* XML::XSLT.new => #<XML::XSLT...>
|
120
|
+
*
|
121
|
+
* Create a new XSLT instance. You will need to specify
|
122
|
+
* a filename and document for the instance after it is
|
123
|
+
* created.
|
124
|
+
*/
|
125
|
+
VALUE
|
126
|
+
ruby_xslt_new(VALUE class) {
|
127
|
+
ruby_xslt *rxslt = ALLOC(ruby_xslt);
|
128
|
+
|
129
|
+
if (rxslt == NULL)
|
130
|
+
rb_raise(rb_eNoMemError, "No memory left for XSLT struct");
|
131
|
+
|
132
|
+
rxslt->ctxt = Qnil;
|
133
|
+
rxslt->data = NULL;
|
134
|
+
rxslt->data_type = RUBY_LIBXSLT_SRC_TYPE_NULL;
|
135
|
+
rxslt->str = Qnil;
|
136
|
+
rxslt->xml_doc_obj = Qnil;
|
137
|
+
rxslt->xsp = NULL;
|
138
|
+
|
139
|
+
return(Data_Wrap_Struct(class, ruby_xslt_mark, ruby_xslt_free, rxslt));
|
140
|
+
}
|
141
|
+
|
142
|
+
/* call-seq:
|
143
|
+
* XML::XSLT.file("filename.xsl") => #<XML::XSLT...>
|
144
|
+
*
|
145
|
+
* Create a new XSLT instance with the supplied stylesheet filename.
|
146
|
+
*/
|
147
|
+
VALUE
|
148
|
+
ruby_xslt_new_file(VALUE class, VALUE filename) {
|
149
|
+
VALUE xslt;
|
150
|
+
|
151
|
+
xslt = ruby_xslt_new(class);
|
152
|
+
ruby_xslt_filename_set(xslt, filename);
|
153
|
+
return(xslt);
|
154
|
+
}
|
155
|
+
|
156
|
+
/* call-seq:
|
157
|
+
* xslt.parse => #<XML::XSLT::Stylesheet...>
|
158
|
+
*
|
159
|
+
* Parse the xsl source (specified by +filename+) and create
|
160
|
+
* a +Stylesheet+ instance that will apply it against the
|
161
|
+
* source document. If a parsed XML::Document isn't associated
|
162
|
+
* with this +XSLT+ instance (via #doc=) then a
|
163
|
+
* Stylesheet::RequireParsedDoc exception is raised.
|
164
|
+
*/
|
165
|
+
VALUE
|
166
|
+
ruby_xslt_parse(VALUE self) {
|
167
|
+
ruby_xml_document_t *rxd;
|
168
|
+
ruby_xslt *rxslt;
|
169
|
+
ruby_xslt_stylesheet *xss;
|
170
|
+
VALUE xssobj;
|
171
|
+
xsltStylesheetPtr sheet;
|
172
|
+
|
173
|
+
Data_Get_Struct(self, ruby_xslt, rxslt);
|
174
|
+
|
175
|
+
if (rxslt->data_type == RUBY_LIBXSLT_SRC_TYPE_FILE) {
|
176
|
+
/*xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,
|
177
|
+
xsltParseStylesheetFile((const xmlChar *)
|
178
|
+
STR2CSTR(rxslt->data)));*/
|
179
|
+
sheet = xsltParseStylesheetFile((const xmlChar *) STR2CSTR(rxslt->data));
|
180
|
+
|
181
|
+
if (sheet) {
|
182
|
+
xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet, sheet);
|
183
|
+
Data_Get_Struct(xssobj, ruby_xslt_stylesheet, xss);
|
184
|
+
xss->data = (void *)rb_obj_dup((VALUE)rxslt->data);
|
185
|
+
xss->xml_doc_obj = rxslt->xml_doc_obj;
|
186
|
+
} else
|
187
|
+
xssobj = Qnil;
|
188
|
+
|
189
|
+
} else if (rxslt->xml_doc_obj != Qnil) {
|
190
|
+
Data_Get_Struct(rxslt->xml_doc_obj, ruby_xml_document_t, rxd);
|
191
|
+
/*xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,
|
192
|
+
xsltParseStylesheetDoc(rxd->doc));*/
|
193
|
+
sheet = xsltParseStylesheetDoc(rxd->doc);
|
194
|
+
if (sheet) {
|
195
|
+
xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,sheet);
|
196
|
+
Data_Get_Struct(xssobj, ruby_xslt_stylesheet, xss);
|
197
|
+
xss->xml_doc_obj = rxslt->xml_doc_obj;
|
198
|
+
} else
|
199
|
+
xssobj = Qnil;
|
200
|
+
|
201
|
+
} else {
|
202
|
+
xssobj = Qnil;
|
203
|
+
}
|
204
|
+
|
205
|
+
return(xssobj);
|
206
|
+
}
|
207
|
+
|
208
|
+
#if defined(_WIN32)
|
209
|
+
__declspec(dllexport)
|
210
|
+
#endif
|
211
|
+
|
212
|
+
void
|
213
|
+
Init_libxslt_ruby(void) {
|
214
|
+
LIBXML_TEST_VERSION;
|
215
|
+
|
216
|
+
// Must load libxml bindings to use xslst
|
217
|
+
mXML = rb_const_get(rb_cObject, rb_intern("XML"));
|
218
|
+
cXMLDocument = rb_const_get(mXML, rb_intern("Document"));
|
219
|
+
|
220
|
+
cXSLT = rb_define_class_under(mXML, "XSLT", rb_cObject);
|
221
|
+
|
222
|
+
rb_define_const(cXSLT, "MAX_DEPTH", INT2NUM(xsltMaxDepth));
|
223
|
+
rb_define_const(cXSLT, "MAX_SORT", INT2NUM(XSLT_MAX_SORT));
|
224
|
+
rb_define_const(cXSLT, "ENGINE_VERSION", rb_str_new2(xsltEngineVersion));
|
225
|
+
rb_define_const(cXSLT, "LIBXSLT_VERSION", INT2NUM(xsltLibxsltVersion));
|
226
|
+
rb_define_const(cXSLT, "LIBXML_VERSION", INT2NUM(xsltLibxmlVersion));
|
227
|
+
rb_define_const(cXSLT, "XSLT_NAMESPACE", rb_str_new2((const char*)XSLT_NAMESPACE));
|
228
|
+
rb_define_const(cXSLT, "DEFAULT_VENDOR", rb_str_new2(XSLT_DEFAULT_VENDOR));
|
229
|
+
rb_define_const(cXSLT, "DEFAULT_VERSION", rb_str_new2(XSLT_DEFAULT_VERSION));
|
230
|
+
rb_define_const(cXSLT, "DEFAULT_URL", rb_str_new2(XSLT_DEFAULT_URL));
|
231
|
+
rb_define_const(cXSLT, "NAMESPACE_LIBXSLT", rb_str_new2((const char*)XSLT_LIBXSLT_NAMESPACE));
|
232
|
+
rb_define_const(cXSLT, "NAMESPACE_NORM_SAXON", rb_str_new2((const char*)XSLT_NORM_SAXON_NAMESPACE));
|
233
|
+
rb_define_const(cXSLT, "NAMESPACE_SAXON", rb_str_new2((const char*)XSLT_SAXON_NAMESPACE));
|
234
|
+
rb_define_const(cXSLT, "NAMESPACE_XT", rb_str_new2((const char*)XSLT_XT_NAMESPACE));
|
235
|
+
rb_define_const(cXSLT, "NAMESPACE_XALAN", rb_str_new2((const char*)XSLT_XALAN_NAMESPACE));
|
236
|
+
|
237
|
+
ruby_init_xslt_stylesheet();
|
238
|
+
ruby_init_xslt_transform_context();
|
239
|
+
|
240
|
+
|
241
|
+
rb_define_singleton_method(cXSLT, "file", ruby_xslt_new_file, 1);
|
242
|
+
rb_define_singleton_method(cXSLT, "new", ruby_xslt_new, 0);
|
243
|
+
|
244
|
+
rb_define_method(cXSLT, "doc", ruby_xslt_doc_get, 0);
|
245
|
+
rb_define_method(cXSLT, "doc=", ruby_xslt_doc_set, 1);
|
246
|
+
rb_define_method(cXSLT, "filename", ruby_xslt_filename_get, 0);
|
247
|
+
rb_define_method(cXSLT, "filename=", ruby_xslt_filename_set, 1);
|
248
|
+
rb_define_method(cXSLT, "parse", ruby_xslt_parse, 0);
|
249
|
+
|
250
|
+
//exsltRegisterAll();
|
251
|
+
}
|