libxslt-ruby 0.3.6 → 0.6.0

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.
Files changed (47) hide show
  1. data/LICENSE +21 -21
  2. data/README +152 -48
  3. data/ext/{xml → libxslt}/extconf.rb +29 -22
  4. data/ext/{xml → libxslt}/libxslt.c +22 -18
  5. data/ext/{xml → libxslt}/libxslt.h +8 -9
  6. data/ext/{xml → libxslt}/ruby_xslt_stylesheet.c +19 -19
  7. data/ext/{xml → libxslt}/ruby_xslt_stylesheet.h +1 -1
  8. data/ext/{xml → libxslt}/ruby_xslt_transform_context.c +2 -4
  9. data/ext/{xml → libxslt}/ruby_xslt_transform_context.h +1 -1
  10. data/ext/libxslt/version.h +5 -0
  11. data/lib/libxslt.rb +2 -0
  12. data/mingw/libxslt-1.dll +0 -0
  13. data/mingw/libxslt_ruby.so +0 -0
  14. data/mingw/mingw.rake +36 -0
  15. data/vc/libxslt_ruby.sln +26 -0
  16. data/vc/libxslt_ruby.vcproj +233 -0
  17. metadata +66 -87
  18. data/CHANGELOG +0 -14
  19. data/Rakefile +0 -245
  20. data/TODO +0 -32
  21. data/ext/xml/libxml-ruby/libxml.h +0 -92
  22. data/ext/xml/libxml-ruby/ruby_xml_attr.h +0 -31
  23. data/ext/xml/libxml-ruby/ruby_xml_attribute.h +0 -31
  24. data/ext/xml/libxml-ruby/ruby_xml_document.h +0 -37
  25. data/ext/xml/libxml-ruby/ruby_xml_dtd.h +0 -27
  26. data/ext/xml/libxml-ruby/ruby_xml_input_cbg.h +0 -31
  27. data/ext/xml/libxml-ruby/ruby_xml_node.h +0 -38
  28. data/ext/xml/libxml-ruby/ruby_xml_node_set.h +0 -36
  29. data/ext/xml/libxml-ruby/ruby_xml_ns.h +0 -31
  30. data/ext/xml/libxml-ruby/ruby_xml_parser.h +0 -41
  31. data/ext/xml/libxml-ruby/ruby_xml_parser_context.h +0 -32
  32. data/ext/xml/libxml-ruby/ruby_xml_sax_parser.h +0 -31
  33. data/ext/xml/libxml-ruby/ruby_xml_schema.h +0 -26
  34. data/ext/xml/libxml-ruby/ruby_xml_tree.h +0 -22
  35. data/ext/xml/libxml-ruby/ruby_xml_xinclude.h +0 -23
  36. data/ext/xml/libxml-ruby/ruby_xml_xpath.h +0 -34
  37. data/ext/xml/libxml-ruby/ruby_xml_xpath_context.h +0 -34
  38. data/ext/xml/libxml-ruby/ruby_xml_xpointer.h +0 -37
  39. data/ext/xml/libxml-ruby/ruby_xml_xpointer_context.h +0 -28
  40. data/tests/commentary.dtd +0 -34
  41. data/tests/fuzface.rb +0 -15
  42. data/tests/fuzface.xml +0 -154
  43. data/tests/fuzface.xsl +0 -4
  44. data/tests/ramblings.xsl +0 -46
  45. data/tests/tc_libxslt.rb +0 -65
  46. data/tests/tc_xslt_stylesheet.rb +0 -41
  47. data/tests/tc_xslt_stylesheet2.rb +0 -41
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- # $Id: LICENSE,v 1.1.1.1 2006/03/09 01:36:19 roscopeco Exp $
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.
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 CHANGED
@@ -1,49 +1,153 @@
1
- == INSTALLATION
2
-
3
- Installation is simple. Follow the following steps:
4
-
5
- === Rubygems
6
-
7
- gem install libxslt-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://libxml.rubyforge.org/doc/xslt
28
-
29
- == USAGE EXAMPLE
30
-
31
- *Note*: To use libxslt, you have to require both 'xml/libxml' and 'xml/libxslt'.
32
-
33
- $ cd tests
34
- $ ruby fuzface.rb
35
-
36
- == If you checked out from CVS
37
-
38
- If you checked out the source from CVS, you must install a copy of
39
- the current (or matching) libxml-ruby headers in:
40
-
41
- ext/xml/libxml-ruby
42
-
43
- prior to running the above. This can be done via rake, and will
44
- happen automatically if ../libxml/ext/xml is found, or the
45
- LIBXMLH=/path/to/headers commandline option is supplied.
46
-
47
- # $Id: README,v 1.3 2006/03/21 22:42:21 roscopeco Exp $
48
-
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
+
49
153
  # See the LICENSE file for copyright and distribution information
@@ -1,10 +1,10 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- # $Id: extconf.rb,v 1.1.1.1 2006/03/09 01:36:20 roscopeco Exp $
3
+ # $Id: extconf.rb 43 2007-12-07 12:38:59Z transami $
4
4
  #
5
5
  # See the LICENSE file for copyright and distribution information
6
6
 
7
- require "mkmf"
7
+ require 'mkmf'
8
8
 
9
9
  $preload = nil
10
10
  $LIBPATH.push(Config::CONFIG['libdir'])
@@ -14,9 +14,24 @@ def crash(str)
14
14
  exit 1
15
15
  end
16
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
17
33
  dir_config('xml2')
18
34
  dir_config('xslt')
19
- #dir_config('libxml-ruby', '../../../libxml', '../../../libxml/ext/xml')
20
35
 
21
36
  unless have_library('m', 'atan')
22
37
  # try again for gcc 4.0
@@ -35,11 +50,11 @@ else
35
50
  end
36
51
 
37
52
  unless (have_library('xml2', 'xmlXPtrNewRange') or
38
- find_library('xml2', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
53
+ find_library('xml2', 'xmlXPtrNewRange', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
39
54
  (have_header('libxml/xmlversion.h') or
40
- find_header('libxml/xmlversion.h',
41
- '/opt/include/libxml2',
42
- '/usr/local/include/libxml2',
55
+ find_header('libxml/xmlversion.h',
56
+ '/opt/include/libxml2',
57
+ '/usr/local/include/libxml2',
43
58
  '/usr/include/libxml2'))
44
59
  crash(<<EOL)
45
60
  need libxml2.
@@ -53,11 +68,11 @@ EOL
53
68
  end
54
69
 
55
70
  unless (have_library('xslt','xsltApplyStylesheet') or
56
- find_library('xslt', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
71
+ find_library('xslt', 'xsltApplyStylesheet', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
57
72
  (have_header('xslt.h') or
58
- find_header('xslt.h',
59
- '/opt/include/libxslt',
60
- '/usr/local/include/libxslt',
73
+ find_header('xslt.h',
74
+ '/opt/include/libxslt',
75
+ '/usr/local/include/libxslt',
61
76
  '/usr/include/libxslt'))
62
77
  crash(<<EOL)
63
78
  need libxslt.
@@ -70,7 +85,8 @@ need libxslt.
70
85
  EOL
71
86
  end
72
87
 
73
- unless have_header('libxml-ruby/libxml.h')
88
+ unless have_header('libxml/ruby_libxml.h') and
89
+ have_header('libxml/ruby_xml_document.h')
74
90
  crash(<<EOL)
75
91
  need headers for libxml-ruby.
76
92
 
@@ -84,14 +100,5 @@ need headers for libxml-ruby.
84
100
  EOL
85
101
  end
86
102
 
87
- $LDFLAGS << ' -lexslt'
88
- #$LDFLAGS << ' -lxml'
89
- #$LDFLAGS << ' ' + `xslt-config --libs`.chomp
90
- #$LDFLAGS << ' ' + `xml2-config --libs`.chomp
91
- #$CFLAGS << ' ' + `xslt-config --cflags`.chomp
92
- #$CFLAGS << ' ' + `xml2-config --cflags`.chomp
93
- $CFLAGS = '-g -Wall ' + $CFLAGS + ' ' + $INCFLAGS
94
-
95
-
96
103
  create_header()
97
- create_makefile("xml/libxslt")
104
+ create_makefile("libxslt_ruby")
@@ -1,10 +1,13 @@
1
- /* $Id: libxslt.c,v 1.2 2006/03/21 22:42:21 roscopeco Exp $ */
1
+ /* $Id: libxslt.c 42 2007-12-07 06:09:35Z transami $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
5
  #include "libxslt.h"
6
6
  #include "libxml/xmlversion.h"
7
7
 
8
+ VALUE mXML;
9
+ VALUE cXMLDocument;
10
+
8
11
  VALUE cXSLT;
9
12
  VALUE eXMLXSLTStylesheetRequireParsedDoc;
10
13
 
@@ -28,7 +31,7 @@ ruby_xslt_doc_get(VALUE self) {
28
31
  VALUE
29
32
  ruby_xslt_doc_set(VALUE self, VALUE xml_doc_obj) {
30
33
  ruby_xslt *rxslt;
31
- ruby_xml_document *rxd;
34
+ ruby_xml_document_t *rxd;
32
35
  ruby_xslt_transform_context *rxtc;
33
36
 
34
37
  if (rb_obj_is_kind_of(xml_doc_obj, cXMLDocument) == Qfalse)
@@ -37,7 +40,7 @@ ruby_xslt_doc_set(VALUE self, VALUE xml_doc_obj) {
37
40
  Data_Get_Struct(self, ruby_xslt, rxslt);
38
41
  rxslt->xml_doc_obj = xml_doc_obj;
39
42
 
40
- Data_Get_Struct(xml_doc_obj, ruby_xml_document, rxd);
43
+ Data_Get_Struct(xml_doc_obj, ruby_xml_document_t, rxd);
41
44
  if (rxd->doc == NULL)
42
45
  return(Qnil);
43
46
 
@@ -92,7 +95,7 @@ ruby_xslt_filename_set(VALUE self, VALUE filename) {
92
95
  void
93
96
  ruby_xslt_free(ruby_xslt *rxslt) {
94
97
  if (rxslt != NULL)
95
- free(rxslt);
98
+ ruby_xfree(rxslt);
96
99
  }
97
100
 
98
101
 
@@ -121,9 +124,8 @@ ruby_xslt_mark(ruby_xslt *rxslt) {
121
124
  */
122
125
  VALUE
123
126
  ruby_xslt_new(VALUE class) {
124
- ruby_xslt *rxslt;
127
+ ruby_xslt *rxslt = ALLOC(ruby_xslt);
125
128
 
126
- rxslt = (ruby_xslt *)malloc(sizeof(ruby_xslt));
127
129
  if (rxslt == NULL)
128
130
  rb_raise(rb_eNoMemError, "No memory left for XSLT struct");
129
131
 
@@ -162,7 +164,7 @@ ruby_xslt_new_file(VALUE class, VALUE filename) {
162
164
  */
163
165
  VALUE
164
166
  ruby_xslt_parse(VALUE self) {
165
- ruby_xml_document *rxd;
167
+ ruby_xml_document_t *rxd;
166
168
  ruby_xslt *rxslt;
167
169
  ruby_xslt_stylesheet *xss;
168
170
  VALUE xssobj;
@@ -172,9 +174,9 @@ ruby_xslt_parse(VALUE self) {
172
174
 
173
175
  if (rxslt->data_type == RUBY_LIBXSLT_SRC_TYPE_FILE) {
174
176
  /*xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,
175
- xsltParseStylesheetFile((const xmlChar *)
176
- STR2CSTR(rxslt->data)));*/
177
- sheet = xsltParseStylesheetFile((const xmlChar *) STR2CSTR(rxslt->data));
177
+ xsltParseStylesheetFile((const xmlChar *)
178
+ STR2CSTR(rxslt->data)));*/
179
+ sheet = xsltParseStylesheetFile((const xmlChar *) STR2CSTR(rxslt->data));
178
180
 
179
181
  if (sheet) {
180
182
  xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet, sheet);
@@ -185,9 +187,9 @@ ruby_xslt_parse(VALUE self) {
185
187
  xssobj = Qnil;
186
188
 
187
189
  } else if (rxslt->xml_doc_obj != Qnil) {
188
- Data_Get_Struct(rxslt->xml_doc_obj, ruby_xml_document, rxd);
190
+ Data_Get_Struct(rxslt->xml_doc_obj, ruby_xml_document_t, rxd);
189
191
  /*xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,
190
- xsltParseStylesheetDoc(rxd->doc));*/
192
+ xsltParseStylesheetDoc(rxd->doc));*/
191
193
  sheet = xsltParseStylesheetDoc(rxd->doc);
192
194
  if (sheet) {
193
195
  xssobj = ruby_xslt_stylesheet_new(cXSLTStylesheet,sheet);
@@ -203,13 +205,15 @@ ruby_xslt_parse(VALUE self) {
203
205
  return(xssobj);
204
206
  }
205
207
 
206
- #ifdef RDOC_NEVER_DEFINED
207
- mXML = rb_define_module("XML");
208
- #endif
208
+ #if defined(_WIN32)
209
+ __declspec(dllexport)
210
+ #endif
209
211
 
210
212
  void
211
- Init_libxslt(void) {
212
- LIBXML_TEST_VERSION;
213
+ Init_libxslt_ruby(void) {
214
+ LIBXML_TEST_VERSION;
215
+
216
+ // Must load libxml bindings to use xslst
213
217
  mXML = rb_const_get(rb_cObject, rb_intern("XML"));
214
218
  cXMLDocument = rb_const_get(mXML, rb_intern("Document"));
215
219
 
@@ -243,5 +247,5 @@ Init_libxslt(void) {
243
247
  rb_define_method(cXSLT, "filename=", ruby_xslt_filename_set, 1);
244
248
  rb_define_method(cXSLT, "parse", ruby_xslt_parse, 0);
245
249
 
246
- exsltRegisterAll();
250
+ //exsltRegisterAll();
247
251
  }