class LibXML::XML::XPointer

  1. ext/libxml/libxml.c
Parent: XML

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.

Methods

Public Class

  1. range

Public Class methods

XML::XPointer.range(start_node, end_node) -> xpath

Create an xpath representing the range between the supplied start and end node.

[show source]
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
}