/*
* call-seq:
* attribute_nodes
*
* Get a list of attributes for this Node
*/
static VALUE attribute_nodes(VALUE self)
{
xmlTextReaderPtr reader;
VALUE attr ;
Data_Get_Struct(self, xmlTextReader, reader);
attr = rb_ary_new() ;
if (! has_attributes(reader))
return attr ;
xmlNodePtr ptr = xmlTextReaderExpand(reader);
if(ptr == NULL) return Qnil;
// FIXME I'm not sure if this is correct..... I don't really like pointing
// at this document, but I have to because of the assertions in
// the node wrapping code.
if(! DOC_RUBY_OBJECT_TEST(ptr->doc)) {
VALUE rb_doc = Nokogiri_wrap_xml_document(cNokogiriXmlDocument, ptr->doc);
RDATA(rb_doc)->dfree = NULL;
}
VALUE enc = rb_iv_get(self, "@encoding");
if(enc != Qnil && NULL == ptr->doc->encoding) {
ptr->doc->encoding = calloc((size_t)RSTRING_LEN(enc), sizeof(char));
strncpy(
(char *)ptr->doc->encoding,
StringValuePtr(enc),
(size_t)RSTRING_LEN(enc)
);
}
Nokogiri_xml_node_properties(ptr, attr);
return attr ;
}