Class: LibXML::XML::XPointer
- Inherits:
-
Object
- Object
- LibXML::XML::XPointer
- Defined in:
- ext/libxml/ruby_xml_xpointer.c,
ext/libxml/ruby_xml_xpointer.c
Overview
The XML::Pointer class provides a standards based API for searching an xml document. XPointer is based on the XML Path Language (XML::XPath) and is documented at www.w3.org/TR/WD-xptr.
Class Method Summary collapse
-
.XML::XPointer.range(start_node, end_node) ⇒ Object
Create an xpath representing the range between the supplied start and end node.
Class Method Details
.XML::XPointer.range(start_node, end_node) ⇒ Object
Create an xpath representing the range between the supplied start and end node.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'ext/libxml/ruby_xml_xpointer.c', line 65
static VALUE rxml_xpointer_range(VALUE class, VALUE rstart, VALUE rend)
{
#ifdef LIBXML_XPTR_ENABLED
xmlNodePtr start, end;
VALUE rxxp;
xmlXPathObjectPtr xpath;
if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
Data_Get_Struct(rstart, xmlNode, start);
if (start == NULL)
return(Qnil);
Data_Get_Struct(rend, xmlNode, end);
if (end == NULL)
return(Qnil);
xpath = xmlXPtrNewRangeNodes(start, end);
if (xpath == NULL)
rb_fatal("You shouldn't be able to have this happen");
rxxp = rxml_xpath_object_wrap(start->doc, xpath);
return(rxxp);
#else
rb_warn("libxml was compiled without XPointer support");
return (Qfalse);
#endif
}
|