Class: LibXML::XML::Node
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
self,
Enumerable
|
|
| Inherits: | Object |
| Defined in: | ext/libxml/ruby_xml_node.c, ext/libxml/ruby_xml_node.c, lib/libxml/node.rb |
Overview
Nodes are the primary objects that make up an ::LibXML::XML document. The node class represents most node types that are found in an ::LibXML::XML document (but not Attributes, see Attr). It exposes libxml’s full API for creating, querying moving and deleting node objects. Many of these methods are documented in the DOM Level 3 specification found at: www.w3.org/TR/DOM-Level-3-Core/.
Constant Summary
-
ATTRIBUTE_DECL =
# File 'ext/libxml/ruby_xml_node.c', line 1365INT2FIX(XML_ATTRIBUTE_DECL)
-
ATTRIBUTE_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1351INT2FIX(XML_ATTRIBUTE_NODE)
-
CDATA_SECTION_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1353INT2FIX(XML_CDATA_SECTION_NODE)
-
COMMENT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1357INT2FIX(XML_COMMENT_NODE)
-
DOCB_DOCUMENT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1372INT2FIX(XML_DOCB_DOCUMENT_NODE)
-
DOCUMENT_FRAG_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1360INT2FIX(XML_DOCUMENT_FRAG_NODE)
-
DOCUMENT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1358INT2FIX(XML_DOCUMENT_NODE)
-
DOCUMENT_TYPE_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1359INT2FIX(XML_DOCUMENT_TYPE_NODE)
-
DTD_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1363INT2FIX(XML_DTD_NODE)
-
ELEMENT_DECL =
# File 'ext/libxml/ruby_xml_node.c', line 1364INT2FIX(XML_ELEMENT_DECL)
-
ELEMENT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1350INT2FIX(XML_ELEMENT_NODE)
-
ENTITY_DECL =
# File 'ext/libxml/ruby_xml_node.c', line 1366INT2FIX(XML_ENTITY_DECL)
-
ENTITY_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1355INT2FIX(XML_ENTITY_NODE)
-
ENTITY_REF_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1354INT2FIX(XML_ENTITY_REF_NODE)
-
HTML_DOCUMENT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1362INT2FIX(XML_HTML_DOCUMENT_NODE)
-
NAMESPACE_DECL =
# File 'ext/libxml/ruby_xml_node.c', line 1367INT2FIX(XML_NAMESPACE_DECL)
-
NOTATION_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1361INT2FIX(XML_NOTATION_NODE)
-
PI_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1356INT2FIX(XML_PI_NODE)
-
SPACE_DEFAULT =
# File 'ext/libxml/ruby_xml_node.c', line 1335INT2NUM(0)
-
SPACE_NOT_INHERIT =
# File 'ext/libxml/ruby_xml_node.c', line 1337INT2NUM(-1)
-
SPACE_PRESERVE =
# File 'ext/libxml/ruby_xml_node.c', line 1336INT2NUM(1)
-
TEXT_NODE =
# File 'ext/libxml/ruby_xml_node.c', line 1352INT2FIX(XML_TEXT_NODE)
-
XINCLUDE_END =
# File 'ext/libxml/ruby_xml_node.c', line 1369INT2FIX(XML_XINCLUDE_END)
-
XINCLUDE_START =
# File 'ext/libxml/ruby_xml_node.c', line 1368INT2FIX(XML_XINCLUDE_START)
-
XLINK_ACTUATE_AUTO =
# File 'ext/libxml/ruby_xml_node.c', line 1338INT2NUM(1)
-
XLINK_ACTUATE_NONE =
# File 'ext/libxml/ruby_xml_node.c', line 1339INT2NUM(0)
-
XLINK_ACTUATE_ONREQUEST =
# File 'ext/libxml/ruby_xml_node.c', line 1340INT2NUM(2)
-
XLINK_SHOW_EMBED =
# File 'ext/libxml/ruby_xml_node.c', line 1341INT2NUM(2)
-
XLINK_SHOW_NEW =
# File 'ext/libxml/ruby_xml_node.c', line 1342INT2NUM(1)
-
XLINK_SHOW_NONE =
# File 'ext/libxml/ruby_xml_node.c', line 1343INT2NUM(0)
-
XLINK_SHOW_REPLACE =
# File 'ext/libxml/ruby_xml_node.c', line 1344INT2NUM(3)
-
XLINK_TYPE_EXTENDED =
# File 'ext/libxml/ruby_xml_node.c', line 1345INT2NUM(2)
-
XLINK_TYPE_EXTENDED_SET =
# File 'ext/libxml/ruby_xml_node.c', line 1346INT2NUM(3)
-
XLINK_TYPE_NONE =
# File 'ext/libxml/ruby_xml_node.c', line 1347INT2NUM(0)
-
XLINK_TYPE_SIMPLE =
# File 'ext/libxml/ruby_xml_node.c', line 1348INT2NUM(1)
Class Method Summary
-
XML::Node.initialize(name, content = nil, namespace = nil) ⇒ Node
constructor
Creates a new element with the specified name, content and namespace.
-
XML::Node.new_cdata(content = nil) ⇒ Node
Create a new
#CDATAnode, optionally setting the node’s content. -
XML::Node.new_comment(content = nil) ⇒ Node
Create a new comment node, optionally setting the node’s content.
-
XML::Node.new_pi(name, content = nil) ⇒ Node
Create a new pi node, optionally setting the node’s content.
-
XML::Node.new_text(content) ⇒ Node
Create a new text node.
Instance Attribute Summary
-
#attribute? ⇒ Boolean
readonly
Specifies if this is an attribute node.
-
#attribute_decl? ⇒ Boolean
readonly
Specifies if this is an attribute declaration node.
-
#attributes ⇒ attributes
readonly
Returns the
Attributesfor this node. -
#attributes? ⇒ Boolean
readonly
Determines whether this node has attributes.
-
#base_uri ⇒ "uri"
rw
Obtain this node’s base URI.
-
#base_uri=("uri")
rw
Set this node’s base URI.
-
#empty? ⇒ Boolean
(also: #empty?)
readonly
Determine whether this node is an empty or whitespace only text-node.
-
#cdata? ⇒ Boolean
readonly
Specifies if this is an CDATA node.
-
#child
readonly
Alias for #first.
-
#child?
readonly
Alias for #first?.
-
#children?
readonly
Alias for #first?.
-
#comment? ⇒ Boolean
readonly
Specifies if this is an comment node.
-
#content ⇒ "string"
rw
Obtain this node’s content as a string.
-
#content=("string")
rw
Set this node’s content to the specified string.
-
#docbook_doc? ⇒ Boolean
readonly
Specifies if this is an docbook node.
-
#doctype? ⇒ Boolean
readonly
Specifies if this is an doctype node.
-
#document? ⇒ Boolean
readonly
Specifies if this is an document node.
-
#dtd? ⇒ Boolean
readonly
Specifies if this is an DTD node.
-
#element? ⇒ Boolean
readonly
Specifies if this is an element node.
-
#element_decl? ⇒ Boolean
readonly
Specifies if this is an element declaration node.
-
#empty? ⇒ Boolean
readonly
Alias for #blank?.
-
#entity? ⇒ Boolean
readonly
Specifies if this is an entity node.
-
#entity_ref? ⇒ Boolean
readonly
Specifies if this is an entity reference node.
-
#first ⇒ Node
(also: #child)
readonly
Returns this node’s first child node if any.
-
#first? ⇒ Boolean
(also: #child?, #children?)
readonly
Determines whether this node has a first node.
-
#fragment? ⇒ Boolean
readonly
Specifies if this is a fragment node.
-
#html_doc? ⇒ Boolean
readonly
Specifies if this is a html document node.
-
#lang ⇒ "string"
rw
Obtain the language set for this node, if any.
-
#lang=("string")
rw
Set the language for this node.
-
#last ⇒ Node
readonly
Obtain the last child node of this node, if any.
-
#last? ⇒ Boolean
readonly
Determines whether this node has a last node.
-
#name ⇒ "string"
rw
Obtain this node’s name.
-
#name=("string")
rw
Set this node’s name.
-
#namespace? ⇒ Boolean
readonly
Specifies if this is a namespace node (not if it has a namepsace).
-
#next ⇒ Node
rw
Returns the next sibling node if one exists.
-
#next=(node)
rw
Adds the specified node as the next sibling of the current node.
-
#next? ⇒ Boolean
rw
Determines whether this node has a next node.
-
#notation? ⇒ Boolean
readonly
Specifies if this is a notation node.
-
#output_escaping=(true|false)
rw
Controls whether this text node or the immediate text node children of an element or attribute node escapes their output.
-
#output_escaping? ⇒ Boolean
rw
Determine whether this node escapes it’s output or not.
-
#parent ⇒ Node
readonly
Obtain this node’s parent node, if any.
-
#parent? ⇒ Boolean
readonly
Determines whether this node has a parent node.
-
#pi? ⇒ Boolean
readonly
Specifies if this is a processiong instruction node.
-
#prev ⇒ Node
rw
Obtain the previous sibling, if any.
-
#prev=(node)
rw
Adds the specified node as the previous sibling of the current node.
-
#prev? ⇒ Boolean
rw
Determines whether this node has a previous node.
-
#sibling=(node)
writeonly
Adds the specified node as the end of the current node’s list of siblings.
-
#space_preserve ⇒ Boolean
rw
Determine whether this node preserves whitespace.
-
#space_preserve=(true|false)
rw
Control whether this node preserves whitespace.
-
#text? ⇒ Boolean
readonly
Specifies if this is a text node.
-
#xinclude_end? ⇒ Boolean
readonly
Specifies if this is an xinclude end node.
-
#xinclude_start? ⇒ Boolean
readonly
Specifies if this is an xinclude start node.
-
#xlink? ⇒ Boolean
readonly
Determine whether this node is an xlink node.
Instance Method Summary
-
#<<(node)
Add the specified text or
Nodeas a new child node to the current node. -
#==(other_node) ⇒ Boolean
(also: #eql?)
Test equality between the two nodes.
-
#[]("name") ⇒ "string"
Obtain the named property.
-
#[]=(name, value)
Set the named property.
-
#children
readonly
Returns this node’s children as an array.
-
#clone
Create a shallow copy of the node.
-
#context(namespaces = nil) ⇒ XPath::Context
Returns a new
XML::XPathContextfor the current node. -
#copy ⇒ Node
Creates a copy of this node.
-
#debug ⇒ Boolean
Print libxml debugging information to stdout.
-
#doc ⇒ document
Obtain the
Documentthis node belongs to. -
#dup ⇒ Node
Create a shallow copy of the node.
-
#each ⇒ Node
(also: #each_child)
Iterates over this node’s children, including text nodes, element nodes, etc.
-
#each_attr
——- Traversal —————- Iterates over this node’s attributes.
-
#each_child
Alias for #each.
-
#each_element
Iterates over this node’s child elements (nodes that have a node_type == ELEMENT_NODE).
-
#eql?(other_node) ⇒ Boolean
Alias for #==.
-
#find(namespaces = nil) ⇒ XPath::XPathObject
Return nodes matching the specified xpath expression.
-
#find_first(namespaces = nil) ⇒ Node
Return the first node matching the specified xpath expression.
-
#inner_xml ⇒ "string"
Converts a node’s children to a string representation.
-
#line_num ⇒ Numeric
Obtain the line number (in the
::LibXML::XMLdocument) that this node was read from. -
#namespacess ⇒ XML::Namespaces
Returns this node’s
Namespacesobject, which is used to access the namespaces associated with this node. -
#type ⇒ Numeric
Obtain this node’s type identifier.
-
#node_type_name
Returns this node’s type name.
-
#path ⇒ path
Obtain this node’s path.
-
#remove! ⇒ Node
Removes this node and its children from the document tree by setting its document, parent and siblings to nil.
-
#to_s ⇒ "string"
Converts a node, and all of its children, to a string representation.
-
#xlink_type ⇒ Numeric
Obtain the type identifier for this xlink, if applicable.
-
#xlink_type_name ⇒ "string"
Obtain the type name for this xlink, if applicable.
- #create_string_io(xml) private
Constructor Details
XML::Node.initialize(name, content = nil, namespace = nil) ⇒ Node
Creates a new element with the specified name, content and namespace. The content and namespace may be nil.
# File 'ext/libxml/ruby_xml_node.c', line 312
static VALUE rxml_node_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE name;
VALUE content;
VALUE ns;
xmlNodePtr xnode = NULL;
xmlNsPtr xns = NULL;
rb_scan_args(argc, argv, "12", &name, &content, &ns);
name = rb_obj_as_string(name);
if (!NIL_P(ns))
TypedData_Get_Struct(ns, xmlNs, &rxml_namespace_type, xns);
xnode = xmlNewNode(xns, (xmlChar*) StringValuePtr(name));
if (xnode == NULL)
rxml_raise(xmlGetLastError());
// Link the ruby wrapper to the underlying libxml node
RTYPEDDATA_DATA(self) = xnode;
// Ruby is in charge of managing this node's memory
rxml_node_manage(xnode, self);
if (!NIL_P(content))
rxml_node_content_set(self, content);
return self;
}
Class Method Details
XML::Node.new_cdata(content = nil) ⇒ Node
Create a new #CDATA node, optionally setting the node’s content.
# File 'ext/libxml/ruby_xml_node.c', line 191
static VALUE rxml_node_new_cdata(int argc, VALUE *argv, VALUE klass)
{
VALUE content = Qnil;
xmlNodePtr xnode;
rb_scan_args(argc, argv, "01", &content);
if (NIL_P(content))
{
xnode = xmlNewCDataBlock(NULL, NULL, 0);
}
else
{
content = rb_obj_as_string(content);
xnode = xmlNewCDataBlock(NULL, (xmlChar*) StringValuePtr(content), (int)RSTRING_LEN(content));
}
if (xnode == NULL)
rxml_raise(xmlGetLastError());
return rxml_node_wrap(xnode);
}
XML::Node.new_comment(content = nil) ⇒ Node
Create a new comment node, optionally setting the node’s content.
# File 'ext/libxml/ruby_xml_node.c', line 222
static VALUE rxml_node_new_comment(int argc, VALUE *argv, VALUE klass)
{
VALUE content = Qnil;
xmlNodePtr xnode;
rb_scan_args(argc, argv, "01", &content);
if (NIL_P(content))
{
xnode = xmlNewComment(NULL);
}
else
{
content = rb_obj_as_string(content);
xnode = xmlNewComment((xmlChar*) StringValueCStr(content));
}
if (xnode == NULL)
rxml_raise(xmlGetLastError());
return rxml_node_wrap(xnode);
}
XML::Node.new_pi(name, content = nil) ⇒ Node
Create a new pi node, optionally setting the node’s content.
# File 'ext/libxml/ruby_xml_node.c', line 253
static VALUE rxml_node_new_pi(int argc, VALUE *argv, VALUE klass)
{
VALUE name = Qnil;
VALUE content = Qnil;
xmlNodePtr xnode;
rb_scan_args(argc, argv, "11", &name, &content);
if (NIL_P(name))
{
rb_raise(rb_eRuntimeError, "You must provide me with a name for a PI.");
}
name = rb_obj_as_string(name);
if (NIL_P(content))
{
xnode = xmlNewPI((xmlChar*) StringValuePtr(name), NULL);
}
else
{
content = rb_obj_as_string(content);
xnode = xmlNewPI((xmlChar*) StringValuePtr(name), (xmlChar*) StringValueCStr(content));
}
if (xnode == NULL)
rxml_raise(xmlGetLastError());
return rxml_node_wrap(xnode);
}
XML::Node.new_text(content) ⇒ Node
Create a new text node.
# File 'ext/libxml/ruby_xml_node.c', line 289
static VALUE rxml_node_new_text(VALUE klass, VALUE content)
{
xmlNodePtr xnode;
Check_Type(content, T_STRING);
content = rb_obj_as_string(content);
xnode = xmlNewText((xmlChar*) StringValueCStr(content));
if (xnode == NULL)
rxml_raise(xmlGetLastError());
return rxml_node_wrap(xnode);
}
Instance Attribute Details
#attribute? ⇒ Boolean (readonly)
Specifies if this is an attribute node
# File 'lib/libxml/node.rb', line 207
def attribute? node_type == ATTRIBUTE_NODE end
#attribute_decl? ⇒ Boolean (readonly)
Specifies if this is an attribute declaration node
# File 'lib/libxml/node.rb', line 212
def attribute_decl? node_type == ATTRIBUTE_DECL end
#attributes ⇒ attributes (readonly)
Returns the Attributes for this node.
# File 'ext/libxml/ruby_xml_node.c', line 1099
static VALUE rxml_node_attributes_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
return rxml_attributes_new(xnode);
}
#attributes? ⇒ Boolean (readonly)
Determines whether this node has attributes
# File 'lib/libxml/node.rb', line 9
def attributes? attributes.length > 0 end
#base_uri ⇒ "uri" (rw)
Obtain this node’s base URI.
# File 'ext/libxml/ruby_xml_node.c', line 382
static VALUE rxml_node_base_uri_get(VALUE self)
{
xmlNodePtr xnode;
xmlChar* base_uri;
VALUE result = Qnil;
xnode = rxml_get_xnode(self);
if (xnode->doc == NULL)
return (result);
base_uri = xmlNodeGetBase(xnode->doc, xnode);
if (base_uri)
{
result = rxml_new_cstr( base_uri, NULL);
xmlFree(base_uri);
}
return (result);
}
#base_uri=("uri") (rw)
Set this node’s base URI.
# File 'ext/libxml/ruby_xml_node.c', line 411
static VALUE rxml_node_base_uri_set(VALUE self, VALUE uri)
{
xmlNodePtr xnode;
Check_Type(uri, T_STRING);
xnode = rxml_get_xnode(self);
if (xnode->doc == NULL)
return (Qnil);
xmlNodeSetBase(xnode, (xmlChar*) StringValuePtr(uri));
return (Qtrue);
}
#empty? ⇒ Boolean (readonly) Also known as: #empty?
Determine whether this node is an empty or whitespace only text-node.
# File 'ext/libxml/ruby_xml_node.c', line 703
static VALUE rxml_node_empty_q(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (xnode == NULL)
return (Qnil);
return ((xmlIsBlankNode(xnode) == 1) ? Qtrue : Qfalse);
}
#cdata? ⇒ Boolean (readonly)
Specifies if this is an CDATA node
# File 'lib/libxml/node.rb', line 217
def cdata? node_type == CDATA_SECTION_NODE end
#child (readonly)
Alias for #first.
# File 'lib/libxml/node.rb', line 309
alias :child :first
#child? (readonly)
Alias for #first?.
# File 'lib/libxml/node.rb', line 307
alias :child? :first?
#children? (readonly)
Alias for #first?.
# File 'lib/libxml/node.rb', line 308
alias :children? :first?
#comment? ⇒ Boolean (readonly)
Specifies if this is an comment node
# File 'lib/libxml/node.rb', line 222
def comment? node_type == COMMENT_NODE end
#content ⇒ "string" (rw)
Obtain this node’s content as a string.
# File 'ext/libxml/ruby_xml_node.c', line 430
static VALUE rxml_node_content_get(VALUE self)
{
xmlNodePtr xnode;
xmlChar *content;
VALUE result = Qnil;
xnode = rxml_get_xnode(self);
content = xmlNodeGetContent(xnode);
if (content)
{
result = rxml_new_cstr(content, NULL);
xmlFree(content);
}
return result;
}
#content=("string") (rw)
Set this node’s content to the specified string.
# File 'ext/libxml/ruby_xml_node.c', line 453
static VALUE rxml_node_content_set(VALUE self, VALUE content)
{
xmlNodePtr xnode;
xmlChar* encoded_content;
Check_Type(content, T_STRING);
xnode = rxml_get_xnode(self);
encoded_content = xmlEncodeSpecialChars(xnode->doc, (xmlChar*) StringValuePtr(content));
xmlNodeSetContent(xnode, encoded_content);
xmlFree(encoded_content);
return (Qtrue);
}
#docbook_doc? ⇒ Boolean (readonly)
Specifies if this is an docbook node
# File 'lib/libxml/node.rb', line 227
def docbook_doc? node_type == DOCB_DOCUMENT_NODE end
#doctype? ⇒ Boolean (readonly)
Specifies if this is an doctype node
# File 'lib/libxml/node.rb', line 232
def doctype? node_type == DOCUMENT_TYPE_NODE end
#document? ⇒ Boolean (readonly)
Specifies if this is an document node
# File 'lib/libxml/node.rb', line 237
def document? node_type == DOCUMENT_NODE end
#dtd? ⇒ Boolean (readonly)
Specifies if this is an DTD node
#element? ⇒ Boolean (readonly)
Specifies if this is an element node
# File 'lib/libxml/node.rb', line 247
def element? node_type == ELEMENT_NODE end
#element_decl? ⇒ Boolean (readonly)
Specifies if this is an element declaration node
# File 'lib/libxml/node.rb', line 257
def element_decl? node_type == ELEMENT_DECL end
#empty? ⇒ Boolean (readonly)
#empty? ⇒ Boolean
Boolean (readonly)
#empty? ⇒ Boolean
Alias for #blank?.
#entity? ⇒ Boolean (readonly)
Specifies if this is an entity node
# File 'lib/libxml/node.rb', line 252
def entity? node_type == ENTITY_NODE end
#entity_ref? ⇒ Boolean (readonly)
Specifies if this is an entity reference node
# File 'lib/libxml/node.rb', line 262
def entity_ref? node_type == ENTITY_REF_NODE end
#first ⇒ Node (readonly) Also known as: #child
Returns this node’s first child node if any.
# File 'ext/libxml/ruby_xml_node.c', line 492
static VALUE rxml_node_first_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (xnode->children)
return (rxml_node_wrap(xnode->children));
else
return (Qnil);
}
#first? ⇒ Boolean (readonly)
Also known as: #child?, #children?
Determines whether this node has a first node
# File 'lib/libxml/node.rb', line 126
def first? not first.nil? end
#fragment? ⇒ Boolean (readonly)
Specifies if this is a fragment node
# File 'lib/libxml/node.rb', line 267
def fragment? node_type == DOCUMENT_FRAG_NODE end
#html_doc? ⇒ Boolean (readonly)
Specifies if this is a html document node
# File 'lib/libxml/node.rb', line 272
def html_doc? node_type == HTML_DOCUMENT_NODE end
#lang ⇒ "string" (rw)
Obtain the language set for this node, if any. This is set in ::LibXML::XML via the xml:lang attribute.
# File 'ext/libxml/ruby_xml_node.c', line 745
static VALUE rxml_node_lang_get(VALUE self)
{
xmlNodePtr xnode;
xmlChar *lang;
VALUE result = Qnil;
xnode = rxml_get_xnode(self);
lang = xmlNodeGetLang(xnode);
if (lang)
{
result = rxml_new_cstr( lang, NULL);
xmlFree(lang);
}
return (result);
}
#lang=("string") (rw)
Set the language for this node. This affects the value of the xml:lang attribute.
# File 'ext/libxml/ruby_xml_node.c', line 772
static VALUE rxml_node_lang_set(VALUE self, VALUE lang)
{
xmlNodePtr xnode;
Check_Type(lang, T_STRING);
xnode = rxml_get_xnode(self);
xmlNodeSetLang(xnode, (xmlChar*) StringValuePtr(lang));
return (Qtrue);
}
#last ⇒ Node (readonly)
Obtain the last child node of this node, if any.
# File 'ext/libxml/ruby_xml_node.c', line 789
static VALUE rxml_node_last_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (xnode->last)
return (rxml_node_wrap(xnode->last));
else
return (Qnil);
}
#last? ⇒ Boolean (readonly)
Determines whether this node has a last node
# File 'lib/libxml/node.rb', line 146
def last? not last.nil? end
#name ⇒ "string" (rw)
Obtain this node’s name.
# File 'ext/libxml/ruby_xml_node.c', line 901
static VALUE rxml_node_name_get(VALUE self)
{
xmlNodePtr xnode;
const xmlChar *name;
xnode = rxml_get_xnode(self);
switch (xnode->type)
{
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
{
xmlDocPtr doc = (xmlDocPtr) xnode;
name = doc->URL;
break;
}
case XML_ATTRIBUTE_NODE:
{
xmlAttrPtr attr = (xmlAttrPtr) xnode;
name = attr->name;
break;
}
case XML_NAMESPACE_DECL:
{
xmlNsPtr ns = (xmlNsPtr) xnode;
name = ns->prefix;
break;
}
default:
name = xnode->name;
break;
}
if (xnode->name == NULL)
return (Qnil);
else
return (rxml_new_cstr( name, NULL));
}
#name=("string") (rw)
Set this node’s name.
# File 'ext/libxml/ruby_xml_node.c', line 949
static VALUE rxml_node_name_set(VALUE self, VALUE name)
{
xmlNodePtr xnode;
const xmlChar *xname;
Check_Type(name, T_STRING);
xnode = rxml_get_xnode(self);
xname = (const xmlChar*)StringValuePtr(name);
/* Note: calling xmlNodeSetName() for a text node is ignored by libXML. */
xmlNodeSetName(xnode, xname);
return (Qtrue);
}
#namespace? ⇒ Boolean (readonly)
Specifies if this is a namespace node (not if it has a namepsace)
# File 'lib/libxml/node.rb', line 278
def namespace? node_type == NAMESPACE_DECL end
#next ⇒ Node (rw)
Returns the next sibling node if one exists.
# File 'ext/libxml/ruby_xml_node.c', line 970
static VALUE rxml_node_next_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (xnode->next)
return (rxml_node_wrap(xnode->next));
else
return (Qnil);
}
#next=(node) (rw)
Adds the specified node as the next sibling of the current node. If the node already exists in the document, it is first removed from its existing context. Any adjacent text nodes will be merged together, meaning the returned node may be different than the original node.
# File 'ext/libxml/ruby_xml_node.c', line 992
static VALUE rxml_node_next_set(VALUE self, VALUE next)
{
return rxml_node_modify_dom(self, next, xmlAddNextSibling);
}
#next? ⇒ Boolean (rw)
Determines whether this node has a next node
# File 'lib/libxml/node.rb', line 136
def next? not self.next.nil? end
#notation? ⇒ Boolean (readonly)
Specifies if this is a notation node
# File 'lib/libxml/node.rb', line 283
def notation? node_type == NOTATION_NODE end
#output_escaping=(true|false) (rw)
#output_escaping=(true|false)
#output_escaping=(true|false)
Controls whether this text node or the immediate text node children of an element or attribute node escapes their output. Any other type of node will simply ignore this operation.
Text nodes which are added to an element or attribute node will be affected by any previous setting of this property.
# File 'ext/libxml/ruby_xml_node.c', line 1234
static VALUE rxml_node_output_escaping_set(VALUE self, VALUE value)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
switch (xnode->type) {
case XML_TEXT_NODE:
xnode->name = (value != Qfalse && value != Qnil) ? xmlStringText : xmlStringTextNoenc;
break;
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
{
const xmlChar *name = (value != Qfalse && value != Qnil) ? xmlStringText : xmlStringTextNoenc;
xmlNodePtr tmp;
for (tmp = xnode->children; tmp; tmp = tmp->next)
if (tmp->type == XML_TEXT_NODE)
tmp->name = name;
}
break;
default:
return Qnil;
}
return (value!=Qfalse && value!=Qnil) ? Qtrue : Qfalse;
}
#output_escaping? ⇒ Boolean (rw)
#output_escaping? ⇒ Boolean
#output_escaping? ⇒ Boolean
#output_escaping? ⇒ Boolean
Boolean (rw)
#output_escaping? ⇒ Boolean
#output_escaping? ⇒ Boolean
#output_escaping? ⇒ Boolean
Determine whether this node escapes it’s output or not.
Text nodes return only true or false. Element and attribute nodes examine their immediate text node children to determine the value. Any other type of node always returns nil.
If an element or attribute node has at least one immediate child text node and all the immediate text node children have the same output_escaping? value, that value is returned. Otherwise, nil is returned.
# File 'ext/libxml/ruby_xml_node.c', line 1187
static VALUE rxml_node_output_escaping_q(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
switch (xnode->type) {
case XML_TEXT_NODE:
return xnode->name==xmlStringTextNoenc ? Qfalse : Qtrue;
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
{
xmlNodePtr tmp = xnode->children;
const xmlChar *match = NULL;
/* Find the first text node and use it as the reference. */
while (tmp && tmp->type != XML_TEXT_NODE)
tmp = tmp->next;
if (! tmp)
return Qnil;
match = tmp->name;
/* Walk the remaining text nodes until we run out or one doesn't match. */
while (tmp && (tmp->type != XML_TEXT_NODE || match == tmp->name))
tmp = tmp->next;
/* We're left with either the mismatched node or the aggregate result. */
return tmp ? Qnil : (match==xmlStringTextNoenc ? Qfalse : Qtrue);
}
break;
default:
return Qnil;
}
}
#parent ⇒ Node (readonly)
Obtain this node’s parent node, if any.
# File 'ext/libxml/ruby_xml_node.c', line 1003
static VALUE rxml_node_parent_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (xnode->parent)
return (rxml_node_wrap(xnode->parent));
else
return (Qnil);
}
#parent? ⇒ Boolean (readonly)
Determines whether this node has a parent node
# File 'lib/libxml/node.rb', line 121
def parent? not parent.nil? end
#pi? ⇒ Boolean (readonly)
Specifies if this is a processiong instruction node
#prev ⇒ Node (rw)
Obtain the previous sibling, if any.
# File 'ext/libxml/ruby_xml_node.c', line 1045
static VALUE rxml_node_prev_get(VALUE self)
{
xmlNodePtr xnode;
xmlNodePtr node;
xnode = rxml_get_xnode(self);
switch (xnode->type)
{
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_NAMESPACE_DECL:
node = NULL;
break;
case XML_ATTRIBUTE_NODE:
{
xmlAttrPtr attr = (xmlAttrPtr) xnode;
node = (xmlNodePtr) attr->prev;
}
break;
default:
node = xnode->prev;
break;
}
if (node == NULL)
return (Qnil);
else
return (rxml_node_wrap(node));
}
#prev=(node) (rw)
Adds the specified node as the previous sibling of the current node. If the node already exists in the document, it is first removed from its existing context. Any adjacent text nodes will be merged together, meaning the returned node may be different than the original node.
# File 'ext/libxml/ruby_xml_node.c', line 1088
static VALUE rxml_node_prev_set(VALUE self, VALUE prev)
{
return rxml_node_modify_dom(self, prev, xmlAddPrevSibling);
}
#prev? ⇒ Boolean (rw)
Determines whether this node has a previous node
# File 'lib/libxml/node.rb', line 141
def prev? not prev.nil? end
#sibling=(node) (writeonly)
Adds the specified node as the end of the current node’s list of siblings. If the node already exists in the document, it is first removed from its existing context. Any adjacent text nodes will be merged together, meaning the returned node may be different than the original node.
# File 'ext/libxml/ruby_xml_node.c', line 1165
static VALUE rxml_node_sibling_set(VALUE self, VALUE sibling)
{
return rxml_node_modify_dom(self, sibling, xmlAddSibling);
}
#space_preserve ⇒ Boolean (rw)
Determine whether this node preserves whitespace.
# File 'ext/libxml/ruby_xml_node.c', line 1266
static VALUE rxml_node_space_preserve_get(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
return (INT2NUM(xmlNodeGetSpacePreserve(xnode)));
}
#space_preserve=(true|false) (rw)
Control whether this node preserves whitespace.
# File 'ext/libxml/ruby_xml_node.c', line 1280
static VALUE rxml_node_space_preserve_set(VALUE self, VALUE value)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
if (value == Qfalse)
xmlNodeSetSpacePreserve(xnode, 0);
else
xmlNodeSetSpacePreserve(xnode, 1);
return (Qnil);
}
#text? ⇒ Boolean (readonly)
Specifies if this is a text node
#xinclude_end? ⇒ Boolean (readonly)
Specifies if this is an xinclude end node
# File 'lib/libxml/node.rb', line 298
def xinclude_end? node_type == XINCLUDE_END end
#xinclude_start? ⇒ Boolean (readonly)
Specifies if this is an xinclude start node
# File 'lib/libxml/node.rb', line 303
def xinclude_start? node_type == XINCLUDE_START end
#xlink? ⇒ Boolean (readonly)
Determine whether this node is an xlink node.
# File 'ext/libxml/ruby_xml_node.c', line 828
static VALUE rxml_node_xlink_q(VALUE self)
{
xmlNodePtr xnode;
xlinkType xlt;
xnode = rxml_get_xnode(self);
xlt = xlinkIsLink(xnode->doc, xnode);
if (xlt == XLINK_TYPE_NONE)
return (Qfalse);
else
return (Qtrue);
}
Instance Method Details
#curr_node(<< "Some text")
#<<(node)
Add the specified text or Node as a new child node to the current node.
If the specified argument is a string, it should be a raw string that contains unescaped ::LibXML::XML special characters. Entity references are not supported.
The method will return the current node.
# File 'ext/libxml/ruby_xml_node.c', line 519
static VALUE rxml_node_content_add(VALUE self, VALUE obj)
{
xmlNodePtr xnode;
VALUE str;
xnode = rxml_get_xnode(self);
/* XXX This should only be legal for a CDATA type node, I think,
* resulting in a merge of content, as if a string were passed
* danj 070827
*/
if (rb_obj_is_kind_of(obj, cXMLNode))
{
rxml_node_modify_dom(self, obj, xmlAddChild);
}
else
{
str = rb_obj_as_string(obj);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "invalid argument: must be string or XML::Node");
xmlNodeAddContent(xnode, (xmlChar*) StringValuePtr(str));
}
return self;
}
#==(other_node) ⇒ Boolean Also known as: #eql?
Test equality between the two nodes. Two nodes are equal if they are the same node.
# File 'ext/libxml/ruby_xml_node.c', line 720
static VALUE rxml_node_eql_q(VALUE self, VALUE other)
{
if (self == other)
{
return Qtrue;
}
else if (NIL_P(other))
{
return Qfalse;
}
else
{
xmlNodePtr xnode = rxml_get_xnode(self);
xmlNodePtr xnode_other = rxml_get_xnode(other);
return xnode == xnode_other ? Qtrue : Qfalse;
}
}
#property("name") ⇒ "string"
#[]("name") ⇒ "string"
string"
#[]("name") ⇒ "string"
Obtain the named property.
# File 'ext/libxml/ruby_xml_node.c', line 1114
static VALUE rxml_node_attribute_get(VALUE self, VALUE name)
{
VALUE attributes = rxml_node_attributes_get(self);
return rxml_attributes_attribute_get(attributes, name);
}
#[]=(name, value)
Set the named property.
# File 'ext/libxml/ruby_xml_node.c', line 1126
static VALUE rxml_node_property_set(VALUE self, VALUE name, VALUE value)
{
VALUE attributes = rxml_node_attributes_get(self);
return rxml_attributes_attribute_set(attributes, name, value);
}
#children (readonly)
Returns this node’s children as an array.
# File 'lib/libxml/node.rb', line 131
def children entries end
#clone
Create a shallow copy of the node. To create a deep copy call #copy(true)
# File 'lib/libxml/node.rb', line 15
def clone copy(false) end
#context(namespaces = nil) ⇒ XPath::Context
Returns a new XML::XPathContext for the current node.
Namespaces is an optional array of XML::NS objects
# File 'lib/libxml/node.rb', line 53
def context(nslist = nil) if not self.doc raise(TypeError, "A node must belong to a document before a xpath context can be created") end context = XPath::Context.new(self.doc) context.node = self context.register_namespaces_from_node(self) context.register_namespaces_from_node(self.doc.root) context.register_namespaces(nslist) if nslist context end
#copy ⇒ Node
Creates a copy of this node. To create a shallow copy set the deep parameter to false. To create a deep copy set the deep parameter to true.
# File 'ext/libxml/ruby_xml_node.c', line 1316
static VALUE rxml_node_copy(VALUE self, VALUE deep)
{
xmlNodePtr xnode;
xmlNodePtr xcopy;
int recursive = (deep == Qnil || deep == Qfalse) ? 0 : 1;
xnode = rxml_get_xnode(self);
xcopy = xmlCopyNode(xnode, recursive);
if (xcopy)
return rxml_node_wrap(xcopy);
else
return Qnil;
}
#create_string_io(xml) (private)
[ GitHub ]# File 'lib/libxml/node.rb', line 314
def create_string_io(xml) result = StringIO.new("") result.set_encoding(xml.encoding) result end
#debug ⇒ Boolean
Print libxml debugging information to stdout. Requires that libxml was compiled with debugging enabled.
# File 'ext/libxml/ruby_xml_node.c', line 473
static VALUE rxml_node_debug(VALUE self)
{
#ifdef LIBXML_DEBUG_ENABLED
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
xmlDebugDumpNode(NULL, xnode, 2);
return Qtrue;
#else
rb_warn("libxml was compiled without debugging support.");
return Qfalse;
#endif
}
#doc ⇒ document
Obtain the Document this node belongs to.
# File 'ext/libxml/ruby_xml_node.c', line 551
static VALUE rxml_node_doc(VALUE self)
{
xmlDocPtr xdoc = NULL;
xmlNodePtr xnode = rxml_get_xnode(self);
switch (xnode->type)
{
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_NAMESPACE_DECL:
break;
case XML_ATTRIBUTE_NODE:
xdoc = (xmlDocPtr)((xmlAttrPtr) xnode->doc);
break;
default:
xdoc = xnode->doc;
}
if (xdoc == NULL)
return (Qnil);
return rxml_registry_lookup(xdoc);
}
#dup ⇒ Node
Create a shallow copy of the node. To create a deep copy call #copy(true)
# File 'lib/libxml/node.rb', line 43
def dup copy(false) end
#each ⇒ Node Also known as: #each_child
# File 'ext/libxml/ruby_xml_node.c', line 677
static VALUE rxml_node_each(VALUE self)
{
xmlNodePtr xnode;
xmlNodePtr xcurrent;
xnode = rxml_get_xnode(self);
xcurrent = xnode->children;
while (xcurrent)
{
/* The user could remove this node, so first stache
away the next node. */
xmlNodePtr xnext = xcurrent->next;
rb_yield(rxml_node_wrap(xcurrent));
xcurrent = xnext;
}
return Qnil;
}
#each_attr
# File 'lib/libxml/node.rb', line 103
def each_attr attributes.each do |attr| yield(attr) end end
#each_child
Alias for #each.
# File 'lib/libxml/node.rb', line 310
alias :each_child :each
#each_element
# File 'lib/libxml/node.rb', line 114
def each_element each do |node| yield(node) if node.node_type == ELEMENT_NODE end end
#==(other_node) ⇒ Boolean
#eql?(other_node) ⇒ Boolean
Boolean
#eql?(other_node) ⇒ Boolean
Alias for #==.
#find(namespaces = nil) ⇒ XPath::XPathObject
Return nodes matching the specified xpath expression. For more information, please refer to the documentation for Document#find.
Namespaces is an optional array of XML::NS objects
# File 'lib/libxml/node.rb', line 74
def find(xpath, nslist = nil) self.context(nslist).find(xpath) end
#find_first(namespaces = nil) ⇒ Node
Return the first node matching the specified xpath expression. For more information, please refer to the documentation for the #find method.
#inner_xml ⇒ "string"
#inner_xml(:indent) ⇒ true, :encoding
string"
#inner_xml(:indent) ⇒ true, :encoding
# File 'lib/libxml/node.rb', line 26
def inner_xml( = Hash.new) io = nil self.each do |node| xml = node.to_s() # Create the string IO here since we now know the encoding io = create_string_io(xml) unless io io << xml end io ? io.string : nil end
#line_num ⇒ Numeric
Obtain the line number (in the ::LibXML::XML document) that this node was read from. If default_line_numbers is set false (the default), this method returns zero.
# File 'ext/libxml/ruby_xml_node.c', line 809
static VALUE rxml_node_line_num(VALUE self)
{
xmlNodePtr xnode;
long line_num;
xnode = rxml_get_xnode(self);
line_num = xmlGetLineNo(xnode);
if (line_num == -1)
return (Qnil);
else
return (LONG2NUM((long) line_num));
}
#namespacess ⇒ XML::Namespaces
Returns this node’s Namespaces object, which is used to access the namespaces associated with this node.
# File 'lib/libxml/node.rb', line 94
def namespaces @namespaces ||= XML::Namespaces.new(self) end
#type ⇒ Numeric
Obtain this node’s type identifier.
# File 'ext/libxml/ruby_xml_node.c', line 1299
static VALUE rxml_node_type(VALUE self)
{
xmlNodePtr xnode;
xnode = rxml_get_xnode(self);
return (INT2NUM(xnode->type));
}
#node_type_name
Returns this node’s type name
# File 'lib/libxml/node.rb', line 154
def node_type_name case node_type # Most common choices first when ATTRIBUTE_NODE 'attribute' when DOCUMENT_NODE 'document_xml' when ELEMENT_NODE 'element' when TEXT_NODE 'text' # Now the rest when ATTRIBUTE_DECL 'attribute_decl' when CDATA_SECTION_NODE 'cdata' when COMMENT_NODE 'comment' when DOCB_DOCUMENT_NODE 'document_docbook' when DOCUMENT_FRAG_NODE 'fragment' when DOCUMENT_TYPE_NODE 'doctype' when DTD_NODE 'dtd' when ELEMENT_DECL 'elem_decl' when ENTITY_DECL 'entity_decl' when ENTITY_NODE 'entity' when ENTITY_REF_NODE 'entity_ref' when HTML_DOCUMENT_NODE 'document_html' when NAMESPACE_DECL 'namespace' when NOTATION_NODE 'notation' when PI_NODE 'pi' when XINCLUDE_START 'xinclude_start' when XINCLUDE_END 'xinclude_end' else raise(UnknownType, "Unknown node type: %n", node.node_type); end end
#path ⇒ path
Obtain this node’s path.
# File 'ext/libxml/ruby_xml_node.c', line 1021
static VALUE rxml_node_path(VALUE self)
{
xmlNodePtr xnode;
xmlChar *path;
VALUE result = Qnil;
xnode = rxml_get_xnode(self);
path = xmlGetNodePath(xnode);
if (path)
{
result = rxml_new_cstr( path, NULL);
xmlFree(path);
}
return result;
}
#remove! ⇒ Node
Removes this node and its children from the document tree by setting its document, parent and siblings to nil. You can add the returned node back into a document. Otherwise, the node will be freed once any references to it go out of scope.
# File 'ext/libxml/ruby_xml_node.c', line 1141
static VALUE rxml_node_remove_ex(VALUE self)
{
xmlNodePtr xnode = rxml_get_xnode(self);
// Now unlink the node from its parent
xmlUnlinkNode(xnode);
// Ruby now manages this node
rxml_node_manage(xnode, self);
// Now return the removed node so the user can do something with it
return self;
}
#to_s ⇒ "string"
#to_s(:indent) ⇒ true, :encoding
string"
#to_s(:indent) ⇒ true, :encoding
Converts a node, and all of its children, to a string representation. To include only the node’s children, use the the #inner_xml method.
You may provide an optional hash table to control how the string is generated. Valid options are:
:indent - Specifies if the string should be indented. The default value is true. Note that indentation is only added if both :indent is true and LibXML::XML.indent_tree_output is true. If :indent is set to false, then both indentation and line feeds are removed from the result.
:level - Specifies the indentation level. The amount of indentation is equal to the (level * number_spaces) + number_spaces, where libxml defaults the number of spaces to 2. Thus a level of 0 results in 2 spaces, level 1 results in 4 spaces, level 2 results in 6 spaces, etc.
:encoding - Specifies the output encoding of the string. It defaults to XML::Encoding::UTF8. To change it, use one of the Encoding encoding constants.
# File 'ext/libxml/ruby_xml_node.c', line 604
static VALUE rxml_node_to_s(int argc, VALUE *argv, VALUE self)
{
VALUE result = Qnil;
VALUE options = Qnil;
xmlNodePtr xnode;
xmlCharEncodingHandlerPtr encodingHandler;
xmlOutputBufferPtr output;
int level = 0;
int indent = 1;
const xmlChar *xencoding = (const xmlChar*)"UTF-8";
rb_scan_args(argc, argv, "01", &options);
if (!NIL_P(options))
{
VALUE rencoding, rindent, rlevel;
Check_Type(options, T_HASH);
rencoding = rb_hash_aref(options, ID2SYM(rb_intern("encoding")));
rindent = rb_hash_aref(options, ID2SYM(rb_intern("indent")));
rlevel = rb_hash_aref(options, ID2SYM(rb_intern("level")));
if (rindent == Qfalse)
indent = 0;
if (rlevel != Qnil)
level = NUM2INT(rlevel);
if (rencoding != Qnil)
{
xencoding = (const xmlChar*)xmlGetCharEncodingName((xmlCharEncoding)NUM2INT(rencoding));
if (!xencoding)
rb_raise(rb_eArgError, "Unknown encoding value: %d", NUM2INT(rencoding));
}
}
encodingHandler = xmlFindCharEncodingHandler((const char*)xencoding);
output = xmlAllocOutputBuffer(encodingHandler);
xnode = rxml_get_xnode(self);
xmlNodeDumpOutput(output, xnode->doc, xnode, level, indent, (const char*)xencoding);
xmlOutputBufferFlush(output);
#ifdef LIBXML2_NEW_BUFFER
if (output->conv)
result = rxml_new_cstr(xmlBufContent(output->conv), xencoding);
else
result = rxml_new_cstr(xmlBufContent(output->buffer), xencoding);
#else
if (output->conv)
result = rxml_new_cstr(xmlBufferContent(output->conv), xencoding);
else
result = rxml_new_cstr(xmlBufferContent(output->buffer), xencoding);
#endif
xmlOutputBufferClose(output);
return result;
}
#xlink_type ⇒ Numeric
Obtain the type identifier for this xlink, if applicable. If this is not an xlink node (see #xlink?), will return nil.
# File 'ext/libxml/ruby_xml_node.c', line 850
static VALUE rxml_node_xlink_type(VALUE self)
{
xmlNodePtr xnode;
xlinkType xlt;
xnode = rxml_get_xnode(self);
xlt = xlinkIsLink(xnode->doc, xnode);
if (xlt == XLINK_TYPE_NONE)
return (Qnil);
else
return (INT2NUM(xlt));
}
#xlink_type_name ⇒ "string"
Obtain the type name for this xlink, if applicable. If this is not an xlink node (see #xlink?), will return nil.
# File 'ext/libxml/ruby_xml_node.c', line 872
static VALUE rxml_node_xlink_type_name(VALUE self)
{
xmlNodePtr xnode;
xlinkType xlt;
xnode = rxml_get_xnode(self);
xlt = xlinkIsLink(xnode->doc, xnode);
switch (xlt)
{
case XLINK_TYPE_NONE:
return (Qnil);
case XLINK_TYPE_SIMPLE:
return (rxml_new_cstr((const xmlChar*)"simple", NULL));
case XLINK_TYPE_EXTENDED:
return (rxml_new_cstr((const xmlChar*)"extended", NULL));
case XLINK_TYPE_EXTENDED_SET:
return (rxml_new_cstr((const xmlChar*)"extended_set", NULL));
default:
rb_fatal("Unknowng xlink type, %d", xlt);
}
}