Nokogiri::XSLT

module Nokogiri::XSLT

See Nokogiri::XSLT::Stylesheet for creating and manipulating Stylesheet object.

Public Class Methods

parse(string, modules = {}) Show source

Parse the stylesheet in string, register any modules

# File lib/nokogiri/xslt.rb, line 24
def parse string, modules = {}
  modules.each do |url, klass|
    XSLT.register url, klass
  end

  if Nokogiri.jruby?
    Stylesheet.parse_stylesheet_doc(XML.parse(string), string)
  else
    Stylesheet.parse_stylesheet_doc(XML.parse(string))
  end
end
quote_params(params) Show source

Quote parameters in params for stylesheet safety

# File lib/nokogiri/xslt.rb, line 38
def quote_params params
  parray = (params.instance_of?(Hash) ? params.to_a.flatten : params).dup
  parray.each_with_index do |v,i|
    if i % 2 > 0
      parray[i]=
        if v =~ /'/
          "concat('#{ v.gsub(/'/, %q{', "'", '}) }')"
        else
          "'#{v}'";
        end
    else
      parray[i] = v.to_s
    end
  end
  parray.flatten
end
register(uri, custom_handler_class) Show source

Register a class that implements custom XSLT transformation functions.

static VALUE registr(VALUE self, VALUE uri, VALUE obj)
{
    VALUE modules = rb_iv_get(self, "@modules");
    if(NIL_P(modules)) rb_raise(rb_eRuntimeError, "wtf! @modules isn't set");

    rb_hash_aset(modules, uri, obj);
    xsltRegisterExtModule((unsigned char *)StringValueCStr(uri), initFunc, shutdownFunc);
    return self;
}

© 2008–2016 Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo
Patrick Mahoney, Yoko Harada, Akinori Musha, John Shahid
Licensed under the MIT License.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部