lib/rdf/rdfxml/reader/nokogiri.rb in rdf-rdfxml-1.1.2 vs lib/rdf/rdfxml/reader/nokogiri.rb in rdf-rdfxml-1.1.3
- old
+ new
@@ -21,10 +21,19 @@
def initialize(node, parent = nil)
@node = node
@parent = parent
end
+ # Create a new element child of an existing node
+ def create_node(name, children)
+ native = ::Nokogiri::XML::Element.new(name, @node)
+ children.each do |c|
+ native.add_child(c.node)
+ end
+ NodeProxy.new(native, self)
+ end
+
##
# Element language
#
# @return [String]
def language
@@ -122,10 +131,14 @@
end
NodeProxy.new(n, parent)
end
end
+ def at_xpath(*args)
+ xpath(*args).first
+ end
+
# For jRuby, there is a bug that prevents the namespace from being set on an element
if RUBY_PLATFORM == "java"
def add_namespace(prefix, href)
@def_namespace = href if prefix.nil?
@node.add_namespace(prefix, href)
@@ -148,9 +161,11 @@
def uri
ns = namespace || RDF::XML.to_s
ns = ns.href if ns.respond_to?(:href)
RDF::URI.intern(ns + self.node_name)
end
+
+ def to_s; @node.to_s; end
##
# Proxy for everything else to @node
def method_missing(method, *args)
@node.send(method, *args)