0
@@ -33,8 +33,6 @@ void Init_fastxml_doc()
0
rb_define_method( rb_cFastXmlDoc, "to_s", fastxml_doc_to_s, 0 );
0
rb_define_method( rb_cFastXmlDoc, "root", fastxml_doc_root, 0 );
0
rb_define_method( rb_cFastXmlDoc, "transform", fastxml_doc_transform, 1 );
0
- rb_define_method( rb_cFastXmlDoc, "stylesheet=", fastxml_doc_stylesheet_set, 1 );
0
- rb_define_method( rb_cFastXmlDoc, "stylesheet", fastxml_doc_stylesheet, 0 );
0
rb_define_method( rb_cFastXmlDoc, "children", fastxml_doc_children, 0 );
0
rb_define_method( rb_cFastXmlDoc, "inspect", fastxml_doc_inspect, 0 );
0
@@ -72,32 +70,6 @@ VALUE fastxml_doc_children(VALUE self)
0
return fastxml_nodelist_to_obj( data->doc->children, -1 );
0
-/* Returns the FastXml::Doc that's defined as the xsl for this document
0
-VALUE fastxml_doc_stylesheet(VALUE self)
0
- return rb_iv_get( self, "@lxml_style" );
0
- * doc.stylesheet = FastXml::Doc.new( open( 'my.xsl' ) )
0
-VALUE fastxml_doc_stylesheet_set(VALUE self, VALUE style)
0
- xslt_doc = rb_class_new_instance(1, &style, rb_cFastXmlDoc );
0
- dv = rb_iv_get( xslt_doc, "@lxml_doc" );
0
- Data_Get_Struct( dv, fxml_data_t, data );
0
- data->xslt = xsltParseStylesheetDoc( data->doc );
0
- rb_iv_set( self, "@lxml_style", xslt_doc );
0
/* Applys an XSLT to the target FastXml::Doc.
0
* Returns the resulting FastXml::Doc
0
@@ -109,6 +81,7 @@ VALUE fastxml_doc_transform(VALUE self, VALUE xform)
0
VALUE ret, dv, xform_dv, ret_str, ret_dv;
0
fxml_data_t *my_data, *xf_data, *ret_data;
0
+ xsltStylesheetPtr style;
0
@@ -118,10 +91,16 @@ VALUE fastxml_doc_transform(VALUE self, VALUE xform)
0
xform_dv = rb_iv_get( xform, "@lxml_doc" );
0
Data_Get_Struct( xform_dv, fxml_data_t, xf_data );
0
- if (xf_data->
xslt == NULL)
0
+ if (xf_data->
doc == NULL)
0
+ if (xf_data->xslt == NULL) {
0
+ style = xsltParseStylesheetDoc( xf_data->doc );
0
+ return Qnil; // TODO: this should throw a FastXml exception
0
- ret_doc = (xmlDocPtr)xsltApplyStylesheet(
xf_data->xslt, my_data->doc, NULL );
0
+ ret_doc = (xmlDocPtr)xsltApplyStylesheet(
style, my_data->doc, NULL );
0
ret_str = rb_str_new2( "<shouldNeverBeSeen/>" );
0
ret = rb_class_new_instance( 1, &ret_str, rb_cFastXmlDoc ); // provide an xml snipped temporarily
0
ret_dv = rb_iv_get( ret, "@lxml_doc" );
0
@@ -129,6 +108,7 @@ VALUE fastxml_doc_transform(VALUE self, VALUE xform)
0
xmlFree( ret_data->doc );
0
ret_data->doc = ret_doc;
Comments
No one has commented yet.