Class | LibXML::XML::Dtd |
In: |
ext/libxml/libxml.c
|
Parent: | Object |
SV * parse_string(CLASS, str, …)
char * CLASS char * str PREINIT: STRLEN n_a; xmlDtdPtr res; SV * encoding_sv; xmlParserInputBufferPtr buffer; xmlCharEncoding enc = XML_CHAR_ENCODING_NONE; xmlChar * new_string; STRLEN len; CODE: LibXML_init_error(); if (items > 2) { encoding_sv = ST(2); if (items > 3) { croak("parse_string: too many parameters"); } // warn("getting encoding...\n"); enc = xmlParseCharEncoding(SvPV(encoding_sv, n_a)); if (enc == XML_CHAR_ENCODING_ERROR) { croak("Parse of encoding %s failed: %s", SvPV(encoding_sv, n_a), SvPV(LibXML_error, n_a)); } } buffer = xmlAllocParserInputBuffer(enc); // buffer = xmlParserInputBufferCreateMem(str, xmlStrlen(str), enc); if ( !buffer) croak("cant create buffer!\n" ); new_string = xmlStrdup((const xmlChar*)str); xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string); res = xmlIOParseDTD(NULL, buffer, enc); // NOTE: For some reason freeing this InputBuffer causes a segfault! // xmlFreeParserInputBuffer(buffer); xmlFree(new_string); sv_2mortal( LibXML_error ); LibXML_croak_error(); if (res == NULL) { croak("no DTD parsed!"); } RETVAL = PmmNodeToSv((xmlNodePtr)res, NULL); OUTPUT: RETVAL
Create a new Dtd from the specified public and system identifiers.
/* * call-seq: * XML::Dtd.new("public system") -> dtd * XML::Dtd.new("public", "system") -> dtd * * Create a new Dtd from the specified public and system * identifiers. */ VALUE ruby_xml_dtd_initialize(int argc, VALUE *argv, VALUE class) {