| 1 |
|
| /* $Id$ |
| 2 |
|
| * |
| 3 |
|
| * This is free software, you may use it and distribute it under the same terms as |
| 4 |
|
| * Perl itself. |
| 5 |
|
| * |
| 6 |
|
| * Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas |
| 7 |
|
| */ |
| 8 |
|
| |
| 9 |
|
| #ifdef __cplusplus |
| 10 |
|
| extern "C" { |
| 11 |
|
| #endif |
| 12 |
|
| |
| 13 |
|
| #if defined(_MSC_VER) |
| 14 |
|
| #define _CRT_SECURE_NO_DEPRECATE 1 |
| 15 |
|
| #define _CRT_NONSTDC_NO_DEPRECATE 1 |
| 16 |
|
| #endif |
| 17 |
|
| |
| 18 |
|
| /* perl stuff */ |
| 19 |
|
| #include "EXTERN.h" |
| 20 |
|
| #include "perl.h" |
| 21 |
|
| #include "XSUB.h" |
| 22 |
|
| #define NEED_newRV_noinc_GLOBAL |
| 23 |
|
| #define NEED_sv_2pv_flags |
| 24 |
|
| #include "ppport.h" |
| 25 |
|
| #include "Av_CharPtrPtr.h" /* XS_*_charPtrPtr() */ |
| 26 |
|
| |
| 27 |
|
| #include <fcntl.h> |
| 28 |
|
| #include <limits.h> /* INT_MAX */ |
| 29 |
|
| |
| 30 |
|
| #ifndef WIN32 |
| 31 |
|
| #include <unistd.h> |
| 32 |
|
| #endif |
| 33 |
|
| |
| 34 |
|
| /* libxml2 configuration properties */ |
| 35 |
|
| #include <libxml/xmlversion.h> |
| 36 |
|
| |
| 37 |
|
| #define DEBUG_C14N |
| 38 |
|
| |
| 39 |
|
| /* libxml2 stuff */ |
| 40 |
|
| #include <libxml/xmlversion.h> |
| 41 |
|
| #include <libxml/globals.h> |
| 42 |
|
| #include <libxml/xmlmemory.h> |
| 43 |
|
| #include <libxml/parser.h> |
| 44 |
|
| #include <libxml/parserInternals.h> |
| 45 |
|
| #include <libxml/HTMLparser.h> |
| 46 |
|
| #include <libxml/HTMLtree.h> |
| 47 |
|
| #include <libxml/c14n.h> |
| 48 |
|
| #include <libxml/tree.h> |
| 49 |
|
| #include <libxml/xpath.h> |
| 50 |
|
| #include <libxml/xpathInternals.h> |
| 51 |
|
| #include <libxml/xmlIO.h> |
| 52 |
|
| /* #include <libxml/debugXML.h> */ |
| 53 |
|
| #include <libxml/xmlerror.h> |
| 54 |
|
| #include <libxml/xinclude.h> |
| 55 |
|
| #include <libxml/valid.h> |
| 56 |
|
| |
| 57 |
|
| #ifdef LIBXML_PATTERN_ENABLED |
| 58 |
|
| #include <libxml/pattern.h> |
| 59 |
|
| #endif |
| 60 |
|
| |
| 61 |
|
| #ifdef LIBXML_REGEXP_ENABLED |
| 62 |
|
| #include <libxml/xmlregexp.h> |
| 63 |
|
| #endif |
| 64 |
|
| |
| 65 |
|
| #if LIBXML_VERSION >= 20510 |
| 66 |
|
| #define HAVE_SCHEMAS |
| 67 |
|
| #include <libxml/relaxng.h> |
| 68 |
|
| #include <libxml/xmlschemas.h> |
| 69 |
|
| #endif |
| 70 |
|
| |
| 71 |
|
| #if LIBXML_VERSION >= 20621 |
| 72 |
|
| #define WITH_SERRORS |
| 73 |
|
| #ifdef LIBXML_READER_ENABLED |
| 74 |
|
| #define HAVE_READER_SUPPORT |
| 75 |
|
| #include <libxml/xmlreader.h> |
| 76 |
|
| #endif |
| 77 |
|
| #endif |
| 78 |
|
| |
| 79 |
|
| #ifdef LIBXML_CATALOG_ENABLED |
| 80 |
|
| #include <libxml/catalog.h> |
| 81 |
|
| #endif |
| 82 |
|
| |
| 83 |
|
| #ifdef HAVE_READER_SUPPORT |
| 84 |
|
| |
| 85 |
|
| typedef enum { |
| 86 |
|
| XML_TEXTREADER_NONE = -1, |
| 87 |
|
| XML_TEXTREADER_START= 0, |
| 88 |
|
| XML_TEXTREADER_ELEMENT= 1, |
| 89 |
|
| XML_TEXTREADER_END= 2, |
| 90 |
|
| XML_TEXTREADER_EMPTY= 3, |
| 91 |
|
| XML_TEXTREADER_BACKTRACK= 4, |
| 92 |
|
| XML_TEXTREADER_DONE= 5, |
| 93 |
|
| XML_TEXTREADER_ERROR= 6 |
| 94 |
|
| } xmlTextReaderState; |
| 95 |
|
| |
| 96 |
|
| typedef enum { |
| 97 |
|
| XML_TEXTREADER_NOT_VALIDATE = 0, |
| 98 |
|
| XML_TEXTREADER_VALIDATE_DTD = 1, |
| 99 |
|
| XML_TEXTREADER_VALIDATE_RNG = 2, |
| 100 |
|
| XML_TEXTREADER_VALIDATE_XSD = 4 |
| 101 |
|
| } xmlTextReaderValidate; |
| 102 |
|
| |
| 103 |
|
| #endif /* HAVE_READER_SUPPORT */ |
| 104 |
|
| |
| 105 |
|
| /* GDOME support |
| 106 |
|
| * libgdome installs only the core functions to the system. |
| 107 |
|
| * this is not enough for XML::LibXML <-> XML::GDOME conversion. |
| 108 |
|
| * therefore there is the need to ship as well the GDOME core headers. |
| 109 |
|
| */ |
| 110 |
|
| #ifdef XML_LIBXML_GDOME_SUPPORT |
| 111 |
|
| |
| 112 |
|
| #include <libgdome/gdome.h> |
| 113 |
|
| #include <libgdome/gdome-libxml-util.h> |
| 114 |
|
| |
| 115 |
|
| #endif |
| 116 |
|
| |
| 117 |
|
| |
| 118 |
|
| #if LIBXML_VERSION < 20621 |
| 119 |
|
| /* HTML_PARSE_RECOVER was added in libxml2 2.6.21 */ |
| 120 |
|
| # define HTML_PARSE_RECOVER XML_PARSE_RECOVER |
| 121 |
|
| #endif |
| 122 |
|
| |
| 123 |
|
| |
| 124 |
|
| /* XML::LibXML stuff */ |
| 125 |
|
| #include "perl-libxml-mm.h" |
| 126 |
|
| #include "perl-libxml-sax.h" |
| 127 |
|
| |
| 128 |
|
| #include "dom.h" |
| 129 |
|
| #include "xpath.h" |
| 130 |
|
| #include "xpathcontext.h" |
| 131 |
|
| |
| 132 |
|
| #ifdef __cplusplus |
| 133 |
|
| } |
| 134 |
|
| #endif |
| 135 |
|
| |
| 136 |
|
| |
| 137 |
|
| #define TEST_PERL_FLAG(flag) \ |
| 138 |
|
| SvTRUE(get_sv(flag, FALSE)) ? 1 : 0 |
| 139 |
|
| |
| 140 |
|
| #ifdef HAVE_READER_SUPPORT |
| 141 |
|
| #define LIBXML_READER_TEST_ELEMENT(reader,name,nsURI) \ |
| 142 |
|
| (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) && \ |
| 143 |
|
| ((!nsURI && !name) \ |
| 144 |
|
| || \ |
| 145 |
|
| (!nsURI && xmlStrcmp((const xmlChar*)name, xmlTextReaderConstName(reader) ) == 0 ) \ |
| 146 |
|
| || \ |
| 147 |
|
| (nsURI && xmlStrcmp((const xmlChar*)nsURI, xmlTextReaderConstNamespaceUri(reader))==0 \ |
| 148 |
|
| && \ |
| 149 |
|
| (!name || xmlStrcmp((const xmlChar*)name, xmlTextReaderConstLocalName(reader)) == 0))) |
| 150 |
|
| #endif |
| 151 |
|
| |
| 152 |
|
| /* this should keep the default */ |
| 153 |
|
| static xmlExternalEntityLoader LibXML_old_ext_ent_loader = NULL; |
| 154 |
|
| static xmlExternalEntityLoader LibXML_old_ext_ent_loader_global = NULL; |
| 155 |
|
| |
| 156 |
|
| /* global external entity loader */ |
| 157 |
|
| SV *EXTERNAL_ENTITY_LOADER_FUNC = (SV *)NULL; |
| 158 |
|
| |
| 159 |
|
| SV* PROXY_NODE_REGISTRY_MUTEX = NULL; |
| 160 |
|
| |
| 161 |
|
| /* **************************************************************** |
| 162 |
|
| * Error handler |
| 163 |
|
| * **************************************************************** */ |
| 164 |
|
| |
| 165 |
|
| #ifdef WITH_SERRORS |
| 166 |
|
| |
| 167 |
|
| #define INIT_READER_ERROR_HANDLER(reader) |
| 168 |
|
| |
| 169 |
|
| #define PREINIT_SAVED_ERROR SV* saved_error = sv_2mortal(newSV(0)); |
| 170 |
|
| |
| 171 |
|
| #define INIT_ERROR_HANDLER \ |
| 172 |
|
| xmlSetGenericErrorFunc((void *)saved_error, \ |
| 173 |
|
| (xmlGenericErrorFunc) LibXML_flat_handler); \ |
| 174 |
|
| xmlSetStructuredErrorFunc((void *)saved_error, \ |
| 175 |
|
| (xmlStructuredErrorFunc)LibXML_struct_error_handler) |
| 176 |
|
| |
| 177 |
|
| #define REPORT_ERROR(recover) LibXML_report_error_ctx(saved_error, recover) |
| 178 |
|
| |
| 179 |
|
| #define CLEANUP_ERROR_HANDLER xmlSetGenericErrorFunc(NULL,NULL); \ |
| 180 |
|
| xmlSetStructuredErrorFunc(NULL,NULL) |
| 181 |
|
| |
| 182 |
|
| #else /* WITH_SERRORS */ |
| 183 |
|
| |
| 184 |
|
| #define INIT_READER_ERROR_HANDLER(reader) \ |
| 185 |
|
| if (reader) \ |
| 186 |
|
| xmlTextReaderSetErrorHandler(reader, LibXML_reader_error_handler, \ |
| 187 |
|
| sv_2mortal(newSVpv("",0))); |
| 188 |
|
| |
| 189 |
|
| #define PREINIT_SAVED_ERROR SV* saved_error = sv_2mortal(newSVpv("",0)); |
| 190 |
|
| |
| 191 |
|
| #define INIT_ERROR_HANDLER \ |
| 192 |
|
| xmlSetGenericErrorFunc((void *) saved_error, \ |
| 193 |
|
| (xmlGenericErrorFunc) LibXML_error_handler_ctx) |
| 194 |
|
| |
| 195 |
|
| #define REPORT_ERROR(recover) LibXML_report_error_ctx(saved_error, recover) |
| 196 |
|
| |
| 197 |
|
| #define CLEANUP_ERROR_HANDLER xmlSetGenericErrorFunc(NULL,NULL); |
| 198 |
|
| |
| 199 |
|
| |
| 200 |
|
| #endif /* WITH_SERRORS */ |
| 201 |
|
| |
| 202 |
|
| #ifdef WITH_SERRORS |
| 203 |
|
| void |
| 204 |
265 |
| LibXML_struct_error_callback(SV * saved_error, SV * libErr ) |
| 205 |
|
| { |
| 206 |
|
| |
| 207 |
|
| dTHX; |
| 208 |
265 |
| dSP; |
| 209 |
|
| |
| 210 |
265 |
▶ | if ( saved_error == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( saved_error == NULL ) { |
0 |
265 |
265 |
|
| 211 |
0 |
| warn( "have no save_error\n" ); |
| 212 |
|
| } |
| 213 |
|
| |
| 214 |
265 |
| ENTER; |
| 215 |
265 |
| SAVETMPS; |
| 216 |
265 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
265 |
265 |
|
| 217 |
|
| |
| 218 |
265 |
▶ | XPUSHs(sv_2mortal(libErr)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(libErr)); |
0 |
265 |
265 |
|
| 219 |
265 |
▶ | if ( saved_error != NULL && SvOK(saved_error) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( saved_error != NULL && SvOK(saved_error) ) { |
265 |
0 |
265 |
| if ( saved_error != NULL && SvOK(saved_error) ) { |
93 |
172 |
265 |
|
| 220 |
93 |
▶ | XPUSHs(saved_error); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(saved_error); |
0 |
93 |
93 |
|
| 221 |
|
| } |
| 222 |
265 |
| PUTBACK; |
| 223 |
|
| |
| 224 |
265 |
▶ | if ( saved_error != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( saved_error != NULL ) { |
265 |
0 |
265 |
|
| 225 |
265 |
| call_pv( "XML::LibXML::Error::_callback_error", G_SCALAR | G_EVAL ); |
| 226 |
|
| } else { |
| 227 |
0 |
| call_pv( "XML::LibXML::Error::_instant_error_callback", G_SCALAR ); |
| 228 |
|
| } |
| 229 |
265 |
| SPAGAIN; |
| 230 |
|
| |
| 231 |
265 |
▶ | if ( SvTRUE(ERRSV) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( SvTRUE(ERRSV) ) { |
265 |
0 |
265 |
| if ( SvTRUE(ERRSV) ) { |
0 |
265 |
265 |
|
| 232 |
0 |
| (void) POPs; |
| 233 |
0 |
| croak_obj; |
| 234 |
|
| } else { |
| 235 |
265 |
| sv_setsv(saved_error, POPs); |
| 236 |
|
| } |
| 237 |
|
| |
| 238 |
265 |
| PUTBACK; |
| 239 |
265 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
265 |
0 |
265 |
|
| 240 |
265 |
| LEAVE; |
| 241 |
265 |
| } |
| 242 |
|
| |
| 243 |
|
| void |
| 244 |
265 |
| LibXML_struct_error_handler(SV * saved_error, xmlErrorPtr error ) |
| 245 |
|
| { |
| 246 |
265 |
| const char * CLASS = "XML::LibXML::LibError"; |
| 247 |
|
| SV* libErr; |
| 248 |
|
| |
| 249 |
265 |
| libErr = NEWSV(0,0); |
| 250 |
265 |
| sv_setref_pv( libErr, CLASS, (void*)error ); |
| 251 |
265 |
| LibXML_struct_error_callback( saved_error, libErr); |
| 252 |
265 |
| } |
| 253 |
|
| |
| 254 |
|
| |
| 255 |
|
| void |
| 256 |
0 |
| LibXML_flat_handler(SV * saved_error, const char * msg, ...) |
| 257 |
|
| { |
| 258 |
|
| SV* sv; |
| 259 |
|
| va_list args; |
| 260 |
|
| |
| 261 |
0 |
| sv = newSVpv("",0); |
| 262 |
0 |
| va_start(args, msg); |
| 263 |
0 |
| sv_vcatpvf(sv, msg, &args); |
| 264 |
0 |
| va_end(args); |
| 265 |
|
| xs_warn("flat error\n"); |
| 266 |
0 |
| LibXML_struct_error_callback( saved_error, sv); |
| 267 |
0 |
| } |
| 268 |
|
| |
| 269 |
|
| #endif /* WITH_SERRORS */ |
| 270 |
|
| |
| 271 |
|
| |
| 272 |
|
| /* If threads-support is working correctly in libxml2 then |
| 273 |
|
| * this method will be called with the correct thread-context */ |
| 274 |
|
| void |
| 275 |
0 |
| LibXML_error_handler_ctx(void * ctxt, const char * msg, ...) |
| 276 |
|
| { |
| 277 |
|
| va_list args; |
| 278 |
0 |
| SV * saved_error = (SV *) ctxt; |
| 279 |
|
| |
| 280 |
|
| /* If saved_error is null we croak with the error */ |
| 281 |
0 |
▶ | if( NULL == saved_error ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( NULL == saved_error ) { |
0 |
0 |
0 |
|
| 282 |
0 |
| SV * sv = sv_2mortal(newSV(0)); |
| 283 |
0 |
| va_start(args, msg); |
| 284 |
|
| /* vfprintf(stderr, msg, args); */ |
| 285 |
0 |
| sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL); |
| 286 |
0 |
| va_end(args); |
| 287 |
0 |
| croak("%s", SvPV_nolen(sv)); |
| 288 |
|
| /* Otherwise, save the error */ |
| 289 |
|
| } else { |
| 290 |
0 |
| va_start(args, msg); |
| 291 |
|
| /* vfprintf(stderr, msg, args); */ |
| 292 |
0 |
| sv_vcatpvfn(saved_error, msg, strlen(msg), &args, NULL, 0, NULL); |
| 293 |
0 |
| va_end(args); |
| 294 |
|
| } |
| 295 |
0 |
| } |
| 296 |
|
| |
| 297 |
|
| static void |
| 298 |
0 |
| LibXML_validity_error_ctx(void * ctxt, const char *msg, ...) |
| 299 |
|
| { |
| 300 |
|
| va_list args; |
| 301 |
0 |
| SV * saved_error = (SV *) ctxt; |
| 302 |
|
| |
| 303 |
|
| /* If saved_error is null we croak with the error */ |
| 304 |
0 |
▶ | if( NULL == saved_error ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( NULL == saved_error ) { |
0 |
0 |
0 |
|
| 305 |
0 |
| SV * sv = sv_2mortal(newSV(0)); |
| 306 |
0 |
| va_start(args, msg); |
| 307 |
0 |
| sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL); |
| 308 |
0 |
| va_end(args); |
| 309 |
0 |
| croak("%s", SvPV_nolen(sv)); |
| 310 |
|
| /* Otherwise, save the error */ |
| 311 |
|
| } else { |
| 312 |
0 |
| va_start(args, msg); |
| 313 |
0 |
| sv_vcatpvfn(saved_error, msg, strlen(msg), &args, NULL, 0, NULL); |
| 314 |
0 |
| va_end(args); |
| 315 |
|
| } |
| 316 |
0 |
| } |
| 317 |
|
| |
| 318 |
|
| static void |
| 319 |
0 |
| LibXML_validity_warning_ctx(void * ctxt, const char *msg, ...) |
| 320 |
|
| { |
| 321 |
|
| va_list args; |
| 322 |
0 |
| SV * saved_error = (SV *) ctxt; |
| 323 |
|
| STRLEN len; |
| 324 |
|
| |
| 325 |
|
| /* If saved_error is null we croak with the error */ |
| 326 |
0 |
▶ | if( NULL == saved_error ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( NULL == saved_error ) { |
0 |
0 |
0 |
|
| 327 |
0 |
| SV * sv = sv_2mortal(newSV(0)); |
| 328 |
0 |
| va_start(args, msg); |
| 329 |
0 |
| sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL); |
| 330 |
0 |
| va_end(args); |
| 331 |
0 |
| croak("LibXML_validity_warning_ctx internal error: context was null (%s)", SvPV_nolen(sv)); |
| 332 |
|
| /* Otherwise, give the warning */ |
| 333 |
|
| } else { |
| 334 |
0 |
| va_start(args, msg); |
| 335 |
0 |
| sv_vcatpvfn(saved_error, msg, strlen(msg), &args, NULL, 0, NULL); |
| 336 |
0 |
| va_end(args); |
| 337 |
0 |
| warn("validation error: %s", SvPV(saved_error, len)); |
| 338 |
|
| } |
| 339 |
0 |
| } |
| 340 |
|
| |
| 341 |
|
| static int |
| 342 |
434 |
| LibXML_will_die_ctx(SV * saved_error, int recover) |
| 343 |
|
| { |
| 344 |
|
| #ifdef WITH_SERRORS |
| 345 |
434 |
▶ | if( saved_error!=NULL && SvOK(saved_error) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if( saved_error!=NULL && SvOK(saved_error) ) { |
434 |
0 |
434 |
| if( saved_error!=NULL && SvOK(saved_error) ) { |
95 |
339 |
434 |
|
| 346 |
95 |
▶ | if ( recover == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( recover == 0 ) { |
95 |
0 |
95 |
|
| 347 |
95 |
| return 1; |
| 348 |
|
| } |
| 349 |
|
| } |
| 350 |
|
| #else |
| 351 |
|
| if( 0 < SvCUR( saved_error ) ) { |
| 352 |
|
| if ( recover == 0 ) { |
| 353 |
|
| return 1; |
| 354 |
|
| } |
| 355 |
|
| } |
| 356 |
|
| #endif |
| 357 |
339 |
| return 0; |
| 358 |
|
| } |
| 359 |
|
| |
| 360 |
|
| |
| 361 |
|
| static void |
| 362 |
1899 |
| LibXML_report_error_ctx(SV * saved_error, int recover) |
| 363 |
|
| { |
| 364 |
|
| #ifdef WITH_SERRORS |
| 365 |
1899 |
▶ | if( saved_error!=NULL && SvOK( saved_error ) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if( saved_error!=NULL && SvOK( saved_error ) ) { |
1899 |
0 |
1899 |
| if( saved_error!=NULL && SvOK( saved_error ) ) { |
168 |
1731 |
1899 |
|
| 366 |
168 |
▶ | if (!recover || recover==1) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!recover || recover==1) { |
2 |
166 |
168 |
| if (!recover || recover==1) { |
1 |
1 |
2 |
|
| 367 |
|
| dTHX; |
| 368 |
167 |
| dSP; |
| 369 |
|
| |
| 370 |
167 |
| ENTER; |
| 371 |
167 |
| SAVETMPS; |
| 372 |
167 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
167 |
167 |
|
| 373 |
167 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
167 |
167 |
|
| 374 |
167 |
| PUSHs(saved_error); |
| 375 |
167 |
| PUTBACK; |
| 376 |
167 |
▶ | if (recover==1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (recover==1) { |
1 |
166 |
167 |
|
| 377 |
1 |
| call_pv( "XML::LibXML::Error::_report_warning", G_SCALAR | G_DISCARD); |
| 378 |
|
| } else { |
| 379 |
166 |
| call_pv( "XML::LibXML::Error::_report_error", G_SCALAR | G_DISCARD); |
| 380 |
|
| } |
| 381 |
1 |
| SPAGAIN; |
| 382 |
|
| |
| 383 |
1 |
| PUTBACK; |
| 384 |
1 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
1 |
1 |
|
| 385 |
1 |
| LEAVE; |
| 386 |
|
| } |
| 387 |
|
| } |
| 388 |
|
| #else |
| 389 |
|
| if( 0 < SvCUR( saved_error ) ) { |
| 390 |
|
| if( recover ) { |
| 391 |
|
| if ( recover == 1 ) { |
| 392 |
|
| warn("%s", SvPV_nolen(saved_error)); |
| 393 |
|
| } /* else recover silently */ |
| 394 |
|
| } else { |
| 395 |
|
| croak("%s", SvPV_nolen(saved_error)); |
| 396 |
|
| } |
| 397 |
|
| } |
| 398 |
|
| #endif |
| 399 |
1733 |
| } |
| 400 |
|
| |
| 401 |
|
| #ifdef HAVE_READER_SUPPORT |
| 402 |
|
| |
| 403 |
|
| #ifndef WITH_SERRORS |
| 404 |
|
| static void |
| 405 |
|
| LibXML_reader_error_handler(void * ctxt, |
| 406 |
|
| const char * msg, |
| 407 |
|
| xmlParserSeverities severity, |
| 408 |
|
| xmlTextReaderLocatorPtr locator) |
| 409 |
|
| { |
| 410 |
|
| int line = xmlTextReaderLocatorLineNumber(locator); |
| 411 |
|
| xmlChar * filename = xmlTextReaderLocatorBaseURI(locator); |
| 412 |
|
| SV * msg_sv = sv_2mortal(C2Sv((xmlChar*) msg,NULL)); |
| 413 |
|
| SV * error = sv_2mortal(newSVpv("", 0)); |
| 414 |
|
| |
| 415 |
|
| switch (severity) { |
| 416 |
|
| case XML_PARSER_SEVERITY_VALIDITY_WARNING: |
| 417 |
|
| sv_catpv(error, "Validity WARNING"); |
| 418 |
|
| break; |
| 419 |
|
| case XML_PARSER_SEVERITY_WARNING: |
| 420 |
|
| sv_catpv(error, "Reader WARNING"); |
| 421 |
|
| break; |
| 422 |
|
| case XML_PARSER_SEVERITY_VALIDITY_ERROR: |
| 423 |
|
| sv_catpv(error, "Validity ERROR"); |
| 424 |
|
| break; |
| 425 |
|
| case XML_PARSER_SEVERITY_ERROR: |
| 426 |
|
| sv_catpv(error, "Reader ERROR"); |
| 427 |
|
| break; |
| 428 |
|
| } |
| 429 |
|
| if (filename) { |
| 430 |
|
| sv_catpvf(error, " in %s", filename); |
| 431 |
|
| xmlFree(filename); |
| 432 |
|
| } |
| 433 |
|
| if (line >= 0) { |
| 434 |
|
| sv_catpvf(error, " at line %d", line); |
| 435 |
|
| } |
| 436 |
|
| sv_catpvf(error, ": %s", SvPV_nolen(msg_sv)); |
| 437 |
|
| if (severity == XML_PARSER_SEVERITY_VALIDITY_WARNING || |
| 438 |
|
| severity == XML_PARSER_SEVERITY_WARNING ) { |
| 439 |
|
| warn("%s", SvPV_nolen(error)); |
| 440 |
|
| } else { |
| 441 |
|
| SV * error_sv = (SV*) ctxt; |
| 442 |
|
| if (error_sv) { |
| 443 |
|
| sv_catpvf(error_sv, "%s ", SvPV_nolen(error)); |
| 444 |
|
| } else { |
| 445 |
|
| croak("%s",SvPV_nolen(error)); |
| 446 |
|
| } |
| 447 |
|
| } |
| 448 |
|
| } |
| 449 |
|
| #endif /* !defined WITH_SERRORS */ |
| 450 |
|
| |
| 451 |
|
| SV * |
| 452 |
0 |
| LibXML_get_reader_error_data(xmlTextReaderPtr reader) |
| 453 |
|
| { |
| 454 |
0 |
| SV * saved_error = NULL; |
| 455 |
0 |
| xmlTextReaderErrorFunc f = NULL; |
| 456 |
0 |
| xmlTextReaderGetErrorHandler(reader, &f, (void **) &saved_error); |
| 457 |
0 |
| return saved_error; |
| 458 |
|
| } |
| 459 |
|
| |
| 460 |
|
| #ifndef WITH_SERRORS |
| 461 |
|
| static void |
| 462 |
|
| LibXML_report_reader_error(xmlTextReaderPtr reader) |
| 463 |
|
| { |
| 464 |
|
| SV * saved_error = NULL; |
| 465 |
|
| xmlTextReaderErrorFunc f = NULL; |
| 466 |
|
| xmlTextReaderGetErrorHandler(reader, &f, (void **) &saved_error); |
| 467 |
|
| if ( saved_error && SvOK( saved_error) && 0 < SvCUR( saved_error ) ) { |
| 468 |
|
| croak("%s", SvPV_nolen(saved_error)); |
| 469 |
|
| } |
| 470 |
|
| } |
| 471 |
|
| #endif /* !defined WITH_SERRORS */ |
| 472 |
|
| |
| 473 |
|
| #endif /* HAVE_READER_SUPPORT */ |
| 474 |
|
| |
| 475 |
|
| static int |
| 476 |
941 |
| LibXML_get_recover(HV * real_obj) |
| 477 |
|
| { |
| 478 |
941 |
| SV** item = hv_fetch( real_obj, "XML_LIBXML_RECOVER", 18, 0 ); |
| 479 |
941 |
▶ | return ( item != NULL && SvTRUE(*item) ) ? SvIV(*item) : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| return ( item != NULL && SvTRUE(*item) ) ? SvIV(*item) : 0; |
105 |
836 |
941 |
| return ( item != NULL && SvTRUE(*item) ) ? SvIV(*item) : 0; |
1 |
104 |
105 |
|
| 480 |
|
| } |
| 481 |
|
| |
| 482 |
|
| static SV * |
| 483 |
437 |
| LibXML_NodeToSv(HV * real_obj, xmlNodePtr real_doc) |
| 484 |
|
| { |
| 485 |
437 |
| SV** item = hv_fetch( real_obj, "XML_LIBXML_GDOME", 16, 0 ); |
| 486 |
|
| |
| 487 |
437 |
▶ | if ( item != NULL && SvTRUE(*item) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( item != NULL && SvTRUE(*item) ) { |
53 |
384 |
437 |
| if ( item != NULL && SvTRUE(*item) ) { |
0 |
53 |
53 |
|
| 488 |
0 |
| return PmmNodeToGdomeSv(real_doc); |
| 489 |
|
| } |
| 490 |
|
| else { |
| 491 |
437 |
| return PmmNodeToSv(real_doc, NULL); |
| 492 |
|
| } |
| 493 |
|
| } |
| 494 |
|
| |
| 495 |
|
| /* **************************************************************** |
| 496 |
|
| * IO callbacks |
| 497 |
|
| * **************************************************************** */ |
| 498 |
|
| |
| 499 |
|
| int |
| 500 |
34 |
| LibXML_read_perl (SV * ioref, char * buffer, int len) |
| 501 |
|
| { |
| 502 |
|
| dTHX; |
| 503 |
34 |
| dSP; |
| 504 |
|
| |
| 505 |
|
| int cnt; |
| 506 |
|
| SV * read_results; |
| 507 |
|
| IV read_results_iv; |
| 508 |
|
| STRLEN read_length; |
| 509 |
|
| char * chars; |
| 510 |
34 |
| SV * tbuff = NEWSV(0,len); |
| 511 |
34 |
| SV * tsize = newSViv(len); |
| 512 |
|
| |
| 513 |
34 |
| ENTER; |
| 514 |
34 |
| SAVETMPS; |
| 515 |
|
| |
| 516 |
34 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
34 |
34 |
|
| 517 |
34 |
▶ | EXTEND(SP, 3); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 3); |
0 |
34 |
34 |
|
| 518 |
34 |
| PUSHs(ioref); |
| 519 |
34 |
| PUSHs(sv_2mortal(tbuff)); |
| 520 |
34 |
| PUSHs(sv_2mortal(tsize)); |
| 521 |
34 |
| PUTBACK; |
| 522 |
|
| |
| 523 |
34 |
▶ | if (sv_isobject(ioref)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_isobject(ioref)) { |
11 |
23 |
34 |
|
| 524 |
11 |
| cnt = call_method("read", G_SCALAR | G_EVAL); |
| 525 |
|
| } |
| 526 |
|
| else { |
| 527 |
23 |
| cnt = call_pv("XML::LibXML::__read", G_SCALAR | G_EVAL); |
| 528 |
|
| } |
| 529 |
|
| |
| 530 |
34 |
| SPAGAIN; |
| 531 |
|
| |
| 532 |
34 |
▶ | if (cnt != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cnt != 1) { |
0 |
34 |
34 |
|
| 533 |
0 |
| croak("read method call failed"); |
| 534 |
|
| } |
| 535 |
|
| |
| 536 |
34 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
34 |
0 |
34 |
| if (SvTRUE(ERRSV)) { |
1 |
33 |
34 |
|
| 537 |
1 |
| (void) POPs; |
| 538 |
1 |
| croak_obj; |
| 539 |
|
| } |
| 540 |
|
| |
| 541 |
33 |
| read_results = POPs; |
| 542 |
|
| |
| 543 |
33 |
▶ | if (!SvOK(read_results)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(read_results)) { |
0 |
33 |
33 |
|
| 544 |
0 |
| croak("read error"); |
| 545 |
|
| } |
| 546 |
|
| |
| 547 |
33 |
| read_results_iv = SvIV(read_results); |
| 548 |
|
| |
| 549 |
33 |
| chars = SvPV(tbuff, read_length); |
| 550 |
|
| |
| 551 |
|
| /* |
| 552 |
|
| * If the file handle uses an encoding layer, the length parameter is |
| 553 |
|
| * interpreted as character count, not as byte count. So it's possible |
| 554 |
|
| * that more than len bytes are read which would overflow the buffer. |
| 555 |
|
| * Check for this condition also by comparing the return value. |
| 556 |
|
| */ |
| 557 |
33 |
▶ | if (read_results_iv != read_length || read_length > len) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (read_results_iv != read_length || read_length > len) { |
32 |
1 |
33 |
| if (read_results_iv != read_length || read_length > len) { |
0 |
32 |
32 |
|
| 558 |
1 |
| croak("Read more bytes than requested. Do you use an encoding-related" |
| 559 |
|
| " PerlIO layer?"); |
| 560 |
|
| } |
| 561 |
32 |
| strncpy(buffer, chars, read_length); |
| 562 |
|
| |
| 563 |
32 |
| PUTBACK; |
| 564 |
32 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
32 |
0 |
32 |
|
| 565 |
32 |
| LEAVE; |
| 566 |
|
| |
| 567 |
32 |
| return read_length; |
| 568 |
|
| } |
| 569 |
|
| |
| 570 |
|
| /* used only by Reader */ |
| 571 |
|
| int |
| 572 |
1 |
| LibXML_close_perl (SV * ioref) |
| 573 |
|
| { |
| 574 |
1 |
| SvREFCNT_dec(ioref); |
| 575 |
1 |
| return 0; |
| 576 |
|
| } |
| 577 |
|
| |
| 578 |
|
| int |
| 579 |
120 |
| LibXML_input_match(char const * filename) |
| 580 |
|
| { |
| 581 |
|
| int results; |
| 582 |
|
| int count; |
| 583 |
|
| SV * res; |
| 584 |
|
| |
| 585 |
120 |
| results = 0; |
| 586 |
|
| |
| 587 |
|
| { |
| 588 |
|
| dTHX; |
| 589 |
120 |
| dSP; |
| 590 |
|
| |
| 591 |
120 |
| ENTER; |
| 592 |
120 |
| SAVETMPS; |
| 593 |
|
| |
| 594 |
120 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
120 |
120 |
|
| 595 |
120 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
120 |
120 |
|
| 596 |
120 |
| PUSHs(sv_2mortal(newSVpv((char*)filename, 0))); |
| 597 |
120 |
| PUTBACK; |
| 598 |
|
| |
| 599 |
120 |
| count = call_pv("XML::LibXML::InputCallback::_callback_match", |
| 600 |
|
| G_SCALAR | G_EVAL); |
| 601 |
|
| |
| 602 |
120 |
| SPAGAIN; |
| 603 |
|
| |
| 604 |
120 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
120 |
120 |
|
| 605 |
0 |
| croak("match callback must return a single value"); |
| 606 |
|
| } |
| 607 |
|
| |
| 608 |
120 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
120 |
0 |
120 |
| if (SvTRUE(ERRSV)) { |
0 |
120 |
120 |
|
| 609 |
0 |
| (void) POPs; |
| 610 |
0 |
| croak_obj; |
| 611 |
|
| } |
| 612 |
|
| |
| 613 |
120 |
| res = POPs; |
| 614 |
|
| |
| 615 |
120 |
▶ | if (SvTRUE(res)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTRUE(res)) { |
25 |
95 |
120 |
|
| 616 |
25 |
| results = 1; |
| 617 |
|
| } |
| 618 |
|
| |
| 619 |
120 |
| PUTBACK; |
| 620 |
120 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
120 |
0 |
120 |
|
| 621 |
120 |
| LEAVE; |
| 622 |
|
| } |
| 623 |
120 |
| return results; |
| 624 |
|
| } |
| 625 |
|
| |
| 626 |
|
| void * |
| 627 |
25 |
| LibXML_input_open(char const * filename) |
| 628 |
|
| { |
| 629 |
|
| SV * results; |
| 630 |
|
| int count; |
| 631 |
|
| |
| 632 |
|
| dTHX; |
| 633 |
25 |
| dSP; |
| 634 |
|
| |
| 635 |
25 |
| ENTER; |
| 636 |
25 |
| SAVETMPS; |
| 637 |
|
| |
| 638 |
25 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
25 |
25 |
|
| 639 |
25 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
25 |
25 |
|
| 640 |
25 |
| PUSHs(sv_2mortal(newSVpv((char*)filename, 0))); |
| 641 |
25 |
| PUTBACK; |
| 642 |
|
| |
| 643 |
25 |
| count = call_pv("XML::LibXML::InputCallback::_callback_open", |
| 644 |
|
| G_SCALAR | G_EVAL); |
| 645 |
|
| |
| 646 |
25 |
| SPAGAIN; |
| 647 |
|
| |
| 648 |
25 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
25 |
25 |
|
| 649 |
0 |
| croak("open callback must return a single value"); |
| 650 |
|
| } |
| 651 |
|
| |
| 652 |
25 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
25 |
0 |
25 |
| if (SvTRUE(ERRSV)) { |
0 |
25 |
25 |
|
| 653 |
0 |
| (void) POPs; |
| 654 |
0 |
| croak_obj; |
| 655 |
|
| } |
| 656 |
|
| |
| 657 |
25 |
| results = POPs; |
| 658 |
|
| |
| 659 |
25 |
| (void)SvREFCNT_inc(results); |
| 660 |
|
| |
| 661 |
25 |
| PUTBACK; |
| 662 |
25 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
25 |
0 |
25 |
|
| 663 |
25 |
| LEAVE; |
| 664 |
|
| |
| 665 |
25 |
| return (void *)results; |
| 666 |
|
| } |
| 667 |
|
| |
| 668 |
|
| int |
| 669 |
74 |
| LibXML_input_read(void * context, char * buffer, int len) |
| 670 |
|
| { |
| 671 |
|
| STRLEN res_len; |
| 672 |
|
| const char * output; |
| 673 |
|
| SV * ctxt; |
| 674 |
|
| SV * output_sv; |
| 675 |
|
| |
| 676 |
74 |
| res_len = 0; |
| 677 |
74 |
| ctxt = (SV *)context; |
| 678 |
|
| |
| 679 |
|
| { |
| 680 |
|
| int count; |
| 681 |
|
| |
| 682 |
|
| dTHX; |
| 683 |
74 |
| dSP; |
| 684 |
|
| |
| 685 |
74 |
| ENTER; |
| 686 |
74 |
| SAVETMPS; |
| 687 |
|
| |
| 688 |
74 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
74 |
74 |
|
| 689 |
74 |
▶ | EXTEND(SP, 2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 2); |
0 |
74 |
74 |
|
| 690 |
74 |
| PUSHs(ctxt); |
| 691 |
74 |
| PUSHs(sv_2mortal(newSViv(len))); |
| 692 |
74 |
| PUTBACK; |
| 693 |
|
| |
| 694 |
74 |
| count = call_pv("XML::LibXML::InputCallback::_callback_read", |
| 695 |
|
| G_SCALAR | G_EVAL); |
| 696 |
|
| |
| 697 |
74 |
| SPAGAIN; |
| 698 |
|
| |
| 699 |
74 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
74 |
74 |
|
| 700 |
0 |
| croak("read callback must return a single value"); |
| 701 |
|
| } |
| 702 |
|
| |
| 703 |
74 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
74 |
0 |
74 |
| if (SvTRUE(ERRSV)) { |
0 |
74 |
74 |
|
| 704 |
0 |
| (void) POPs; |
| 705 |
0 |
| croak_obj; |
| 706 |
|
| } |
| 707 |
|
| |
| 708 |
|
| /* |
| 709 |
|
| * Handle undef()s gracefully, to avoid using POPpx which warns upon $^W |
| 710 |
|
| * being set. See t/49callbacks_returning_undef.t and: |
| 711 |
|
| * https://rt.cpan.org/Ticket/Display.html?id=70321 |
| 712 |
|
| * */ |
| 713 |
|
| |
| 714 |
74 |
| output_sv = POPs; |
| 715 |
148 |
▶ | output = SvOK(output_sv) ? SvPV_nolen(output_sv) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| output = SvOK(output_sv) ? SvPV_nolen(output_sv) : NULL; |
74 |
0 |
74 |
|
| 716 |
|
| |
| 717 |
74 |
▶ | if (output != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (output != NULL) { |
74 |
0 |
74 |
|
| 718 |
74 |
| res_len = strlen(output); |
| 719 |
74 |
▶ | if (res_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (res_len) { |
49 |
25 |
74 |
|
| 720 |
49 |
| strncpy(buffer, output, res_len); |
| 721 |
|
| } |
| 722 |
|
| else { |
| 723 |
25 |
| buffer[0] = 0; |
| 724 |
|
| } |
| 725 |
|
| } |
| 726 |
|
| |
| 727 |
74 |
| PUTBACK; |
| 728 |
74 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
74 |
0 |
74 |
|
| 729 |
74 |
| LEAVE; |
| 730 |
|
| } |
| 731 |
74 |
| return res_len; |
| 732 |
|
| } |
| 733 |
|
| |
| 734 |
|
| void |
| 735 |
25 |
| LibXML_input_close(void * context) |
| 736 |
|
| { |
| 737 |
|
| SV * ctxt; |
| 738 |
|
| |
| 739 |
25 |
| ctxt = (SV *)context; |
| 740 |
|
| |
| 741 |
|
| { |
| 742 |
|
| dTHX; |
| 743 |
25 |
| dSP; |
| 744 |
|
| |
| 745 |
25 |
| ENTER; |
| 746 |
25 |
| SAVETMPS; |
| 747 |
|
| |
| 748 |
25 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
25 |
25 |
|
| 749 |
25 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
25 |
25 |
|
| 750 |
25 |
| PUSHs(ctxt); |
| 751 |
25 |
| PUTBACK; |
| 752 |
|
| |
| 753 |
25 |
| call_pv("XML::LibXML::InputCallback::_callback_close", |
| 754 |
|
| G_SCALAR | G_EVAL | G_DISCARD); |
| 755 |
|
| |
| 756 |
25 |
| SvREFCNT_dec(ctxt); |
| 757 |
|
| |
| 758 |
25 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
25 |
0 |
25 |
| if (SvTRUE(ERRSV)) { |
0 |
25 |
25 |
|
| 759 |
0 |
| croak_obj; |
| 760 |
|
| } |
| 761 |
|
| |
| 762 |
25 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
25 |
25 |
|
| 763 |
25 |
| LEAVE; |
| 764 |
|
| } |
| 765 |
25 |
| } |
| 766 |
|
| |
| 767 |
|
| int |
| 768 |
1 |
| LibXML_output_write_handler(void * ioref, char * buffer, int len) |
| 769 |
|
| { |
| 770 |
1 |
▶ | if ( buffer != NULL && len > 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( buffer != NULL && len > 0) { |
1 |
0 |
1 |
| if ( buffer != NULL && len > 0) { |
1 |
0 |
1 |
|
| 771 |
|
| dTHX; |
| 772 |
1 |
| dSP; |
| 773 |
|
| |
| 774 |
1 |
| SV * tbuff = newSVpv(buffer,len); |
| 775 |
1 |
| SV * tsize = newSViv(len); |
| 776 |
|
| |
| 777 |
|
| |
| 778 |
1 |
| ENTER; |
| 779 |
1 |
| SAVETMPS; |
| 780 |
|
| |
| 781 |
1 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
1 |
1 |
|
| 782 |
1 |
▶ | EXTEND(SP, 3); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 3); |
0 |
1 |
1 |
|
| 783 |
1 |
| PUSHs((SV*)ioref); |
| 784 |
1 |
| PUSHs(sv_2mortal(tbuff)); |
| 785 |
1 |
| PUSHs(sv_2mortal(tsize)); |
| 786 |
1 |
| PUTBACK; |
| 787 |
|
| |
| 788 |
1 |
| call_pv("XML::LibXML::__write", G_SCALAR | G_EVAL | G_DISCARD ); |
| 789 |
|
| |
| 790 |
1 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
1 |
0 |
1 |
| if (SvTRUE(ERRSV)) { |
0 |
1 |
1 |
|
| 791 |
0 |
| croak_obj; |
| 792 |
|
| } |
| 793 |
|
| |
| 794 |
1 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
1 |
0 |
1 |
|
| 795 |
1 |
| LEAVE; |
| 796 |
|
| } |
| 797 |
1 |
| return len; |
| 798 |
|
| } |
| 799 |
|
| |
| 800 |
|
| int |
| 801 |
1 |
| LibXML_output_close_handler( void * handler ) |
| 802 |
|
| { |
| 803 |
1 |
| return 1; |
| 804 |
|
| } |
| 805 |
|
| |
| 806 |
|
| /* Dispatcher for user-installed Perl entity loaders (per-parser |
| 807 |
|
| * "ext_ent_handler" or process-global externalEntityLoader()). DO NOT add |
| 808 |
|
| * URL filtering or no_network checks here -- the user's callback is the |
| 809 |
|
| * policy authority. See CLAUDE.md "Entity loaders" and GH #168/#133/#143. */ |
| 810 |
|
| xmlParserInputPtr |
| 811 |
35 |
| LibXML_load_external_entity( |
| 812 |
|
| const char * URL, |
| 813 |
|
| const char * ID, |
| 814 |
|
| xmlParserCtxtPtr ctxt) |
| 815 |
|
| { |
| 816 |
|
| SV ** func; |
| 817 |
|
| int count; |
| 818 |
|
| SV * results; |
| 819 |
|
| STRLEN results_len; |
| 820 |
|
| int int_results_len; |
| 821 |
|
| const char * results_pv; |
| 822 |
|
| xmlParserInputBufferPtr input_buf; |
| 823 |
|
| |
| 824 |
35 |
▶ | if (ctxt->_private == NULL && EXTERNAL_ENTITY_LOADER_FUNC == NULL) |
Branch: 2 branches
| Branch | True | False | Total |
| if (ctxt->_private == NULL && EXTERNAL_ENTITY_LOADER_FUNC == NULL) |
4 |
31 |
35 |
| if (ctxt->_private == NULL && EXTERNAL_ENTITY_LOADER_FUNC == NULL) |
0 |
4 |
4 |
|
| 825 |
|
| { |
| 826 |
0 |
| return xmlNewInputFromFile(ctxt, URL); |
| 827 |
|
| } |
| 828 |
|
| |
| 829 |
35 |
▶ | if (URL == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (URL == NULL) { |
0 |
35 |
35 |
|
| 830 |
0 |
| URL = ""; |
| 831 |
|
| } |
| 832 |
35 |
▶ | if (ID == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ID == NULL) { |
22 |
13 |
35 |
|
| 833 |
22 |
| ID = ""; |
| 834 |
|
| } |
| 835 |
|
| |
| 836 |
|
| /* fetch entity loader function */ |
| 837 |
35 |
▶ | if(EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if(EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
27 |
8 |
35 |
|
| 838 |
|
| { |
| 839 |
27 |
| func = &EXTERNAL_ENTITY_LOADER_FUNC; |
| 840 |
|
| } |
| 841 |
|
| else |
| 842 |
|
| { |
| 843 |
|
| SV * self; |
| 844 |
|
| HV * real_obj; |
| 845 |
|
| |
| 846 |
8 |
| self = (SV *)ctxt->_private; |
| 847 |
8 |
| real_obj = (HV *)SvRV(self); |
| 848 |
8 |
| func = hv_fetch(real_obj, "ext_ent_handler", 15, 0); |
| 849 |
|
| } |
| 850 |
|
| |
| 851 |
35 |
▶ | if (func != NULL && SvTRUE(*func)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (func != NULL && SvTRUE(*func)) { |
35 |
0 |
35 |
| if (func != NULL && SvTRUE(*func)) { |
35 |
0 |
35 |
|
| 852 |
|
| dTHX; |
| 853 |
35 |
| dSP; |
| 854 |
|
| |
| 855 |
35 |
| ENTER; |
| 856 |
35 |
| SAVETMPS; |
| 857 |
|
| |
| 858 |
35 |
▶ | PUSHMARK(SP) ; |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP) ; |
0 |
35 |
35 |
|
| 859 |
35 |
▶ | XPUSHs(sv_2mortal(newSVpv((char*)URL, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv((char*)URL, 0))); |
0 |
35 |
35 |
|
| 860 |
35 |
▶ | XPUSHs(sv_2mortal(newSVpv((char*)ID, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv((char*)ID, 0))); |
0 |
35 |
35 |
|
| 861 |
35 |
| PUTBACK; |
| 862 |
|
| |
| 863 |
35 |
| count = call_sv(*func, G_SCALAR | G_EVAL); |
| 864 |
|
| |
| 865 |
35 |
| SPAGAIN; |
| 866 |
|
| |
| 867 |
35 |
▶ | if (count == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count == 0) { |
0 |
35 |
35 |
|
| 868 |
0 |
| croak("external entity handler did not return a value"); |
| 869 |
|
| } |
| 870 |
|
| |
| 871 |
35 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
35 |
0 |
35 |
| if (SvTRUE(ERRSV)) { |
1 |
34 |
35 |
|
| 872 |
1 |
| (void) POPs; |
| 873 |
1 |
| croak_obj; |
| 874 |
|
| } |
| 875 |
|
| |
| 876 |
34 |
| results = POPs; |
| 877 |
|
| |
| 878 |
34 |
| results_pv = SvPV(results, results_len); |
| 879 |
34 |
| int_results_len = results_len; |
| 880 |
34 |
▶ | if ((results_len > INT_MAX) || (int_results_len != results_len)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ((results_len > INT_MAX) || (int_results_len != results_len)) { |
34 |
0 |
34 |
| if ((results_len > INT_MAX) || (int_results_len != results_len)) { |
0 |
34 |
34 |
|
| 881 |
0 |
| croak("a buffer would be too big\n"); |
| 882 |
|
| } |
| 883 |
34 |
| input_buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE); |
| 884 |
34 |
▶ | if (!input_buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!input_buf) { |
0 |
34 |
34 |
|
| 885 |
0 |
| croak("cannot create a buffer!\n"); |
| 886 |
|
| } |
| 887 |
34 |
▶ | if (-1 == xmlParserInputBufferPush(input_buf, int_results_len, results_pv)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (-1 == xmlParserInputBufferPush(input_buf, int_results_len, results_pv)) { |
0 |
34 |
34 |
|
| 888 |
0 |
| xmlFreeParserInputBuffer(input_buf); |
| 889 |
0 |
| croak("cannot push an external entity into a buffer!\n"); |
| 890 |
|
| } |
| 891 |
|
| |
| 892 |
34 |
| PUTBACK; |
| 893 |
34 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
34 |
0 |
34 |
|
| 894 |
34 |
| LEAVE; |
| 895 |
|
| |
| 896 |
34 |
| return xmlNewIOInputStream(ctxt, input_buf, XML_CHAR_ENCODING_NONE); |
| 897 |
|
| } |
| 898 |
|
| else { |
| 899 |
0 |
▶ | if (URL == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (URL == NULL) { |
0 |
0 |
0 |
|
| 900 |
0 |
| return NULL; |
| 901 |
|
| } |
| 902 |
0 |
| return xmlNewInputFromFile(ctxt, URL); |
| 903 |
|
| } |
| 904 |
|
| } |
| 905 |
|
| |
| 906 |
|
| /* **************************************************************** |
| 907 |
|
| * Helper functions |
| 908 |
|
| * **************************************************************** */ |
| 909 |
|
| |
| 910 |
|
| HV* |
| 911 |
1044 |
| LibXML_init_parser( SV * self, xmlParserCtxtPtr ctxt ) { |
| 912 |
|
| /* we fetch all switches and callbacks from the hash */ |
| 913 |
1044 |
| HV* real_obj = NULL; |
| 914 |
1044 |
| SV** item = NULL; |
| 915 |
1044 |
| int parserOptions = XML_PARSE_NODICT; |
| 916 |
|
| |
| 917 |
|
| /* A NOTE ABOUT xmlInitParser(); */ |
| 918 |
|
| /* xmlInitParser() should be used only at startup and*/ |
| 919 |
|
| /* not for initializing a single parser. libxml2's */ |
| 920 |
|
| /* documentation is quite clear about this. If */ |
| 921 |
|
| /* something fails it is a problem elsewhere. Simply */ |
| 922 |
|
| /* resetting the entire module will lead to unwanted */ |
| 923 |
|
| /* results in server environments, such as if */ |
| 924 |
|
| /* mod_perl is used together with php's xml module. */ |
| 925 |
|
| /* calling xmlInitParser() here is definitely wrong! */ |
| 926 |
|
| /* xmlInitParser(); */ |
| 927 |
|
| |
| 928 |
|
| #ifndef WITH_SERRORS |
| 929 |
|
| xmlGetWarningsDefaultValue = 0; |
| 930 |
|
| #endif |
| 931 |
1044 |
▶ | if ( self != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self != NULL ) { |
1044 |
0 |
1044 |
|
| 932 |
|
| /* first fetch the values from the hash */ |
| 933 |
1044 |
| real_obj = (HV *)SvRV(self); |
| 934 |
|
| |
| 935 |
1044 |
| item = hv_fetch( real_obj, "XML_LIBXML_PARSER_OPTIONS", 25, 0 ); |
| 936 |
1044 |
▶ | if (item != NULL && SvOK(*item)) parserOptions = sv_2iv(*item); |
Branch: 2 branches
| Branch | True | False | Total |
| if (item != NULL && SvOK(*item)) parserOptions = sv_2iv(*item); |
1044 |
0 |
1044 |
| if (item != NULL && SvOK(*item)) parserOptions = sv_2iv(*item); |
1044 |
0 |
1044 |
|
| 937 |
|
| |
| 938 |
|
| /* compatibility with old implementation: |
| 939 |
|
| absence of XML_PARSE_DTDLOAD (load_ext_dtd) implies absence of |
| 940 |
|
| all DTD related flags |
| 941 |
|
| */ |
| 942 |
1044 |
▶ | if ((parserOptions & XML_PARSE_DTDLOAD) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((parserOptions & XML_PARSE_DTDLOAD) == 0) { |
885 |
159 |
1044 |
|
| 943 |
885 |
| parserOptions &= ~(XML_PARSE_DTDVALID | XML_PARSE_DTDATTR | XML_PARSE_NOENT ); |
| 944 |
|
| } |
| 945 |
1044 |
▶ | if (ctxt) xmlCtxtUseOptions(ctxt, parserOptions ); /* Note: sets ctxt->linenumbers = 1 */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt) xmlCtxtUseOptions(ctxt, parserOptions ); /* Note: sets ctxt->linenumbers = 1 */ |
577 |
467 |
1044 |
|
| 946 |
|
| |
| 947 |
|
| /* |
| 948 |
|
| * Without this if/else conditional, NOBLANKS has no effect. |
| 949 |
|
| * |
| 950 |
|
| * For more information, see: |
| 951 |
|
| * |
| 952 |
|
| * https://rt.cpan.org/Ticket/Display.html?id=76696 |
| 953 |
|
| * |
| 954 |
|
| * */ |
| 955 |
1044 |
▶ | if (parserOptions & XML_PARSE_NOBLANKS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (parserOptions & XML_PARSE_NOBLANKS) { |
61 |
983 |
1044 |
|
| 956 |
61 |
| xmlKeepBlanksDefault(0); |
| 957 |
|
| } |
| 958 |
|
| else { |
| 959 |
983 |
| xmlKeepBlanksDefault(1); |
| 960 |
|
| } |
| 961 |
|
| |
| 962 |
1044 |
| item = hv_fetch( real_obj, "XML_LIBXML_LINENUMBERS", 22, 0 ); |
| 963 |
1044 |
▶ | if ( item != NULL && SvTRUE(*item) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( item != NULL && SvTRUE(*item) ) { |
110 |
934 |
1044 |
| if ( item != NULL && SvTRUE(*item) ) { |
2 |
108 |
110 |
|
| 964 |
2 |
▶ | if (ctxt) ctxt->linenumbers = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt) ctxt->linenumbers = 1; |
2 |
0 |
2 |
|
| 965 |
|
| } |
| 966 |
|
| else { |
| 967 |
1042 |
▶ | if (ctxt) ctxt->linenumbers = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt) ctxt->linenumbers = 0; |
575 |
467 |
1042 |
|
| 968 |
|
| } |
| 969 |
|
| |
| 970 |
|
| /* If a user installed a process-global loader via externalEntityLoader(), |
| 971 |
|
| * leave it alone -- they're the policy authority. See CLAUDE.md |
| 972 |
|
| * "Entity loaders". */ |
| 973 |
1044 |
▶ | if(EXTERNAL_ENTITY_LOADER_FUNC == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if(EXTERNAL_ENTITY_LOADER_FUNC == NULL) |
1026 |
18 |
1044 |
|
| 974 |
|
| { |
| 975 |
1026 |
| item = hv_fetch(real_obj, "ext_ent_handler", 15, 0); |
| 976 |
1026 |
▶ | if (item != NULL && SvTRUE(*item)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (item != NULL && SvTRUE(*item)) { |
92 |
934 |
1026 |
| if (item != NULL && SvTRUE(*item)) { |
7 |
85 |
92 |
|
| 977 |
7 |
| LibXML_old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 978 |
7 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)LibXML_load_external_entity ); |
| 979 |
|
| } |
| 980 |
|
| else |
| 981 |
|
| { |
| 982 |
1019 |
▶ | if (parserOptions & XML_PARSE_NONET) |
Branch: 1 branch
| Branch | True | False | Total |
| if (parserOptions & XML_PARSE_NONET) |
12 |
1007 |
1019 |
|
| 983 |
|
| { |
| 984 |
12 |
| LibXML_old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 985 |
12 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 986 |
|
| } |
| 987 |
|
| /* LibXML_old_ext_ent_loader = NULL; */ |
| 988 |
|
| } |
| 989 |
|
| } |
| 990 |
|
| } |
| 991 |
|
| |
| 992 |
1044 |
| return real_obj; |
| 993 |
|
| } |
| 994 |
|
| |
| 995 |
|
| void |
| 996 |
1041 |
| LibXML_cleanup_parser() { |
| 997 |
|
| #ifndef WITH_SERRORS |
| 998 |
|
| xmlGetWarningsDefaultValue = 0; |
| 999 |
|
| #endif |
| 1000 |
1041 |
▶ | if (EXTERNAL_ENTITY_LOADER_FUNC == NULL && LibXML_old_ext_ent_loader != NULL) |
Branch: 2 branches
| Branch | True | False | Total |
| if (EXTERNAL_ENTITY_LOADER_FUNC == NULL && LibXML_old_ext_ent_loader != NULL) |
1024 |
17 |
1041 |
| if (EXTERNAL_ENTITY_LOADER_FUNC == NULL && LibXML_old_ext_ent_loader != NULL) |
19 |
1005 |
1024 |
|
| 1001 |
|
| { |
| 1002 |
19 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)LibXML_old_ext_ent_loader ); |
| 1003 |
19 |
| LibXML_old_ext_ent_loader = NULL; |
| 1004 |
|
| } |
| 1005 |
1041 |
| } |
| 1006 |
|
| |
| 1007 |
|
| int |
| 1008 |
289 |
| LibXML_test_node_name( xmlChar * name ) |
| 1009 |
|
| { |
| 1010 |
289 |
▶ | if ( name == NULL || *name == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( name == NULL || *name == 0 ) { |
289 |
0 |
289 |
| if ( name == NULL || *name == 0 ) { |
0 |
289 |
289 |
|
| 1011 |
0 |
| return(0); |
| 1012 |
|
| } |
| 1013 |
|
| |
| 1014 |
289 |
| return xmlValidateName( name, 0 ) == 0; |
| 1015 |
|
| } |
| 1016 |
|
| |
| 1017 |
|
| /* Assumes that the node has a proxy. */ |
| 1018 |
|
| static void |
| 1019 |
35 |
| LibXML_reparent_removed_node(xmlNodePtr node) { |
| 1020 |
|
| /* |
| 1021 |
|
| * Attribute nodes can't be added to document fragments. Adding |
| 1022 |
|
| * DTD nodes would cause a memory leak. |
| 1023 |
|
| */ |
| 1024 |
35 |
▶ | if (node->type != XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type != XML_ATTRIBUTE_NODE |
33 |
2 |
35 |
|
| 1025 |
33 |
▶ | && node->type != XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| && node->type != XML_DTD_NODE) { |
28 |
5 |
33 |
|
| 1026 |
28 |
| ProxyNodePtr docfrag = PmmNewFragment(node->doc); |
| 1027 |
28 |
| xmlAddChild(PmmNODE(docfrag), node); |
| 1028 |
28 |
| PmmFixOwner(PmmPROXYNODE(node), docfrag); |
| 1029 |
|
| } |
| 1030 |
35 |
| } |
| 1031 |
|
| |
| 1032 |
|
| static void |
| 1033 |
12 |
| LibXML_set_int_subset(xmlDocPtr doc, xmlNodePtr dtd) { |
| 1034 |
12 |
| xmlNodePtr old_dtd = (xmlNodePtr)doc->intSubset; |
| 1035 |
12 |
▶ | if (old_dtd == dtd) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (old_dtd == dtd) { |
0 |
12 |
12 |
|
| 1036 |
0 |
| return; |
| 1037 |
|
| } |
| 1038 |
|
| |
| 1039 |
12 |
▶ | if (old_dtd != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (old_dtd != NULL) { |
12 |
0 |
12 |
|
| 1040 |
12 |
| xmlUnlinkNode(old_dtd); |
| 1041 |
|
| |
| 1042 |
12 |
▶ | if (PmmPROXYNODE(old_dtd) == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PmmPROXYNODE(old_dtd) == NULL) { |
6 |
6 |
12 |
|
| 1043 |
6 |
| xmlFreeDtd((xmlDtdPtr)old_dtd); |
| 1044 |
|
| } |
| 1045 |
|
| } |
| 1046 |
|
| |
| 1047 |
12 |
| doc->intSubset = (xmlDtdPtr)dtd; |
| 1048 |
|
| } |
| 1049 |
|
| |
| 1050 |
|
| /* **************************************************************** |
| 1051 |
|
| * XPathContext helper functions |
| 1052 |
|
| * **************************************************************** */ |
| 1053 |
|
| |
| 1054 |
|
| /* Temporary node pool: * |
| 1055 |
|
| * Stores pnode in context node-pool hash table in order to preserve * |
| 1056 |
|
| * at least one reference. * |
| 1057 |
|
| * If pnode is NULL, only return current value for hashkey */ |
| 1058 |
|
| static SV* |
| 1059 |
6045 |
| LibXML_XPathContext_pool ( xmlXPathContextPtr ctxt, void * hashkey, SV * pnode ) { |
| 1060 |
|
| SV ** value; |
| 1061 |
|
| SV * key; |
| 1062 |
|
| STRLEN len; |
| 1063 |
|
| char * strkey; |
| 1064 |
|
| dTHX; |
| 1065 |
|
| |
| 1066 |
6045 |
▶ | if (XPathContextDATA(ctxt)->pool == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->pool == NULL) { |
20 |
6025 |
6045 |
|
| 1067 |
20 |
▶ | if (pnode == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (pnode == NULL) { |
0 |
20 |
20 |
|
| 1068 |
0 |
| return &PL_sv_undef; |
| 1069 |
|
| } else { |
| 1070 |
|
| xs_warn("initializing node pool"); |
| 1071 |
20 |
| XPathContextDATA(ctxt)->pool = newHV(); |
| 1072 |
|
| } |
| 1073 |
|
| } |
| 1074 |
|
| |
| 1075 |
6045 |
| key = newSViv(PTR2IV(hashkey)); |
| 1076 |
6045 |
| strkey = SvPV(key, len); |
| 1077 |
6045 |
▶ | if (pnode != NULL && !hv_exists(XPathContextDATA(ctxt)->pool,strkey,len)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (pnode != NULL && !hv_exists(XPathContextDATA(ctxt)->pool,strkey,len)) { |
6045 |
0 |
6045 |
| if (pnode != NULL && !hv_exists(XPathContextDATA(ctxt)->pool,strkey,len)) { |
6043 |
2 |
6045 |
|
| 1078 |
6043 |
| value = hv_store(XPathContextDATA(ctxt)->pool,strkey,len, SvREFCNT_inc(pnode),0); |
| 1079 |
|
| } else { |
| 1080 |
2 |
| value = hv_fetch(XPathContextDATA(ctxt)->pool,strkey,len, 0); |
| 1081 |
|
| } |
| 1082 |
6045 |
| SvREFCNT_dec(key); |
| 1083 |
|
| |
| 1084 |
6045 |
▶ | if (value == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (value == NULL) { |
0 |
6045 |
6045 |
|
| 1085 |
0 |
| return &PL_sv_undef; |
| 1086 |
|
| } else { |
| 1087 |
6045 |
| return *value; |
| 1088 |
|
| } |
| 1089 |
|
| } |
| 1090 |
|
| |
| 1091 |
|
| /* convert perl result structures to LibXML structures */ |
| 1092 |
|
| static xmlXPathObjectPtr |
| 1093 |
52 |
| LibXML_perldata_to_LibXMLdata(xmlXPathParserContextPtr ctxt, |
| 1094 |
|
| SV* perl_result) { |
| 1095 |
|
| dTHX; |
| 1096 |
|
| |
| 1097 |
52 |
▶ | if (!SvOK(perl_result)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(perl_result)) { |
0 |
52 |
52 |
|
| 1098 |
0 |
| return (xmlXPathObjectPtr)xmlXPathNewCString(""); |
| 1099 |
|
| } |
| 1100 |
52 |
▶ | if (SvROK(perl_result) && |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvROK(perl_result) && |
40 |
12 |
52 |
|
| 1101 |
40 |
▶ | SvTYPE(SvRV(perl_result)) == SVt_PVAV) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvTYPE(SvRV(perl_result)) == SVt_PVAV) { |
27 |
13 |
40 |
|
| 1102 |
|
| /* consider any array ref to be a nodelist */ |
| 1103 |
|
| int i; |
| 1104 |
|
| int length; |
| 1105 |
|
| SV ** pnode; |
| 1106 |
|
| AV * array_result; |
| 1107 |
|
| xmlXPathObjectPtr ret; |
| 1108 |
|
| |
| 1109 |
27 |
| ret = (xmlXPathObjectPtr) xmlXPathNewNodeSet(INT2PTR(xmlNodePtr,NULL)); |
| 1110 |
27 |
| array_result = (AV*)SvRV(perl_result); |
| 1111 |
27 |
| length = av_len(array_result); |
| 1112 |
9083 |
▶ | for( i = 0; i <= length ; i++ ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for( i = 0; i <= length ; i++ ) { |
9056 |
27 |
9083 |
|
| 1113 |
9056 |
| pnode = av_fetch(array_result,i,0); |
| 1114 |
18112 |
▶ | if (pnode != NULL && sv_isobject(*pnode) && |
Branch: 1 branch
| Branch | True | False | Total |
| if (pnode != NULL && sv_isobject(*pnode) && |
9056 |
0 |
9056 |
|
| 1115 |
9056 |
| sv_derived_from(*pnode,"XML::LibXML::Node")) { |
| 1116 |
9056 |
| xmlXPathNodeSetAdd(ret->nodesetval, |
| 1117 |
9056 |
| INT2PTR(xmlNodePtr,PmmSvNode(*pnode))); |
| 1118 |
9056 |
▶ | if(ctxt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(ctxt) { |
6043 |
3013 |
9056 |
|
| 1119 |
6043 |
| LibXML_XPathContext_pool(ctxt->context, |
| 1120 |
6043 |
| PmmSvNode(*pnode), *pnode); |
| 1121 |
|
| } |
| 1122 |
|
| } else { |
| 1123 |
0 |
| warn("XPathContext: ignoring non-node member of a nodelist"); |
| 1124 |
|
| } |
| 1125 |
|
| } |
| 1126 |
27 |
| return ret; |
| 1127 |
25 |
▶ | } else if (sv_isobject(perl_result) && |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (sv_isobject(perl_result) && |
13 |
12 |
25 |
|
| 1128 |
13 |
▶ | (SvTYPE(SvRV(perl_result)) == SVt_PVMG)) |
Branch: 1 branch
| Branch | True | False | Total |
| (SvTYPE(SvRV(perl_result)) == SVt_PVMG)) |
13 |
0 |
13 |
|
| 1129 |
|
| { |
| 1130 |
13 |
▶ | if (sv_derived_from(perl_result, "XML::LibXML::Node")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(perl_result, "XML::LibXML::Node")) { |
11 |
2 |
13 |
|
| 1131 |
|
| xmlNodePtr tmp_node; |
| 1132 |
|
| xmlXPathObjectPtr ret; |
| 1133 |
|
| |
| 1134 |
11 |
| ret = INT2PTR(xmlXPathObjectPtr,xmlXPathNewNodeSet(NULL)); |
| 1135 |
11 |
| tmp_node = INT2PTR(xmlNodePtr,PmmSvNode(perl_result)); |
| 1136 |
11 |
| xmlXPathNodeSetAdd(ret->nodesetval,tmp_node); |
| 1137 |
11 |
▶ | if(ctxt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(ctxt) { |
2 |
9 |
11 |
|
| 1138 |
2 |
| LibXML_XPathContext_pool(ctxt->context, PmmSvNode(perl_result), |
| 1139 |
|
| perl_result); |
| 1140 |
|
| } |
| 1141 |
|
| |
| 1142 |
11 |
| return ret; |
| 1143 |
|
| } |
| 1144 |
2 |
▶ | else if (sv_isa(perl_result, "XML::LibXML::Boolean")) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (sv_isa(perl_result, "XML::LibXML::Boolean")) { |
0 |
2 |
2 |
|
| 1145 |
0 |
| return (xmlXPathObjectPtr) |
| 1146 |
0 |
| xmlXPathNewBoolean(SvIV(SvRV(perl_result))); |
| 1147 |
|
| } |
| 1148 |
2 |
▶ | else if (sv_isa(perl_result, "XML::LibXML::Literal")) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (sv_isa(perl_result, "XML::LibXML::Literal")) { |
1 |
1 |
2 |
|
| 1149 |
1 |
| return (xmlXPathObjectPtr) |
| 1150 |
2 |
| xmlXPathNewCString(SvPV_nolen(SvRV(perl_result))); |
| 1151 |
|
| } |
| 1152 |
1 |
▶ | else if (sv_isa(perl_result, "XML::LibXML::Number")) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (sv_isa(perl_result, "XML::LibXML::Number")) { |
1 |
0 |
1 |
|
| 1153 |
1 |
| return (xmlXPathObjectPtr) |
| 1154 |
|
| xmlXPathNewFloat(SvNV(SvRV(perl_result))); |
| 1155 |
|
| } |
| 1156 |
12 |
▶ | } else if (SvNOK(perl_result) || SvIOK(perl_result)) { |
Branch: 2 branches
| Branch | True | False | Total |
| } else if (SvNOK(perl_result) || SvIOK(perl_result)) { |
9 |
3 |
12 |
| } else if (SvNOK(perl_result) || SvIOK(perl_result)) { |
0 |
9 |
9 |
|
| 1157 |
3 |
| return (xmlXPathObjectPtr)xmlXPathNewFloat(SvNV(perl_result)); |
| 1158 |
|
| } else { |
| 1159 |
9 |
| return (xmlXPathObjectPtr) |
| 1160 |
9 |
| xmlXPathNewCString(SvPV_nolen(perl_result)); |
| 1161 |
|
| } |
| 1162 |
0 |
| return NULL; |
| 1163 |
|
| } |
| 1164 |
|
| |
| 1165 |
|
| |
| 1166 |
|
| /* save XPath context and XPathContextDATA for recursion */ |
| 1167 |
|
| static xmlXPathContextPtr |
| 1168 |
53 |
| LibXML_save_context(xmlXPathContextPtr ctxt) |
| 1169 |
|
| { |
| 1170 |
|
| xmlXPathContextPtr copy; |
| 1171 |
53 |
| copy = xmlMalloc(sizeof(xmlXPathContext)); |
| 1172 |
53 |
▶ | if (copy) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (copy) { |
53 |
0 |
53 |
|
| 1173 |
|
| /* backup ctxt */ |
| 1174 |
53 |
| memcpy(copy, ctxt, sizeof(xmlXPathContext)); |
| 1175 |
|
| /* clear namespaces so that they are not freed and overwritten |
| 1176 |
|
| by configure_namespaces */ |
| 1177 |
53 |
| ctxt->namespaces = NULL; |
| 1178 |
|
| /* backup data */ |
| 1179 |
53 |
| copy->user = xmlMalloc(sizeof(XPathContextData)); |
| 1180 |
53 |
▶ | if (XPathContextDATA(copy)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(copy)) { |
53 |
0 |
53 |
|
| 1181 |
53 |
| memcpy(XPathContextDATA(copy), XPathContextDATA(ctxt),sizeof(XPathContextData)); |
| 1182 |
|
| /* clear ctxt->pool, so that it is not used freed during re-entrance */ |
| 1183 |
53 |
| XPathContextDATA(ctxt)->pool = NULL; |
| 1184 |
|
| } |
| 1185 |
|
| } |
| 1186 |
53 |
| return copy; |
| 1187 |
|
| } |
| 1188 |
|
| |
| 1189 |
|
| /* restore XPath context and XPathContextDATA from a saved copy */ |
| 1190 |
|
| static void |
| 1191 |
53 |
| LibXML_restore_context(xmlXPathContextPtr ctxt, xmlXPathContextPtr copy) |
| 1192 |
|
| { |
| 1193 |
|
| dTHX; |
| 1194 |
|
| /* cleanup */ |
| 1195 |
53 |
▶ | if (XPathContextDATA(ctxt)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)) { |
53 |
0 |
53 |
|
| 1196 |
|
| /* cleanup newly created pool */ |
| 1197 |
53 |
▶ | if (XPathContextDATA(ctxt)->pool != NULL && |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->pool != NULL && |
0 |
53 |
53 |
|
| 1198 |
0 |
▶ | SvOK(XPathContextDATA(ctxt)->pool)) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvOK(XPathContextDATA(ctxt)->pool)) { |
0 |
0 |
0 |
|
| 1199 |
0 |
| SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); |
| 1200 |
|
| } |
| 1201 |
|
| } |
| 1202 |
53 |
▶ | if (ctxt->namespaces) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->namespaces) { |
0 |
53 |
53 |
|
| 1203 |
|
| /* free namespaces allocated during recursion */ |
| 1204 |
0 |
| xmlFree( ctxt->namespaces ); |
| 1205 |
|
| } |
| 1206 |
|
| |
| 1207 |
|
| /* restore context */ |
| 1208 |
53 |
▶ | if (copy) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (copy) { |
53 |
0 |
53 |
|
| 1209 |
|
| /* 1st restore our data */ |
| 1210 |
53 |
▶ | if (XPathContextDATA(copy)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(copy)) { |
53 |
0 |
53 |
|
| 1211 |
53 |
| memcpy(XPathContextDATA(ctxt),XPathContextDATA(copy),sizeof(XPathContextData)); |
| 1212 |
53 |
| xmlFree(XPathContextDATA(copy)); |
| 1213 |
53 |
| copy->user = XPathContextDATA(ctxt); |
| 1214 |
|
| } |
| 1215 |
|
| /* now copy the rest */ |
| 1216 |
53 |
| memcpy(ctxt, copy, sizeof(xmlXPathContext)); |
| 1217 |
53 |
| xmlFree(copy); |
| 1218 |
|
| } |
| 1219 |
53 |
| } |
| 1220 |
|
| |
| 1221 |
|
| |
| 1222 |
|
| /* **************************************************************** |
| 1223 |
|
| * Variable Lookup |
| 1224 |
|
| * **************************************************************** */ |
| 1225 |
|
| /* Much of the code is borrowed from Matt Sergeant's XML::LibXSLT */ |
| 1226 |
|
| static xmlXPathObjectPtr |
| 1227 |
21 |
| LibXML_generic_variable_lookup(void* varLookupData, |
| 1228 |
|
| const xmlChar *name, |
| 1229 |
|
| const xmlChar *ns_uri) |
| 1230 |
|
| { |
| 1231 |
|
| xmlXPathObjectPtr ret; |
| 1232 |
|
| xmlXPathContextPtr ctxt; |
| 1233 |
|
| xmlXPathContextPtr copy; |
| 1234 |
|
| XPathContextDataPtr data; |
| 1235 |
|
| I32 count; |
| 1236 |
|
| dTHX; |
| 1237 |
21 |
| dSP; |
| 1238 |
|
| |
| 1239 |
21 |
| ctxt = (xmlXPathContextPtr) varLookupData; |
| 1240 |
21 |
▶ | if ( ctxt == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) |
0 |
21 |
21 |
|
| 1241 |
0 |
| croak("XPathContext: missing xpath context"); |
| 1242 |
21 |
| data = XPathContextDATA(ctxt); |
| 1243 |
21 |
▶ | if ( data == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data == NULL ) |
0 |
21 |
21 |
|
| 1244 |
0 |
| croak("XPathContext: missing xpath context private data"); |
| 1245 |
21 |
▶ | if ( data->varLookup == NULL || !SvROK(data->varLookup) || |
Branch: 2 branches
| Branch | True | False | Total |
| if ( data->varLookup == NULL || !SvROK(data->varLookup) || |
21 |
0 |
21 |
| if ( data->varLookup == NULL || !SvROK(data->varLookup) || |
21 |
0 |
21 |
|
| 1246 |
21 |
▶ | SvTYPE(SvRV(data->varLookup)) != SVt_PVCV ) |
Branch: 1 branch
| Branch | True | False | Total |
| SvTYPE(SvRV(data->varLookup)) != SVt_PVCV ) |
0 |
21 |
21 |
|
| 1247 |
0 |
| croak("XPathContext: lost variable lookup function!"); |
| 1248 |
|
| |
| 1249 |
21 |
| ENTER; |
| 1250 |
21 |
| SAVETMPS; |
| 1251 |
21 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
21 |
21 |
|
| 1252 |
|
| |
| 1253 |
21 |
▶ | XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef ); |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef ); |
0 |
21 |
21 |
| XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef ); |
20 |
1 |
21 |
|
| 1254 |
21 |
▶ | XPUSHs(sv_2mortal(C2Sv(name,NULL))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(name,NULL))); |
0 |
21 |
21 |
|
| 1255 |
21 |
▶ | XPUSHs(sv_2mortal(C2Sv(ns_uri,NULL))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(ns_uri,NULL))); |
0 |
21 |
21 |
|
| 1256 |
|
| |
| 1257 |
|
| /* save context to allow recursive usage of XPathContext */ |
| 1258 |
21 |
| copy = LibXML_save_context(ctxt); |
| 1259 |
|
| |
| 1260 |
21 |
| PUTBACK ; |
| 1261 |
21 |
| count = call_sv(data->varLookup, G_SCALAR|G_EVAL); |
| 1262 |
21 |
| SPAGAIN; |
| 1263 |
|
| |
| 1264 |
|
| /* restore the xpath context */ |
| 1265 |
21 |
| LibXML_restore_context(ctxt, copy); |
| 1266 |
|
| |
| 1267 |
21 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
21 |
0 |
21 |
| if (SvTRUE(ERRSV)) { |
0 |
21 |
21 |
|
| 1268 |
0 |
| (void) POPs; |
| 1269 |
0 |
| croak_obj; |
| 1270 |
|
| } |
| 1271 |
21 |
▶ | if (count != 1) croak("XPathContext: variable lookup function returned none or more than one argument!"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) croak("XPathContext: variable lookup function returned none or more than one argument!"); |
0 |
21 |
21 |
|
| 1272 |
|
| |
| 1273 |
21 |
| ret = LibXML_perldata_to_LibXMLdata(NULL, POPs); |
| 1274 |
|
| |
| 1275 |
21 |
| PUTBACK; |
| 1276 |
21 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
21 |
0 |
21 |
|
| 1277 |
21 |
| LEAVE; |
| 1278 |
21 |
| return ret; |
| 1279 |
|
| } |
| 1280 |
|
| |
| 1281 |
|
| /* **************************************************************** |
| 1282 |
|
| * Generic Extension Function |
| 1283 |
|
| * **************************************************************** */ |
| 1284 |
|
| /* Much of the code is borrowed from Matt Sergeant's XML::LibXSLT */ |
| 1285 |
|
| static void |
| 1286 |
32 |
| LibXML_generic_extension_function(xmlXPathParserContextPtr ctxt, int nargs) |
| 1287 |
|
| { |
| 1288 |
|
| xmlXPathObjectPtr obj,ret; |
| 1289 |
32 |
| xmlNodeSetPtr nodelist = NULL; |
| 1290 |
|
| int count; |
| 1291 |
|
| SV * perl_dispatch; |
| 1292 |
|
| int i; |
| 1293 |
|
| STRLEN len; |
| 1294 |
32 |
| ProxyNodePtr owner = NULL; |
| 1295 |
|
| SV *key; |
| 1296 |
|
| char *strkey; |
| 1297 |
|
| const char *function, *uri; |
| 1298 |
|
| SV **perl_function; |
| 1299 |
|
| dTHX; |
| 1300 |
32 |
| dSP; |
| 1301 |
|
| SV * data; |
| 1302 |
|
| xmlXPathContextPtr copy; |
| 1303 |
|
| |
| 1304 |
|
| /* warn("entered LibXML_generic_extension_function for %s\n",ctxt->context->function); */ |
| 1305 |
32 |
| data = (SV *) ctxt->context->funcLookupData; |
| 1306 |
32 |
▶ | if (ctxt->context->funcLookupData == NULL || !SvROK(data) || |
Branch: 2 branches
| Branch | True | False | Total |
| if (ctxt->context->funcLookupData == NULL || !SvROK(data) || |
32 |
0 |
32 |
| if (ctxt->context->funcLookupData == NULL || !SvROK(data) || |
32 |
0 |
32 |
|
| 1307 |
32 |
▶ | SvTYPE(SvRV(data)) != SVt_PVHV) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvTYPE(SvRV(data)) != SVt_PVHV) { |
0 |
32 |
32 |
|
| 1308 |
0 |
| croak("XPathContext: lost function lookup data structure!"); |
| 1309 |
|
| } |
| 1310 |
|
| |
| 1311 |
32 |
| function = (char*) ctxt->context->function; |
| 1312 |
32 |
| uri = (char*) ctxt->context->functionURI; |
| 1313 |
|
| |
| 1314 |
32 |
| key = newSVpvn("",0); |
| 1315 |
32 |
▶ | if (uri && *uri) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (uri && *uri) { |
8 |
24 |
32 |
| if (uri && *uri) { |
8 |
0 |
8 |
|
| 1316 |
8 |
| sv_catpv(key, "{"); |
| 1317 |
8 |
| sv_catpv(key, (const char*)uri); |
| 1318 |
8 |
| sv_catpv(key, "}"); |
| 1319 |
|
| } |
| 1320 |
32 |
| sv_catpv(key, (const char*)function); |
| 1321 |
32 |
| strkey = SvPV(key, len); |
| 1322 |
|
| perl_function = |
| 1323 |
32 |
| hv_fetch((HV*)SvRV(data), strkey, len, 0); |
| 1324 |
32 |
▶ | if ( perl_function == NULL || !SvOK(*perl_function) || |
Branch: 2 branches
| Branch | True | False | Total |
| if ( perl_function == NULL || !SvOK(*perl_function) || |
32 |
0 |
32 |
| if ( perl_function == NULL || !SvOK(*perl_function) || |
32 |
0 |
32 |
|
| 1325 |
32 |
▶ | !(SvPOK(*perl_function) || |
Branch: 1 branch
| Branch | True | False | Total |
| !(SvPOK(*perl_function) || |
31 |
1 |
32 |
|
| 1326 |
31 |
▶ | (SvROK(*perl_function) && |
Branch: 1 branch
| Branch | True | False | Total |
| (SvROK(*perl_function) && |
31 |
0 |
31 |
|
| 1327 |
31 |
▶ | SvTYPE(SvRV(*perl_function)) == SVt_PVCV))) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvTYPE(SvRV(*perl_function)) == SVt_PVCV))) { |
0 |
31 |
31 |
|
| 1328 |
0 |
| croak("XPathContext: lost perl extension function!"); |
| 1329 |
|
| } |
| 1330 |
32 |
| SvREFCNT_dec(key); |
| 1331 |
|
| |
| 1332 |
32 |
| ENTER; |
| 1333 |
32 |
| SAVETMPS; |
| 1334 |
32 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
32 |
32 |
|
| 1335 |
|
| |
| 1336 |
32 |
▶ | XPUSHs(*perl_function); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(*perl_function); |
0 |
32 |
32 |
|
| 1337 |
|
| |
| 1338 |
|
| /* set up call to perl dispatcher function */ |
| 1339 |
55 |
▶ | for (i = 0; i < nargs; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < nargs; i++) { |
23 |
32 |
55 |
|
| 1340 |
23 |
| obj = (xmlXPathObjectPtr)valuePop(ctxt); |
| 1341 |
23 |
| switch (obj->type) { |
| 1342 |
11 |
| case XPATH_XSLT_TREE: |
| 1343 |
|
| case XPATH_NODESET: |
| 1344 |
11 |
| nodelist = obj->nodesetval; |
| 1345 |
11 |
▶ | if ( nodelist ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist ) { |
11 |
0 |
11 |
|
| 1346 |
11 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
0 |
11 |
11 |
|
| 1347 |
11 |
▶ | XPUSHs(sv_2mortal(newSViv(nodelist->nodeNr))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(nodelist->nodeNr))); |
0 |
11 |
11 |
|
| 1348 |
11 |
▶ | if ( nodelist->nodeNr > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist->nodeNr > 0 ) { |
10 |
1 |
11 |
|
| 1349 |
|
| int j; |
| 1350 |
10 |
| const char * cls = "XML::LibXML::Node"; |
| 1351 |
|
| xmlNodePtr tnode; |
| 1352 |
|
| SV * element; |
| 1353 |
10 |
| int l = nodelist->nodeNr; |
| 1354 |
|
| |
| 1355 |
3033 |
▶ | for( j = 0 ; j < l; j++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( j = 0 ; j < l; j++){ |
3023 |
10 |
3033 |
|
| 1356 |
3023 |
| tnode = nodelist->nodeTab[j]; |
| 1357 |
3023 |
▶ | if( tnode != NULL && tnode->doc != NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if( tnode != NULL && tnode->doc != NULL) { |
3023 |
0 |
3023 |
| if( tnode != NULL && tnode->doc != NULL) { |
3023 |
0 |
3023 |
|
| 1358 |
3023 |
▶ | owner = PmmOWNERPO(PmmNewNode(INT2PTR(xmlNodePtr,tnode->doc))); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(PmmNewNode(INT2PTR(xmlNodePtr,tnode->doc))); |
3023 |
0 |
3023 |
| owner = PmmOWNERPO(PmmNewNode(INT2PTR(xmlNodePtr,tnode->doc))); |
0 |
3023 |
3023 |
|
| 1359 |
|
| } else { |
| 1360 |
0 |
| owner = NULL; |
| 1361 |
|
| } |
| 1362 |
3023 |
▶ | if (tnode->type == XML_NAMESPACE_DECL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->type == XML_NAMESPACE_DECL) { |
0 |
3023 |
3023 |
|
| 1363 |
0 |
| element = NEWSV(0,0); |
| 1364 |
0 |
| cls = PmmNodeTypeName( tnode ); |
| 1365 |
0 |
| element = sv_setref_pv( element, |
| 1366 |
|
| (const char *)cls, |
| 1367 |
|
| (void *)xmlCopyNamespace((xmlNsPtr)tnode) |
| 1368 |
|
| ); |
| 1369 |
|
| } |
| 1370 |
|
| else { |
| 1371 |
3023 |
| element = PmmNodeToSv(tnode, owner); |
| 1372 |
|
| } |
| 1373 |
3023 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
3023 |
3023 |
|
| 1374 |
|
| } |
| 1375 |
|
| } |
| 1376 |
|
| } else { |
| 1377 |
|
| /* PP: We can't simply leave out an empty nodelist as Matt does! */ |
| 1378 |
|
| /* PP: The number of arguments must match! */ |
| 1379 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
0 |
0 |
0 |
|
| 1380 |
0 |
▶ | XPUSHs(sv_2mortal(newSViv(0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(0))); |
0 |
0 |
0 |
|
| 1381 |
|
| } |
| 1382 |
|
| /* prevent libxml2 from freeing the actual nodes */ |
| 1383 |
11 |
▶ | if (obj->boolval) obj->boolval=0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (obj->boolval) obj->boolval=0; |
0 |
11 |
11 |
|
| 1384 |
11 |
| break; |
| 1385 |
0 |
| case XPATH_BOOLEAN: |
| 1386 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
0 |
0 |
0 |
|
| 1387 |
0 |
▶ | XPUSHs(sv_2mortal(newSViv(obj->boolval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(obj->boolval))); |
0 |
0 |
0 |
|
| 1388 |
0 |
| break; |
| 1389 |
4 |
| case XPATH_NUMBER: |
| 1390 |
4 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
0 |
4 |
4 |
|
| 1391 |
4 |
▶ | XPUSHs(sv_2mortal(newSVnv(obj->floatval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVnv(obj->floatval))); |
0 |
4 |
4 |
|
| 1392 |
4 |
| break; |
| 1393 |
8 |
| case XPATH_STRING: |
| 1394 |
8 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
0 |
8 |
8 |
|
| 1395 |
8 |
▶ | XPUSHs(sv_2mortal(C2Sv(obj->stringval, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(obj->stringval, 0))); |
0 |
8 |
8 |
|
| 1396 |
8 |
| break; |
| 1397 |
0 |
| default: |
| 1398 |
0 |
| warn("Unknown XPath return type (%d) in call to {%s}%s - assuming string", obj->type, uri, function); |
| 1399 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
0 |
0 |
0 |
|
| 1400 |
|
| { |
| 1401 |
0 |
| xmlChar *str = xmlXPathCastToString(obj); |
| 1402 |
0 |
▶ | XPUSHs(sv_2mortal(C2Sv(str, 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(str, 0))); |
0 |
0 |
0 |
|
| 1403 |
0 |
| xmlFree(str); |
| 1404 |
|
| } |
| 1405 |
|
| } |
| 1406 |
23 |
| xmlXPathFreeObject(obj); |
| 1407 |
|
| } |
| 1408 |
|
| |
| 1409 |
|
| /* save context to allow recursive usage of XPathContext */ |
| 1410 |
32 |
| copy = LibXML_save_context(ctxt->context); |
| 1411 |
|
| |
| 1412 |
|
| /* call perl dispatcher */ |
| 1413 |
32 |
| PUTBACK; |
| 1414 |
32 |
| perl_dispatch = sv_2mortal(newSVpv("XML::LibXML::XPathContext::_perl_dispatcher",0)); |
| 1415 |
32 |
| count = call_sv(perl_dispatch, G_SCALAR|G_EVAL); |
| 1416 |
32 |
| SPAGAIN; |
| 1417 |
|
| |
| 1418 |
|
| /* restore the xpath context */ |
| 1419 |
32 |
| LibXML_restore_context(ctxt->context, copy); |
| 1420 |
|
| |
| 1421 |
32 |
▶ | if (SvTRUE(ERRSV)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) { |
32 |
0 |
32 |
| if (SvTRUE(ERRSV)) { |
1 |
31 |
32 |
|
| 1422 |
1 |
| (void) POPs; |
| 1423 |
1 |
| croak_obj; |
| 1424 |
|
| } |
| 1425 |
|
| |
| 1426 |
31 |
▶ | if (count != 1) croak("XPathContext: perl-dispatcher in pm file returned none or more than one argument!"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) croak("XPathContext: perl-dispatcher in pm file returned none or more than one argument!"); |
0 |
31 |
31 |
|
| 1427 |
|
| |
| 1428 |
31 |
| ret = LibXML_perldata_to_LibXMLdata(ctxt, POPs); |
| 1429 |
|
| |
| 1430 |
31 |
| valuePush(ctxt, ret); |
| 1431 |
31 |
| PUTBACK; |
| 1432 |
31 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
31 |
0 |
31 |
|
| 1433 |
31 |
| LEAVE; |
| 1434 |
31 |
| } |
| 1435 |
|
| |
| 1436 |
|
| static void |
| 1437 |
180 |
| LibXML_configure_namespaces( xmlXPathContextPtr ctxt ) { |
| 1438 |
180 |
| xmlNodePtr node = ctxt->node; |
| 1439 |
|
| |
| 1440 |
180 |
▶ | if (ctxt->namespaces != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->namespaces != NULL) { |
28 |
152 |
180 |
|
| 1441 |
28 |
| xmlFree( ctxt->namespaces ); |
| 1442 |
28 |
| ctxt->namespaces = NULL; |
| 1443 |
|
| } |
| 1444 |
180 |
▶ | if (node != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node != NULL) { |
168 |
12 |
180 |
|
| 1445 |
168 |
▶ | if (node->type == XML_DOCUMENT_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_DOCUMENT_NODE) { |
132 |
36 |
168 |
|
| 1446 |
132 |
| ctxt->namespaces = xmlGetNsList( node->doc, |
| 1447 |
132 |
| xmlDocGetRootElement( node->doc ) ); |
| 1448 |
|
| } else { |
| 1449 |
36 |
| ctxt->namespaces = xmlGetNsList(node->doc, node); |
| 1450 |
|
| } |
| 1451 |
168 |
| ctxt->nsNr = 0; |
| 1452 |
168 |
▶ | if (ctxt->namespaces != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->namespaces != NULL) { |
45 |
123 |
168 |
|
| 1453 |
45 |
| int cur=0; |
| 1454 |
|
| xmlNsPtr ns; |
| 1455 |
|
| /* we now walk through the list and |
| 1456 |
|
| drop every ns that was declared via registration */ |
| 1457 |
173 |
▶ | while (ctxt->namespaces[cur] != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (ctxt->namespaces[cur] != NULL) { |
128 |
45 |
173 |
|
| 1458 |
128 |
| ns = ctxt->namespaces[cur]; |
| 1459 |
233 |
| if (ns->prefix==NULL || |
| 1460 |
105 |
| xmlHashLookup(ctxt->nsHash, ns->prefix) != NULL) { |
| 1461 |
|
| /* drop it */ |
| 1462 |
35 |
| ctxt->namespaces[cur]=NULL; |
| 1463 |
|
| } else { |
| 1464 |
93 |
▶ | if (cur != ctxt->nsNr) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cur != ctxt->nsNr) { |
10 |
83 |
93 |
|
| 1465 |
|
| /* move the item to the new tail */ |
| 1466 |
10 |
| ctxt->namespaces[ctxt->nsNr]=ns; |
| 1467 |
10 |
| ctxt->namespaces[cur]=NULL; |
| 1468 |
|
| } |
| 1469 |
93 |
| ctxt->nsNr++; |
| 1470 |
|
| } |
| 1471 |
128 |
| cur++; |
| 1472 |
|
| } |
| 1473 |
|
| } |
| 1474 |
|
| } |
| 1475 |
180 |
| } |
| 1476 |
|
| |
| 1477 |
|
| static void |
| 1478 |
166 |
| LibXML_configure_xpathcontext( xmlXPathContextPtr ctxt ) { |
| 1479 |
166 |
| xmlNodePtr node = PmmSvNode(XPathContextDATA(ctxt)->node); |
| 1480 |
|
| |
| 1481 |
166 |
▶ | if (node != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node != NULL) { |
154 |
12 |
166 |
|
| 1482 |
154 |
| ctxt->doc = node->doc; |
| 1483 |
|
| } else { |
| 1484 |
12 |
| ctxt->doc = NULL; |
| 1485 |
|
| } |
| 1486 |
166 |
| ctxt->node = node; |
| 1487 |
166 |
| LibXML_configure_namespaces(ctxt); |
| 1488 |
166 |
| } |
| 1489 |
|
| |
| 1490 |
|
| #ifdef HAVE_READER_SUPPORT |
| 1491 |
|
| |
| 1492 |
|
| static void |
| 1493 |
62 |
| LibXML_set_reader_preserve_flag( xmlTextReaderPtr reader ) { |
| 1494 |
|
| HV *hash; |
| 1495 |
|
| char key[32]; |
| 1496 |
|
| |
| 1497 |
62 |
| hash = get_hv("XML::LibXML::Reader::_preserve_flag", 0); |
| 1498 |
62 |
▶ | if (!hash) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hash) { |
0 |
62 |
62 |
|
| 1499 |
0 |
| return; |
| 1500 |
|
| } |
| 1501 |
|
| |
| 1502 |
62 |
| (void) snprintf(key, sizeof(key), "%p", reader); |
| 1503 |
62 |
| (void) hv_store(hash, key, strlen(key), newSV(0), 0); |
| 1504 |
|
| } |
| 1505 |
|
| |
| 1506 |
|
| static int |
| 1507 |
31 |
| LibXML_get_reader_preserve_flag( xmlTextReaderPtr reader ) { |
| 1508 |
|
| HV *hash; |
| 1509 |
|
| char key[32]; |
| 1510 |
|
| |
| 1511 |
31 |
| hash = get_hv("XML::LibXML::Reader::_preserve_flag", 0); |
| 1512 |
31 |
▶ | if (!hash) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!hash) { |
0 |
31 |
31 |
|
| 1513 |
0 |
| return 0; |
| 1514 |
|
| } |
| 1515 |
|
| |
| 1516 |
31 |
| (void) snprintf(key, sizeof(key), "%p", reader); |
| 1517 |
31 |
▶ | if ( hv_exists(hash, key, strlen(key)) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( hv_exists(hash, key, strlen(key)) ) { |
10 |
21 |
31 |
|
| 1518 |
10 |
| (void) hv_delete(hash, key, strlen(key), G_DISCARD); |
| 1519 |
10 |
| return 1; |
| 1520 |
|
| } |
| 1521 |
|
| |
| 1522 |
21 |
| return 0; |
| 1523 |
|
| } |
| 1524 |
|
| |
| 1525 |
|
| #endif /* HAVE_READER_SUPPORT */ |
| 1526 |
|
| |
| 1527 |
|
| extern void boot_XML__LibXML__Devel(pTHX_ CV*); |
| 1528 |
|
| |
| 1529 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML |
| 1530 |
|
| |
| 1531 |
|
| PROTOTYPES: DISABLE |
| 1532 |
|
| |
| 1533 |
|
| BOOT: |
| 1534 |
|
| /* Load Devel first, so debug_memory can |
| 1535 |
|
| be called before any allocation. */ |
| 1536 |
|
| |
| 1537 |
|
| /* The ++ is a bit hacky, but boot_blahblah_Devel, being an |
| 1538 |
|
| * XSUB body, will try to pop once more the mark we have just |
| 1539 |
|
| * (implicitly) popped, this boot sector also being an XSUB body */ |
| 1540 |
77 |
| PL_markstack_ptr++; |
| 1541 |
77 |
| boot_XML__LibXML__Devel(aTHX_ cv); |
| 1542 |
77 |
| LIBXML_TEST_VERSION |
| 1543 |
77 |
| xmlInitParser(); |
| 1544 |
77 |
| PmmSAXInitialize(aTHX); |
| 1545 |
|
| #ifndef WITH_SERRORS |
| 1546 |
|
| xmlGetWarningsDefaultValue = 0; |
| 1547 |
|
| #endif |
| 1548 |
|
| #ifdef LIBXML_CATALOG_ENABLED |
| 1549 |
|
| /* xmlCatalogSetDebug(10); */ |
| 1550 |
77 |
| xmlInitializeCatalog(); /* use catalog data */ |
| 1551 |
|
| #endif |
| 1552 |
|
| |
| 1553 |
|
| |
| 1554 |
|
| void |
| 1555 |
|
| _CLONE( class ) |
| 1556 |
|
| CODE: |
| 1557 |
|
| #ifdef XML_LIBXML_THREADS |
| 1558 |
|
| if( PmmUSEREGISTRY ) |
| 1559 |
|
| PmmCloneProxyNodes(); |
| 1560 |
|
| #endif |
| 1561 |
|
| |
| 1562 |
|
| int |
| 1563 |
|
| _leaked_nodes() |
| 1564 |
|
| CODE: |
| 1565 |
1 |
▶ | RETVAL = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 0; |
0 |
1 |
1 |
|
| 1566 |
|
| #ifdef XML_LIBXML_THREADS |
| 1567 |
|
| if( PmmUSEREGISTRY ) |
| 1568 |
|
| RETVAL = PmmProxyNodeRegistrySize(); |
| 1569 |
|
| #endif |
| 1570 |
|
| OUTPUT: |
| 1571 |
|
| RETVAL |
| 1572 |
|
| |
| 1573 |
|
| void |
| 1574 |
|
| _dump_registry() |
| 1575 |
|
| PPCODE: |
| 1576 |
|
| #ifdef XML_LIBXML_THREADS |
| 1577 |
|
| if( PmmUSEREGISTRY ) |
| 1578 |
|
| PmmDumpRegistry(PmmREGISTRY); |
| 1579 |
|
| #endif |
| 1580 |
|
| |
| 1581 |
|
| const char * |
| 1582 |
|
| LIBXML_DOTTED_VERSION() |
| 1583 |
|
| CODE: |
| 1584 |
1 |
| RETVAL = LIBXML_DOTTED_VERSION; |
| 1585 |
|
| OUTPUT: |
| 1586 |
|
| RETVAL |
| 1587 |
|
| |
| 1588 |
|
| |
| 1589 |
|
| int |
| 1590 |
|
| LIBXML_VERSION() |
| 1591 |
|
| CODE: |
| 1592 |
100 |
▶ | RETVAL = LIBXML_VERSION; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = LIBXML_VERSION; |
1 |
99 |
100 |
|
| 1593 |
|
| OUTPUT: |
| 1594 |
|
| RETVAL |
| 1595 |
|
| |
| 1596 |
|
| int |
| 1597 |
|
| HAVE_STRUCT_ERRORS() |
| 1598 |
|
| CODE: |
| 1599 |
|
| #ifdef WITH_SERRORS |
| 1600 |
2 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
2 |
2 |
|
| 1601 |
|
| #else |
| 1602 |
|
| RETVAL = 0; |
| 1603 |
|
| #endif |
| 1604 |
|
| OUTPUT: |
| 1605 |
|
| RETVAL |
| 1606 |
|
| |
| 1607 |
|
| int |
| 1608 |
|
| HAVE_SCHEMAS() |
| 1609 |
|
| CODE: |
| 1610 |
|
| #ifdef HAVE_SCHEMAS |
| 1611 |
1 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
1 |
1 |
|
| 1612 |
|
| # if LIBXML_VERSION == 20904 |
| 1613 |
|
| /* exists but broken https://github.com/shlomif/libxml2-2.9.4-reader-schema-regression */ |
| 1614 |
|
| RETVAL = 0; |
| 1615 |
|
| # endif |
| 1616 |
|
| #else |
| 1617 |
|
| RETVAL = 0; |
| 1618 |
|
| #endif |
| 1619 |
|
| OUTPUT: |
| 1620 |
|
| RETVAL |
| 1621 |
|
| |
| 1622 |
|
| int |
| 1623 |
|
| HAVE_READER() |
| 1624 |
|
| CODE: |
| 1625 |
|
| #ifdef HAVE_READER_SUPPORT |
| 1626 |
2 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
2 |
2 |
|
| 1627 |
|
| #else |
| 1628 |
|
| RETVAL = 0; |
| 1629 |
|
| #endif |
| 1630 |
|
| OUTPUT: |
| 1631 |
|
| RETVAL |
| 1632 |
|
| |
| 1633 |
|
| int |
| 1634 |
|
| HAVE_THREAD_SUPPORT() |
| 1635 |
|
| CODE: |
| 1636 |
|
| #ifdef XML_LIBXML_THREADS |
| 1637 |
|
| RETVAL = (PmmUSEREGISTRY ? 1 : 0); |
| 1638 |
|
| #else |
| 1639 |
0 |
▶ | RETVAL = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 0; |
0 |
0 |
0 |
|
| 1640 |
|
| #endif |
| 1641 |
|
| OUTPUT: |
| 1642 |
|
| RETVAL |
| 1643 |
|
| |
| 1644 |
|
| |
| 1645 |
|
| const char * |
| 1646 |
|
| LIBXML_RUNTIME_VERSION() |
| 1647 |
|
| CODE: |
| 1648 |
83 |
| RETVAL = xmlParserVersion; |
| 1649 |
|
| OUTPUT: |
| 1650 |
|
| RETVAL |
| 1651 |
|
| |
| 1652 |
|
| void |
| 1653 |
|
| END() |
| 1654 |
|
| CODE: |
| 1655 |
77 |
| xmlCleanupParser(); |
| 1656 |
|
| |
| 1657 |
|
| int |
| 1658 |
|
| INIT_THREAD_SUPPORT() |
| 1659 |
|
| CODE: |
| 1660 |
|
| #ifdef XML_LIBXML_THREADS |
| 1661 |
|
| SV *threads = get_sv("threads::threads", 0); /* no create */ |
| 1662 |
|
| if( threads && SvOK(threads) && SvTRUE(threads) ) { |
| 1663 |
|
| PROXY_NODE_REGISTRY_MUTEX = get_sv("XML::LibXML::__PROXY_NODE_REGISTRY_MUTEX",0); |
| 1664 |
|
| RETVAL = 1; |
| 1665 |
|
| } else { |
| 1666 |
|
| croak("XML::LibXML ':threads_shared' can only be used after 'use threads'"); |
| 1667 |
|
| } |
| 1668 |
|
| #else |
| 1669 |
0 |
▶ | RETVAL = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 0; |
0 |
0 |
0 |
|
| 1670 |
|
| #endif |
| 1671 |
|
| OUTPUT: |
| 1672 |
|
| RETVAL |
| 1673 |
|
| |
| 1674 |
|
| void |
| 1675 |
|
| DISABLE_THREAD_SUPPORT() |
| 1676 |
|
| CODE: |
| 1677 |
|
| #ifdef XML_LIBXML_THREADS |
| 1678 |
|
| PROXY_NODE_REGISTRY_MUTEX = NULL; |
| 1679 |
|
| #else |
| 1680 |
0 |
| croak("XML::LibXML compiled without threads!"); |
| 1681 |
|
| #endif |
| 1682 |
|
| |
| 1683 |
|
| SV* |
| 1684 |
|
| _parse_string(self, string, dir = &PL_sv_undef) |
| 1685 |
|
| SV * self |
| 1686 |
|
| SV * string |
| 1687 |
|
| SV * dir |
| 1688 |
|
| PREINIT: |
| 1689 |
360 |
| char * directory = NULL; |
| 1690 |
|
| STRLEN len; |
| 1691 |
|
| const char * ptr; |
| 1692 |
|
| HV * real_obj; |
| 1693 |
|
| int well_formed; |
| 1694 |
|
| int valid; |
| 1695 |
|
| int validate; |
| 1696 |
|
| xmlDocPtr real_doc; |
| 1697 |
360 |
| int recover = 0; |
| 1698 |
360 |
| PREINIT_SAVED_ERROR |
| 1699 |
|
| INIT: |
| 1700 |
360 |
▶ | if (SvPOK(dir)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(dir)) { |
1 |
359 |
360 |
|
| 1701 |
1 |
| directory = SvPV(dir, len); |
| 1702 |
1 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
1 |
1 |
|
| 1703 |
0 |
| directory = NULL; |
| 1704 |
|
| } |
| 1705 |
|
| } |
| 1706 |
|
| /* If string is a reference to a string - dereference it. |
| 1707 |
|
| * See: https://rt.cpan.org/Ticket/Display.html?id=64051 (broke it) |
| 1708 |
|
| * https://rt.cpan.org/Ticket/Display.html?id=77864 (fixed it) */ |
| 1709 |
360 |
▶ | if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
3 |
357 |
360 |
| if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
2 |
1 |
3 |
|
| 1710 |
2 |
| string = SvRV(string); |
| 1711 |
|
| } |
| 1712 |
360 |
| ptr = SvPV_const(string, len); |
| 1713 |
360 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
360 |
360 |
|
| 1714 |
0 |
| croak("Empty string\n"); |
| 1715 |
|
| XSRETURN_UNDEF; |
| 1716 |
|
| } |
| 1717 |
|
| CODE: |
| 1718 |
360 |
| RETVAL = &PL_sv_undef; |
| 1719 |
360 |
| INIT_ERROR_HANDLER; |
| 1720 |
|
| { |
| 1721 |
360 |
| xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(ptr, len); |
| 1722 |
360 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
360 |
360 |
|
| 1723 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1724 |
0 |
| REPORT_ERROR(1); |
| 1725 |
0 |
| croak("Could not create memory parser context!\n"); |
| 1726 |
|
| } |
| 1727 |
|
| xs_warn( "context created\n"); |
| 1728 |
360 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 1729 |
360 |
| recover = LibXML_get_recover(real_obj); |
| 1730 |
|
| |
| 1731 |
|
| |
| 1732 |
360 |
▶ | if ( directory != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( directory != NULL ) { |
1 |
359 |
360 |
|
| 1733 |
1 |
| ctxt->directory = directory; |
| 1734 |
|
| } |
| 1735 |
360 |
| ctxt->_private = (void*)self; |
| 1736 |
|
| |
| 1737 |
|
| /* make libxml2-2.6 display line number on error */ |
| 1738 |
360 |
▶ | if ( ctxt->input != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt->input != NULL ) { |
360 |
0 |
360 |
|
| 1739 |
360 |
▶ | if (directory != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (directory != NULL) { |
1 |
359 |
360 |
|
| 1740 |
1 |
| ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) directory); |
| 1741 |
|
| } else { |
| 1742 |
359 |
| ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) ""); |
| 1743 |
|
| } |
| 1744 |
|
| } |
| 1745 |
|
| |
| 1746 |
|
| xs_warn( "context initialized\n" ); |
| 1747 |
|
| |
| 1748 |
360 |
| xmlParseDocument(ctxt); |
| 1749 |
|
| xs_warn( "document parsed \n"); |
| 1750 |
|
| |
| 1751 |
359 |
| ctxt->directory = NULL; |
| 1752 |
359 |
| well_formed = ctxt->wellFormed; |
| 1753 |
359 |
| valid = ctxt->valid; |
| 1754 |
359 |
| validate = ctxt->validate; |
| 1755 |
359 |
| real_doc = ctxt->myDoc; |
| 1756 |
359 |
| ctxt->myDoc = NULL; |
| 1757 |
359 |
| xmlFreeParserCtxt(ctxt); |
| 1758 |
|
| } |
| 1759 |
359 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
359 |
0 |
359 |
|
| 1760 |
359 |
▶ | if (real_doc->URL != NULL) { /* free "" assigned above */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (real_doc->URL != NULL) { /* free "" assigned above */ |
359 |
0 |
359 |
|
| 1761 |
359 |
| xmlFree((char*) real_doc->URL); |
| 1762 |
359 |
| real_doc->URL = NULL; |
| 1763 |
|
| } |
| 1764 |
|
| |
| 1765 |
359 |
▶ | if ( directory == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( directory == NULL ) { |
358 |
1 |
359 |
|
| 1766 |
358 |
| SV * newURI = sv_2mortal(newSVpvf("unknown-%p", (void*)real_doc)); |
| 1767 |
358 |
| real_doc->URL = xmlStrdup((const xmlChar*)SvPV_nolen(newURI)); |
| 1768 |
|
| } else { |
| 1769 |
1 |
| real_doc->URL = xmlStrdup((const xmlChar*)directory); |
| 1770 |
|
| } |
| 1771 |
359 |
▶ | if ( ! LibXML_will_die_ctx(saved_error, recover) && |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
270 |
89 |
359 |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
269 |
1 |
270 |
|
| 1772 |
269 |
▶ | (recover || ( well_formed && |
Branch: 2 branches
| Branch | True | False | Total |
| (recover || ( well_formed && |
269 |
0 |
269 |
| (recover || ( well_formed && |
0 |
269 |
269 |
|
| 1773 |
|
| ( !validate |
| 1774 |
0 |
▶ | || ( valid || ( real_doc->intSubset == NULL |
Branch: 2 branches
| Branch | True | False | Total |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
|
| 1775 |
0 |
▶ | && real_doc->extSubset == NULL )))))) { |
Branch: 1 branch
| Branch | True | False | Total |
| && real_doc->extSubset == NULL )))))) { |
0 |
0 |
0 |
|
| 1776 |
270 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 1777 |
|
| } else { |
| 1778 |
89 |
| xmlFreeDoc(real_doc); |
| 1779 |
89 |
| real_doc=NULL; |
| 1780 |
|
| } |
| 1781 |
|
| } |
| 1782 |
|
| |
| 1783 |
359 |
| LibXML_cleanup_parser(); |
| 1784 |
359 |
| CLEANUP_ERROR_HANDLER; |
| 1785 |
359 |
| REPORT_ERROR(recover); |
| 1786 |
|
| OUTPUT: |
| 1787 |
|
| RETVAL |
| 1788 |
|
| |
| 1789 |
|
| int |
| 1790 |
|
| _parse_sax_string(self, string) |
| 1791 |
|
| SV * self |
| 1792 |
|
| SV * string |
| 1793 |
|
| PREINIT: |
| 1794 |
|
| STRLEN len; |
| 1795 |
|
| char * ptr; |
| 1796 |
|
| HV * real_obj; |
| 1797 |
37 |
| int recover = 0; |
| 1798 |
37 |
| PREINIT_SAVED_ERROR |
| 1799 |
|
| INIT: |
| 1800 |
37 |
| ptr = SvPV(string, len); |
| 1801 |
37 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
37 |
37 |
|
| 1802 |
0 |
| croak("Empty string\n"); |
| 1803 |
|
| XSRETURN_UNDEF; |
| 1804 |
|
| } |
| 1805 |
|
| CODE: |
| 1806 |
37 |
| RETVAL = 0; |
| 1807 |
37 |
| INIT_ERROR_HANDLER; |
| 1808 |
|
| |
| 1809 |
|
| { |
| 1810 |
37 |
| xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt((const char*)ptr, len); |
| 1811 |
37 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
37 |
37 |
|
| 1812 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1813 |
0 |
▶ | REPORT_ERROR(recover ? recover : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR(recover ? recover : 1); |
0 |
0 |
0 |
|
| 1814 |
0 |
| croak("Could not create memory parser context!\n"); |
| 1815 |
|
| } |
| 1816 |
|
| xs_warn( "context created\n"); |
| 1817 |
37 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 1818 |
37 |
| recover = LibXML_get_recover(real_obj); |
| 1819 |
|
| |
| 1820 |
37 |
| PmmSAXInitContext( ctxt, self, saved_error ); |
| 1821 |
|
| xs_warn( "context initialized \n"); |
| 1822 |
|
| { |
| 1823 |
37 |
| RETVAL = xmlParseDocument(ctxt); |
| 1824 |
|
| xs_warn( "document parsed \n"); |
| 1825 |
|
| } |
| 1826 |
|
| |
| 1827 |
36 |
| PmmSAXCloseContext(ctxt); |
| 1828 |
36 |
| xmlFreeParserCtxt(ctxt); |
| 1829 |
|
| } |
| 1830 |
|
| |
| 1831 |
36 |
| LibXML_cleanup_parser(); |
| 1832 |
36 |
| CLEANUP_ERROR_HANDLER; |
| 1833 |
36 |
| REPORT_ERROR(recover); |
| 1834 |
|
| OUTPUT: |
| 1835 |
|
| RETVAL |
| 1836 |
|
| |
| 1837 |
|
| SV* |
| 1838 |
|
| _parse_fh(self, fh, dir = &PL_sv_undef) |
| 1839 |
|
| SV * self |
| 1840 |
|
| SV * fh |
| 1841 |
|
| SV * dir |
| 1842 |
|
| PREINIT: |
| 1843 |
|
| STRLEN len; |
| 1844 |
9 |
| char * directory = NULL; |
| 1845 |
|
| HV * real_obj; |
| 1846 |
|
| int well_formed; |
| 1847 |
|
| int valid; |
| 1848 |
|
| int validate; |
| 1849 |
|
| xmlDocPtr real_doc; |
| 1850 |
9 |
| int recover = 0; |
| 1851 |
9 |
| PREINIT_SAVED_ERROR |
| 1852 |
|
| INIT: |
| 1853 |
9 |
▶ | if (SvPOK(dir)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(dir)) { |
0 |
9 |
9 |
|
| 1854 |
0 |
| directory = SvPV(dir, len); |
| 1855 |
0 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
0 |
0 |
|
| 1856 |
0 |
| directory = NULL; |
| 1857 |
|
| } |
| 1858 |
|
| } |
| 1859 |
|
| CODE: |
| 1860 |
9 |
| RETVAL = &PL_sv_undef; |
| 1861 |
9 |
| INIT_ERROR_HANDLER; |
| 1862 |
|
| |
| 1863 |
|
| { |
| 1864 |
|
| int read_length; |
| 1865 |
|
| char buffer[1024]; |
| 1866 |
|
| xmlParserCtxtPtr ctxt; |
| 1867 |
|
| |
| 1868 |
9 |
| read_length = LibXML_read_perl(fh, buffer, 4); |
| 1869 |
8 |
▶ | if (read_length <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (read_length <= 0) { |
0 |
8 |
8 |
|
| 1870 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1871 |
0 |
| croak( "Empty Stream\n" ); |
| 1872 |
|
| } |
| 1873 |
|
| |
| 1874 |
8 |
| ctxt = xmlCreatePushParserCtxt(NULL, NULL, buffer, read_length, NULL); |
| 1875 |
8 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
8 |
8 |
|
| 1876 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1877 |
0 |
| REPORT_ERROR(1); |
| 1878 |
0 |
| croak("Could not create xml push parser context!\n"); |
| 1879 |
|
| } |
| 1880 |
|
| xs_warn( "context created\n"); |
| 1881 |
8 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 1882 |
8 |
| recover = LibXML_get_recover(real_obj); |
| 1883 |
|
| #if LIBXML_VERSION > 20600 |
| 1884 |
|
| /* dictionaries not support yet */ |
| 1885 |
8 |
| ctxt->dictNames = 0; |
| 1886 |
|
| #endif |
| 1887 |
8 |
▶ | if ( directory != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( directory != NULL ) { |
0 |
8 |
8 |
|
| 1888 |
0 |
| ctxt->directory = directory; |
| 1889 |
|
| } |
| 1890 |
8 |
| ctxt->_private = (void*)self; |
| 1891 |
|
| xs_warn( "context initialized \n"); |
| 1892 |
|
| { |
| 1893 |
|
| int ret; |
| 1894 |
14 |
▶ | while ((read_length = LibXML_read_perl(fh, buffer, 1024))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((read_length = LibXML_read_perl(fh, buffer, 1024))) { |
7 |
6 |
13 |
|
| 1895 |
7 |
| ret = xmlParseChunk(ctxt, buffer, read_length, 0); |
| 1896 |
7 |
▶ | if ( ret != 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != 0 ) { |
1 |
6 |
7 |
|
| 1897 |
1 |
| break; |
| 1898 |
|
| } |
| 1899 |
|
| } |
| 1900 |
7 |
| ret = xmlParseChunk(ctxt, buffer, 0, 1); |
| 1901 |
|
| xs_warn( "document parsed \n"); |
| 1902 |
|
| } |
| 1903 |
|
| |
| 1904 |
7 |
| ctxt->directory = NULL; |
| 1905 |
7 |
| well_formed = ctxt->wellFormed; |
| 1906 |
7 |
| valid = ctxt->valid; |
| 1907 |
7 |
| validate = ctxt->validate; |
| 1908 |
7 |
| real_doc = ctxt->myDoc; |
| 1909 |
7 |
| ctxt->myDoc = NULL; |
| 1910 |
7 |
| xmlFreeParserCtxt(ctxt); |
| 1911 |
|
| } |
| 1912 |
|
| |
| 1913 |
7 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
7 |
0 |
7 |
|
| 1914 |
|
| |
| 1915 |
7 |
▶ | if ( directory == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( directory == NULL ) { |
7 |
0 |
7 |
|
| 1916 |
7 |
| SV * newURI = sv_2mortal(newSVpvf("unknown-%p", (void*)real_doc)); |
| 1917 |
7 |
| real_doc->URL = xmlStrdup((const xmlChar*)SvPV_nolen(newURI)); |
| 1918 |
|
| } else { |
| 1919 |
0 |
| real_doc->URL = xmlStrdup((const xmlChar*)directory); |
| 1920 |
|
| } |
| 1921 |
|
| |
| 1922 |
7 |
▶ | if ( ! LibXML_will_die_ctx(saved_error, recover) && |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
6 |
1 |
7 |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
6 |
0 |
6 |
|
| 1923 |
6 |
▶ | (recover || ( well_formed && |
Branch: 2 branches
| Branch | True | False | Total |
| (recover || ( well_formed && |
6 |
0 |
6 |
| (recover || ( well_formed && |
0 |
6 |
6 |
|
| 1924 |
|
| ( !validate |
| 1925 |
0 |
▶ | || ( valid || ( real_doc->intSubset == NULL |
Branch: 2 branches
| Branch | True | False | Total |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
|
| 1926 |
0 |
▶ | && real_doc->extSubset == NULL )))))) { |
Branch: 1 branch
| Branch | True | False | Total |
| && real_doc->extSubset == NULL )))))) { |
0 |
0 |
0 |
|
| 1927 |
6 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 1928 |
|
| } else { |
| 1929 |
1 |
| xmlFreeDoc(real_doc); |
| 1930 |
1 |
| real_doc=NULL; |
| 1931 |
|
| } |
| 1932 |
|
| } |
| 1933 |
|
| |
| 1934 |
7 |
| LibXML_cleanup_parser(); |
| 1935 |
7 |
| CLEANUP_ERROR_HANDLER; |
| 1936 |
7 |
| REPORT_ERROR(recover); |
| 1937 |
|
| OUTPUT: |
| 1938 |
|
| RETVAL |
| 1939 |
|
| |
| 1940 |
|
| void |
| 1941 |
|
| _parse_sax_fh(self, fh, dir = &PL_sv_undef) |
| 1942 |
|
| SV * self |
| 1943 |
|
| SV * fh |
| 1944 |
|
| SV * dir |
| 1945 |
|
| PREINIT: |
| 1946 |
|
| STRLEN len; |
| 1947 |
0 |
| char * directory = NULL; |
| 1948 |
|
| HV * real_obj; |
| 1949 |
0 |
| int recover = 0; |
| 1950 |
0 |
| PREINIT_SAVED_ERROR |
| 1951 |
|
| INIT: |
| 1952 |
0 |
▶ | if (SvPOK(dir)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(dir)) { |
0 |
0 |
0 |
|
| 1953 |
0 |
| directory = SvPV(dir, len); |
| 1954 |
0 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
0 |
0 |
|
| 1955 |
0 |
| directory = NULL; |
| 1956 |
|
| } |
| 1957 |
|
| } |
| 1958 |
|
| CODE: |
| 1959 |
0 |
| INIT_ERROR_HANDLER; |
| 1960 |
|
| { |
| 1961 |
|
| int read_length; |
| 1962 |
|
| char buffer[1024]; |
| 1963 |
|
| xmlSAXHandlerPtr sax; |
| 1964 |
|
| xmlParserCtxtPtr ctxt; |
| 1965 |
|
| |
| 1966 |
0 |
| read_length = LibXML_read_perl(fh, buffer, 4); |
| 1967 |
0 |
▶ | if (read_length <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (read_length <= 0) { |
0 |
0 |
0 |
|
| 1968 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1969 |
0 |
| croak( "Empty Stream\n" ); |
| 1970 |
|
| } |
| 1971 |
|
| |
| 1972 |
0 |
| sax = PSaxGetHandler(); |
| 1973 |
0 |
| ctxt = xmlCreatePushParserCtxt(sax, NULL, buffer, read_length, NULL); |
| 1974 |
0 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
0 |
0 |
|
| 1975 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 1976 |
0 |
▶ | REPORT_ERROR(recover ? recover : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR(recover ? recover : 1); |
0 |
0 |
0 |
|
| 1977 |
0 |
| croak("Could not create xml push parser context!\n"); |
| 1978 |
|
| } |
| 1979 |
|
| xs_warn( "context created\n"); |
| 1980 |
0 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 1981 |
0 |
| recover = LibXML_get_recover(real_obj); |
| 1982 |
|
| |
| 1983 |
0 |
▶ | if ( directory != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( directory != NULL ) { |
0 |
0 |
0 |
|
| 1984 |
0 |
| ctxt->directory = directory; |
| 1985 |
|
| } |
| 1986 |
0 |
| PmmSAXInitContext( ctxt, self, saved_error ); |
| 1987 |
|
| xs_warn( "context initialized \n"); |
| 1988 |
|
| |
| 1989 |
|
| { |
| 1990 |
|
| int ret; |
| 1991 |
0 |
▶ | while ((read_length = LibXML_read_perl(fh, buffer, 1024))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((read_length = LibXML_read_perl(fh, buffer, 1024))) { |
0 |
0 |
0 |
|
| 1992 |
0 |
| ret = xmlParseChunk(ctxt, buffer, read_length, 0); |
| 1993 |
0 |
▶ | if ( ret != 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != 0 ) { |
0 |
0 |
0 |
|
| 1994 |
0 |
| break; |
| 1995 |
|
| } |
| 1996 |
|
| } |
| 1997 |
0 |
| ret = xmlParseChunk(ctxt, buffer, 0, 1); |
| 1998 |
|
| xs_warn( "document parsed \n"); |
| 1999 |
|
| } |
| 2000 |
|
| |
| 2001 |
0 |
| ctxt->directory = NULL; |
| 2002 |
0 |
| xmlFree(ctxt->sax); |
| 2003 |
0 |
| ctxt->sax = NULL; |
| 2004 |
0 |
| xmlFree(sax); |
| 2005 |
0 |
| PmmSAXCloseContext(ctxt); |
| 2006 |
0 |
| xmlFreeParserCtxt(ctxt); |
| 2007 |
|
| } |
| 2008 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 2009 |
0 |
| LibXML_cleanup_parser(); |
| 2010 |
0 |
| REPORT_ERROR(recover); |
| 2011 |
|
| |
| 2012 |
|
| SV* |
| 2013 |
|
| _parse_file(self, filename_sv) |
| 2014 |
|
| SV * self |
| 2015 |
|
| SV * filename_sv |
| 2016 |
|
| PREINIT: |
| 2017 |
|
| STRLEN len; |
| 2018 |
|
| char * filename; |
| 2019 |
|
| HV * real_obj; |
| 2020 |
|
| int well_formed; |
| 2021 |
|
| int valid; |
| 2022 |
|
| int validate; |
| 2023 |
|
| xmlDocPtr real_doc; |
| 2024 |
66 |
| int recover = 0; |
| 2025 |
66 |
| PREINIT_SAVED_ERROR |
| 2026 |
|
| INIT: |
| 2027 |
66 |
| filename = SvPV(filename_sv, len); |
| 2028 |
66 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
66 |
66 |
|
| 2029 |
0 |
| croak("Empty filename\n"); |
| 2030 |
|
| XSRETURN_UNDEF; |
| 2031 |
|
| } |
| 2032 |
|
| CODE: |
| 2033 |
66 |
| RETVAL = &PL_sv_undef; |
| 2034 |
66 |
| INIT_ERROR_HANDLER; |
| 2035 |
|
| |
| 2036 |
|
| { |
| 2037 |
66 |
| xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(filename); |
| 2038 |
66 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
1 |
65 |
66 |
|
| 2039 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 2040 |
1 |
| REPORT_ERROR(1); |
| 2041 |
1 |
| croak("Could not create file parser context for file \"%s\": %s\n", |
| 2042 |
|
| filename, strerror(errno)); |
| 2043 |
|
| } |
| 2044 |
|
| xs_warn( "context created\n"); |
| 2045 |
65 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 2046 |
65 |
| recover = LibXML_get_recover(real_obj); |
| 2047 |
|
| |
| 2048 |
65 |
| ctxt->_private = (void*)self; |
| 2049 |
|
| |
| 2050 |
|
| xs_warn( "context initialized\n" ); |
| 2051 |
65 |
| xmlParseDocument(ctxt); |
| 2052 |
|
| xs_warn( "document parsed \n"); |
| 2053 |
|
| |
| 2054 |
65 |
| well_formed = ctxt->wellFormed; |
| 2055 |
65 |
| valid = ctxt->valid; |
| 2056 |
65 |
| validate = ctxt->validate; |
| 2057 |
65 |
| real_doc = ctxt->myDoc; |
| 2058 |
65 |
| ctxt->myDoc = NULL; |
| 2059 |
65 |
| xmlFreeParserCtxt(ctxt); |
| 2060 |
|
| } |
| 2061 |
|
| |
| 2062 |
65 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
65 |
0 |
65 |
|
| 2063 |
65 |
▶ | if ( ! LibXML_will_die_ctx(saved_error, recover) && |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
60 |
5 |
65 |
| if ( ! LibXML_will_die_ctx(saved_error, recover) && |
60 |
0 |
60 |
|
| 2064 |
60 |
▶ | (recover || ( well_formed && |
Branch: 2 branches
| Branch | True | False | Total |
| (recover || ( well_formed && |
60 |
0 |
60 |
| (recover || ( well_formed && |
0 |
60 |
60 |
|
| 2065 |
|
| ( !validate |
| 2066 |
0 |
▶ | || ( valid || ( real_doc->intSubset == NULL |
Branch: 2 branches
| Branch | True | False | Total |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
| || ( valid || ( real_doc->intSubset == NULL |
0 |
0 |
0 |
|
| 2067 |
0 |
▶ | && real_doc->extSubset == NULL )))))) { |
Branch: 1 branch
| Branch | True | False | Total |
| && real_doc->extSubset == NULL )))))) { |
0 |
0 |
0 |
|
| 2068 |
60 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 2069 |
|
| } else { |
| 2070 |
5 |
| xmlFreeDoc(real_doc); |
| 2071 |
5 |
| real_doc=NULL; |
| 2072 |
|
| } |
| 2073 |
|
| } |
| 2074 |
|
| |
| 2075 |
65 |
| LibXML_cleanup_parser(); |
| 2076 |
65 |
| CLEANUP_ERROR_HANDLER; |
| 2077 |
65 |
| REPORT_ERROR(recover); |
| 2078 |
|
| OUTPUT: |
| 2079 |
|
| RETVAL |
| 2080 |
|
| |
| 2081 |
|
| void |
| 2082 |
|
| _parse_sax_file(self, filename_sv) |
| 2083 |
|
| SV * self |
| 2084 |
|
| SV * filename_sv |
| 2085 |
|
| PREINIT: |
| 2086 |
|
| STRLEN len; |
| 2087 |
|
| char * filename; |
| 2088 |
|
| HV * real_obj; |
| 2089 |
1 |
| int recover = 0; |
| 2090 |
1 |
| PREINIT_SAVED_ERROR |
| 2091 |
|
| INIT: |
| 2092 |
1 |
| filename = SvPV(filename_sv, len); |
| 2093 |
1 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
1 |
1 |
|
| 2094 |
0 |
| croak("Empty filename\n"); |
| 2095 |
|
| XSRETURN_UNDEF; |
| 2096 |
|
| } |
| 2097 |
|
| CODE: |
| 2098 |
1 |
| INIT_ERROR_HANDLER; |
| 2099 |
|
| |
| 2100 |
|
| { |
| 2101 |
1 |
| xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(filename); |
| 2102 |
1 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
1 |
1 |
|
| 2103 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 2104 |
0 |
▶ | REPORT_ERROR(recover ? recover : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR(recover ? recover : 1); |
0 |
0 |
0 |
|
| 2105 |
0 |
| croak("Could not create file parser context for file \"%s\": %s\n", |
| 2106 |
|
| filename, strerror(errno)); |
| 2107 |
|
| } |
| 2108 |
|
| xs_warn( "context created\n"); |
| 2109 |
1 |
| real_obj = LibXML_init_parser(self, ctxt); |
| 2110 |
1 |
| recover = LibXML_get_recover(real_obj); |
| 2111 |
|
| |
| 2112 |
1 |
| ctxt->sax = PSaxGetHandler(); |
| 2113 |
1 |
| PmmSAXInitContext( ctxt, self, saved_error ); |
| 2114 |
|
| xs_warn( "context initialized \n"); |
| 2115 |
|
| |
| 2116 |
|
| { |
| 2117 |
1 |
| xmlParseDocument(ctxt); |
| 2118 |
|
| xs_warn( "document parsed \n"); |
| 2119 |
|
| } |
| 2120 |
|
| |
| 2121 |
1 |
| PmmSAXCloseContext(ctxt); |
| 2122 |
1 |
| xmlFreeParserCtxt(ctxt); |
| 2123 |
|
| } |
| 2124 |
|
| |
| 2125 |
1 |
| LibXML_cleanup_parser(); |
| 2126 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 2127 |
1 |
| REPORT_ERROR(recover); |
| 2128 |
|
| |
| 2129 |
|
| SV* |
| 2130 |
|
| _parse_html_string(self, string, svURL, svEncoding, options = 0) |
| 2131 |
|
| SV * self |
| 2132 |
|
| SV * string |
| 2133 |
|
| SV * svURL |
| 2134 |
|
| SV * svEncoding |
| 2135 |
|
| int options |
| 2136 |
|
| PREINIT: |
| 2137 |
|
| STRLEN len; |
| 2138 |
|
| char * ptr; |
| 2139 |
17 |
| char* URL = NULL; |
| 2140 |
17 |
| const char * encoding = NULL; |
| 2141 |
|
| HV * real_obj; |
| 2142 |
|
| htmlDocPtr real_doc; |
| 2143 |
17 |
| int recover = 0; |
| 2144 |
17 |
| PREINIT_SAVED_ERROR |
| 2145 |
|
| INIT: |
| 2146 |
|
| /* If string is a reference to a string - dereference it. |
| 2147 |
|
| * See: https://rt.cpan.org/Ticket/Display.html?id=64051 (broke it) |
| 2148 |
|
| * https://rt.cpan.org/Ticket/Display.html?id=77864 (fixed it) */ |
| 2149 |
17 |
▶ | if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
1 |
16 |
17 |
| if (SvROK(string) && !SvOBJECT(SvRV(string))) { |
1 |
0 |
1 |
|
| 2150 |
1 |
| string = SvRV(string); |
| 2151 |
|
| } |
| 2152 |
17 |
| ptr = SvPV(string, len); |
| 2153 |
17 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
17 |
17 |
|
| 2154 |
0 |
| croak("Empty string\n"); |
| 2155 |
|
| XSRETURN_UNDEF; |
| 2156 |
|
| } |
| 2157 |
17 |
▶ | if (SvOK(svURL)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svURL)) |
2 |
15 |
17 |
|
| 2158 |
2 |
| URL = SvPV_nolen( svURL ); |
| 2159 |
17 |
▶ | if (SvOK(svEncoding)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svEncoding)) |
6 |
11 |
17 |
|
| 2160 |
6 |
| encoding = SvPV_nolen( svEncoding ); |
| 2161 |
|
| CODE: |
| 2162 |
17 |
| RETVAL = &PL_sv_undef; |
| 2163 |
17 |
| INIT_ERROR_HANDLER; |
| 2164 |
17 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2165 |
17 |
▶ | if (encoding == NULL && SvUTF8( string )) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (encoding == NULL && SvUTF8( string )) { |
11 |
6 |
17 |
| if (encoding == NULL && SvUTF8( string )) { |
3 |
8 |
11 |
|
| 2166 |
3 |
| encoding = "UTF-8"; |
| 2167 |
|
| } |
| 2168 |
17 |
▶ | if (options & HTML_PARSE_RECOVER) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (options & HTML_PARSE_RECOVER) { |
13 |
4 |
17 |
|
| 2169 |
13 |
▶ | recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
6 |
7 |
13 |
|
| 2170 |
|
| } |
| 2171 |
|
| #if LIBXML_VERSION >= 20627 |
| 2172 |
17 |
| real_doc = htmlReadDoc((xmlChar*)ptr, URL, encoding, options); |
| 2173 |
|
| #else |
| 2174 |
|
| real_doc = htmlParseDoc((xmlChar*)ptr, encoding); |
| 2175 |
|
| if ( real_doc ) { |
| 2176 |
|
| if (real_doc->URL) xmlFree((xmlChar *)real_doc->URL); |
| 2177 |
|
| if (URL) { |
| 2178 |
|
| real_doc->URL = xmlStrdup((const xmlChar*) URL); |
| 2179 |
|
| } |
| 2180 |
|
| } |
| 2181 |
|
| #endif |
| 2182 |
17 |
▶ | if ( real_doc ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc ) { |
17 |
0 |
17 |
|
| 2183 |
17 |
▶ | if (URL==NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (URL==NULL) { |
15 |
2 |
17 |
|
| 2184 |
15 |
| SV * newURI = sv_2mortal(newSVpvf("unknown-%p", (void*)real_doc)); |
| 2185 |
15 |
| real_doc->URL = xmlStrdup((const xmlChar*)SvPV_nolen(newURI)); |
| 2186 |
|
| } |
| 2187 |
|
| /* This HTML memory parser doesn't use a ctxt; there is no "well-formed" |
| 2188 |
|
| * distinction, and if it manages to parse the HTML, it returns non-null. */ |
| 2189 |
17 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 2190 |
|
| } |
| 2191 |
|
| |
| 2192 |
17 |
| LibXML_cleanup_parser(); |
| 2193 |
17 |
| CLEANUP_ERROR_HANDLER; |
| 2194 |
17 |
| REPORT_ERROR(recover); |
| 2195 |
|
| OUTPUT: |
| 2196 |
|
| RETVAL |
| 2197 |
|
| |
| 2198 |
|
| |
| 2199 |
|
| SV* |
| 2200 |
|
| _parse_html_file(self, filename_sv, svURL, svEncoding, options = 0) |
| 2201 |
|
| SV * self |
| 2202 |
|
| SV * filename_sv |
| 2203 |
|
| SV * svURL |
| 2204 |
|
| SV * svEncoding |
| 2205 |
|
| int options |
| 2206 |
|
| PREINIT: |
| 2207 |
|
| STRLEN len; |
| 2208 |
|
| char * filename; |
| 2209 |
6 |
| char * URL = NULL; |
| 2210 |
6 |
| char * encoding = NULL; |
| 2211 |
|
| HV * real_obj; |
| 2212 |
|
| htmlDocPtr real_doc; |
| 2213 |
6 |
| int recover = 0; |
| 2214 |
6 |
| PREINIT_SAVED_ERROR |
| 2215 |
|
| INIT: |
| 2216 |
6 |
| filename = SvPV(filename_sv, len); |
| 2217 |
6 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
6 |
6 |
|
| 2218 |
0 |
| croak("Empty filename\n"); |
| 2219 |
|
| XSRETURN_UNDEF; |
| 2220 |
|
| } |
| 2221 |
6 |
▶ | if (SvOK(svURL)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svURL)) |
1 |
5 |
6 |
|
| 2222 |
1 |
| URL = SvPV_nolen( svURL ); |
| 2223 |
6 |
▶ | if (SvOK(svEncoding)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svEncoding)) |
2 |
4 |
6 |
|
| 2224 |
2 |
| encoding = SvPV_nolen( svEncoding ); |
| 2225 |
|
| CODE: |
| 2226 |
6 |
| RETVAL = &PL_sv_undef; |
| 2227 |
6 |
| INIT_ERROR_HANDLER; |
| 2228 |
6 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2229 |
6 |
▶ | if (options & HTML_PARSE_RECOVER) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (options & HTML_PARSE_RECOVER) { |
3 |
3 |
6 |
|
| 2230 |
3 |
▶ | recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
0 |
3 |
3 |
|
| 2231 |
|
| } |
| 2232 |
|
| #if LIBXML_VERSION >= 20627 |
| 2233 |
6 |
| real_doc = htmlReadFile((const char *)filename, |
| 2234 |
|
| encoding, |
| 2235 |
|
| options); |
| 2236 |
|
| #else |
| 2237 |
|
| real_doc = htmlParseFile((const char *)filename, encoding); |
| 2238 |
|
| #endif |
| 2239 |
6 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
6 |
0 |
6 |
|
| 2240 |
|
| |
| 2241 |
|
| /* This HTML file parser doesn't use a ctxt; there is no "well-formed" |
| 2242 |
|
| * distinction, and if it manages to parse the HTML, it returns non-null. */ |
| 2243 |
6 |
▶ | if (URL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (URL) { |
1 |
5 |
6 |
|
| 2244 |
1 |
▶ | if (real_doc->URL) xmlFree((xmlChar*) real_doc->URL); |
Branch: 1 branch
| Branch | True | False | Total |
| if (real_doc->URL) xmlFree((xmlChar*) real_doc->URL); |
1 |
0 |
1 |
|
| 2245 |
1 |
| real_doc->URL = xmlStrdup((const xmlChar*) URL); |
| 2246 |
|
| } |
| 2247 |
6 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 2248 |
|
| |
| 2249 |
|
| } |
| 2250 |
6 |
| CLEANUP_ERROR_HANDLER; |
| 2251 |
6 |
| LibXML_cleanup_parser(); |
| 2252 |
6 |
| REPORT_ERROR(recover); |
| 2253 |
|
| OUTPUT: |
| 2254 |
|
| RETVAL |
| 2255 |
|
| |
| 2256 |
|
| SV* |
| 2257 |
|
| _parse_html_fh(self, fh, svURL, svEncoding, options = 0) |
| 2258 |
|
| SV * self |
| 2259 |
|
| SV * fh |
| 2260 |
|
| SV * svURL |
| 2261 |
|
| SV * svEncoding |
| 2262 |
|
| int options |
| 2263 |
|
| PREINIT: |
| 2264 |
|
| HV * real_obj; |
| 2265 |
|
| htmlDocPtr real_doc; |
| 2266 |
4 |
| int recover = 0; |
| 2267 |
4 |
| char * URL = NULL; |
| 2268 |
4 |
| PREINIT_SAVED_ERROR |
| 2269 |
|
| #if LIBXML_VERSION >= 20627 |
| 2270 |
4 |
▶ | char * encoding = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| char * encoding = NULL; |
0 |
4 |
4 |
|
| 2271 |
|
| #else |
| 2272 |
|
| xmlCharEncoding enc = XML_CHAR_ENCODING_NONE; |
| 2273 |
|
| #endif |
| 2274 |
|
| INIT: |
| 2275 |
4 |
▶ | if (SvOK(svURL)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svURL)) |
1 |
3 |
4 |
|
| 2276 |
1 |
| URL = SvPV_nolen( svURL ); |
| 2277 |
|
| #if LIBXML_VERSION >= 20627 |
| 2278 |
4 |
▶ | if (SvOK(svEncoding)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(svEncoding)) |
2 |
2 |
4 |
|
| 2279 |
2 |
| encoding = SvPV_nolen( svEncoding ); |
| 2280 |
|
| #else |
| 2281 |
|
| if (SvOK(svEncoding)) |
| 2282 |
|
| enc = xmlParseCharEncoding(SvPV_nolen( svEncoding )); |
| 2283 |
|
| #endif |
| 2284 |
|
| CODE: |
| 2285 |
4 |
| RETVAL = &PL_sv_undef; |
| 2286 |
4 |
| INIT_ERROR_HANDLER; |
| 2287 |
4 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2288 |
4 |
▶ | if (options & HTML_PARSE_RECOVER) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (options & HTML_PARSE_RECOVER) { |
3 |
1 |
4 |
|
| 2289 |
3 |
▶ | recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1); |
0 |
3 |
3 |
|
| 2290 |
|
| } |
| 2291 |
|
| #if LIBXML_VERSION >= 20627 |
| 2292 |
|
| |
| 2293 |
4 |
| real_doc = htmlReadIO((xmlInputReadCallback) LibXML_read_perl, |
| 2294 |
|
| NULL, |
| 2295 |
|
| (void *) fh, |
| 2296 |
|
| URL, |
| 2297 |
|
| encoding, |
| 2298 |
|
| options); |
| 2299 |
|
| #else /* LIBXML_VERSION >= 20627 */ |
| 2300 |
|
| { |
| 2301 |
|
| int read_length; |
| 2302 |
|
| int well_formed; |
| 2303 |
|
| char buffer[1024]; |
| 2304 |
|
| htmlParserCtxtPtr ctxt; |
| 2305 |
|
| |
| 2306 |
|
| read_length = LibXML_read_perl(fh, buffer, 4); |
| 2307 |
|
| if (read_length <= 0) { |
| 2308 |
|
| CLEANUP_ERROR_HANDLER; |
| 2309 |
|
| croak( "Empty Stream\n" ); |
| 2310 |
|
| } |
| 2311 |
|
| ctxt = htmlCreatePushParserCtxt(NULL, NULL, buffer, read_length, |
| 2312 |
|
| URL, enc); |
| 2313 |
|
| if (ctxt == NULL) { |
| 2314 |
|
| CLEANUP_ERROR_HANDLER; |
| 2315 |
|
| REPORT_ERROR(recover ? recover : 1); |
| 2316 |
|
| croak("Could not create html push parser context!\n"); |
| 2317 |
|
| } |
| 2318 |
|
| ctxt->_private = (void*)self; |
| 2319 |
|
| { |
| 2320 |
|
| int ret; |
| 2321 |
|
| while ((read_length = LibXML_read_perl(fh, buffer, 1024))) { |
| 2322 |
|
| ret = htmlParseChunk(ctxt, buffer, read_length, 0); |
| 2323 |
|
| if ( ret != 0 ) { |
| 2324 |
|
| break; |
| 2325 |
|
| } |
| 2326 |
|
| } |
| 2327 |
|
| ret = htmlParseChunk(ctxt, buffer, 0, 1); |
| 2328 |
|
| } |
| 2329 |
|
| well_formed = ctxt->wellFormed; |
| 2330 |
|
| real_doc = ctxt->myDoc; |
| 2331 |
|
| ctxt->myDoc = NULL; |
| 2332 |
|
| htmlFreeParserCtxt(ctxt); |
| 2333 |
|
| } |
| 2334 |
|
| #endif /* LIBXML_VERSION >= 20627 */ |
| 2335 |
4 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
4 |
0 |
4 |
|
| 2336 |
4 |
▶ | if (real_doc->URL) xmlFree((xmlChar*) real_doc->URL); |
Branch: 1 branch
| Branch | True | False | Total |
| if (real_doc->URL) xmlFree((xmlChar*) real_doc->URL); |
1 |
3 |
4 |
|
| 2337 |
4 |
▶ | if (URL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (URL) { |
1 |
3 |
4 |
|
| 2338 |
1 |
| real_doc->URL = xmlStrdup((const xmlChar*) URL); |
| 2339 |
|
| } else { |
| 2340 |
3 |
| SV * newURI = sv_2mortal(newSVpvf("unknown-%p", (void*)real_doc)); |
| 2341 |
3 |
| real_doc->URL = xmlStrdup((const xmlChar*)SvPV_nolen(newURI)); |
| 2342 |
|
| } |
| 2343 |
|
| |
| 2344 |
4 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 2345 |
|
| } |
| 2346 |
|
| |
| 2347 |
4 |
| LibXML_cleanup_parser(); |
| 2348 |
4 |
| CLEANUP_ERROR_HANDLER; |
| 2349 |
4 |
| REPORT_ERROR(recover); |
| 2350 |
|
| OUTPUT: |
| 2351 |
|
| RETVAL |
| 2352 |
|
| |
| 2353 |
|
| SV* |
| 2354 |
|
| _parse_xml_chunk(self, svchunk, enc = &PL_sv_undef) |
| 2355 |
|
| SV * self |
| 2356 |
|
| SV * svchunk |
| 2357 |
|
| SV * enc |
| 2358 |
|
| PREINIT: |
| 2359 |
|
| STRLEN len; |
| 2360 |
43 |
| const char * encoding = "UTF-8"; |
| 2361 |
|
| HV * real_obj; |
| 2362 |
43 |
| int recover = 0; |
| 2363 |
|
| xmlChar * chunk; |
| 2364 |
43 |
| xmlNodePtr rv = NULL; |
| 2365 |
43 |
| PREINIT_SAVED_ERROR |
| 2366 |
|
| INIT: |
| 2367 |
43 |
▶ | if (SvPOK(enc)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(enc)) { |
0 |
43 |
43 |
|
| 2368 |
0 |
| encoding = SvPV(enc, len); |
| 2369 |
0 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
0 |
0 |
|
| 2370 |
0 |
| encoding = "UTF-8"; |
| 2371 |
|
| } |
| 2372 |
|
| } |
| 2373 |
|
| CODE: |
| 2374 |
43 |
| RETVAL = &PL_sv_undef; |
| 2375 |
43 |
| INIT_ERROR_HANDLER; |
| 2376 |
43 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2377 |
|
| |
| 2378 |
43 |
| chunk = Sv2C(svchunk, (const xmlChar*)encoding); |
| 2379 |
|
| |
| 2380 |
43 |
▶ | if ( chunk != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( chunk != NULL ) { |
43 |
0 |
43 |
|
| 2381 |
43 |
| recover = LibXML_get_recover(real_obj); |
| 2382 |
|
| |
| 2383 |
43 |
| rv = domReadWellBalancedString( NULL, chunk, recover ); |
| 2384 |
|
| |
| 2385 |
43 |
▶ | if ( rv != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rv != NULL ) { |
35 |
8 |
43 |
|
| 2386 |
35 |
| xmlNodePtr fragment= NULL; |
| 2387 |
35 |
| xmlNodePtr rv_end = NULL; |
| 2388 |
|
| |
| 2389 |
|
| /* now we append the nodelist to a document |
| 2390 |
|
| fragment which is unbound to a Document!!!! */ |
| 2391 |
|
| |
| 2392 |
|
| /* step 1: create the fragment */ |
| 2393 |
35 |
| fragment = xmlNewDocFragment( NULL ); |
| 2394 |
35 |
| RETVAL = LibXML_NodeToSv(real_obj, fragment); |
| 2395 |
|
| |
| 2396 |
|
| /* step 2: set the node list to the fragment */ |
| 2397 |
35 |
| fragment->children = rv; |
| 2398 |
35 |
| rv_end = rv; |
| 2399 |
60 |
▶ | while ( rv_end->next != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( rv_end->next != NULL ) { |
25 |
35 |
60 |
|
| 2400 |
25 |
| rv_end->parent = fragment; |
| 2401 |
25 |
| rv_end = rv_end->next; |
| 2402 |
|
| } |
| 2403 |
|
| /* the following line is important, otherwise we'll have |
| 2404 |
|
| occasional segmentation faults |
| 2405 |
|
| */ |
| 2406 |
35 |
| rv_end->parent = fragment; |
| 2407 |
35 |
| fragment->last = rv_end; |
| 2408 |
|
| } |
| 2409 |
|
| |
| 2410 |
|
| /* free the chunk we created */ |
| 2411 |
43 |
| xmlFree( chunk ); |
| 2412 |
|
| } |
| 2413 |
|
| |
| 2414 |
43 |
| LibXML_cleanup_parser(); |
| 2415 |
43 |
| CLEANUP_ERROR_HANDLER; |
| 2416 |
43 |
| REPORT_ERROR(recover); |
| 2417 |
|
| |
| 2418 |
35 |
▶ | if (rv == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv == NULL) { |
0 |
35 |
35 |
|
| 2419 |
0 |
| croak("_parse_xml_chunk: chunk parsing failed\n"); |
| 2420 |
|
| } |
| 2421 |
|
| OUTPUT: |
| 2422 |
|
| RETVAL |
| 2423 |
|
| |
| 2424 |
|
| void |
| 2425 |
|
| _parse_sax_xml_chunk(self, svchunk, enc = &PL_sv_undef) |
| 2426 |
|
| SV * self |
| 2427 |
|
| SV * svchunk |
| 2428 |
|
| SV * enc |
| 2429 |
|
| PREINIT: |
| 2430 |
|
| STRLEN len; |
| 2431 |
|
| char * ptr; |
| 2432 |
29 |
| const char * encoding = "UTF-8"; |
| 2433 |
|
| HV * real_obj; |
| 2434 |
29 |
| int recover = 0; |
| 2435 |
|
| xmlChar * chunk; |
| 2436 |
29 |
| int retCode = -1; |
| 2437 |
29 |
| xmlNodePtr nodes = NULL; |
| 2438 |
29 |
| xmlSAXHandlerPtr handler = NULL; |
| 2439 |
29 |
| PREINIT_SAVED_ERROR |
| 2440 |
|
| INIT: |
| 2441 |
29 |
▶ | if (SvPOK(enc)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(enc)) { |
0 |
29 |
29 |
|
| 2442 |
0 |
| encoding = SvPV(enc, len); |
| 2443 |
0 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
0 |
0 |
|
| 2444 |
0 |
| encoding = "UTF-8"; |
| 2445 |
|
| } |
| 2446 |
|
| } |
| 2447 |
29 |
| ptr = SvPV(svchunk, len); |
| 2448 |
29 |
▶ | if (len <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len <= 0) { |
0 |
29 |
29 |
|
| 2449 |
0 |
| croak("Empty string\n"); |
| 2450 |
|
| } |
| 2451 |
|
| CODE: |
| 2452 |
29 |
| INIT_ERROR_HANDLER; |
| 2453 |
|
| |
| 2454 |
29 |
| chunk = Sv2C(svchunk, (const xmlChar*)encoding); |
| 2455 |
|
| |
| 2456 |
29 |
▶ | if ( chunk != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( chunk != NULL ) { |
29 |
0 |
29 |
|
| 2457 |
29 |
| xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt((const char*)ptr, len); |
| 2458 |
29 |
▶ | if (ctxt == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) { |
0 |
29 |
29 |
|
| 2459 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 2460 |
0 |
▶ | REPORT_ERROR(recover ? recover : 1); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR(recover ? recover : 1); |
0 |
0 |
0 |
|
| 2461 |
0 |
| croak("Could not create memory parser context!\n"); |
| 2462 |
|
| } |
| 2463 |
|
| xs_warn( "context created\n"); |
| 2464 |
29 |
| real_obj = LibXML_init_parser(self,ctxt); |
| 2465 |
29 |
| recover = LibXML_get_recover(real_obj); |
| 2466 |
|
| |
| 2467 |
29 |
| PmmSAXInitContext( ctxt, self, saved_error ); |
| 2468 |
29 |
| handler = PSaxGetHandler(); |
| 2469 |
|
| |
| 2470 |
29 |
| retCode = xmlParseBalancedChunkMemory( NULL, |
| 2471 |
|
| handler, |
| 2472 |
|
| ctxt, |
| 2473 |
|
| 0, |
| 2474 |
|
| chunk, |
| 2475 |
|
| &nodes ); |
| 2476 |
|
| |
| 2477 |
29 |
| xmlFree( handler ); |
| 2478 |
29 |
| PmmSAXCloseContext(ctxt); |
| 2479 |
29 |
| xmlFreeParserCtxt(ctxt); |
| 2480 |
|
| |
| 2481 |
|
| /* free the chunk we created */ |
| 2482 |
29 |
| xmlFree( chunk ); |
| 2483 |
|
| } |
| 2484 |
|
| |
| 2485 |
29 |
| LibXML_cleanup_parser(); |
| 2486 |
29 |
| CLEANUP_ERROR_HANDLER; |
| 2487 |
29 |
| REPORT_ERROR(recover); |
| 2488 |
|
| |
| 2489 |
29 |
▶ | if (retCode == -1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (retCode == -1) { |
0 |
29 |
29 |
|
| 2490 |
0 |
| croak("_parse_sax_xml_chunk: chunk parsing failed\n"); |
| 2491 |
|
| } |
| 2492 |
|
| |
| 2493 |
|
| int |
| 2494 |
|
| _processXIncludes(self, doc, options=0) |
| 2495 |
|
| SV * self |
| 2496 |
|
| SV * doc |
| 2497 |
|
| int options |
| 2498 |
|
| PREINIT: |
| 2499 |
|
| xmlDocPtr real_doc; |
| 2500 |
|
| HV * real_obj; |
| 2501 |
22 |
| int recover = 0; |
| 2502 |
22 |
| PREINIT_SAVED_ERROR |
| 2503 |
|
| INIT: |
| 2504 |
22 |
| real_doc = (xmlDocPtr) PmmSvNode(doc); |
| 2505 |
22 |
▶ | if (real_doc == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (real_doc == NULL) { |
2 |
20 |
22 |
|
| 2506 |
2 |
| croak("No document to process!\n"); |
| 2507 |
|
| XSRETURN_UNDEF; |
| 2508 |
|
| } |
| 2509 |
|
| CODE: |
| 2510 |
20 |
| RETVAL = 0; |
| 2511 |
20 |
| INIT_ERROR_HANDLER; |
| 2512 |
20 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2513 |
20 |
| recover = LibXML_get_recover(real_obj); |
| 2514 |
|
| |
| 2515 |
20 |
| RETVAL = xmlXIncludeProcessFlags(real_doc,options); |
| 2516 |
|
| |
| 2517 |
20 |
| LibXML_cleanup_parser(); |
| 2518 |
20 |
| CLEANUP_ERROR_HANDLER; |
| 2519 |
20 |
| REPORT_ERROR(recover); |
| 2520 |
|
| |
| 2521 |
18 |
▶ | if ( RETVAL < 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL < 0 ) { |
0 |
18 |
18 |
|
| 2522 |
0 |
| croak( "unknown error during XInclude processing\n" ); |
| 2523 |
|
| XSRETURN_UNDEF; |
| 2524 |
18 |
▶ | } else if ( RETVAL == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if ( RETVAL == 0 ) { |
1 |
17 |
18 |
|
| 2525 |
1 |
| RETVAL = 1; |
| 2526 |
|
| } |
| 2527 |
|
| OUTPUT: |
| 2528 |
|
| RETVAL |
| 2529 |
|
| |
| 2530 |
|
| SV* |
| 2531 |
|
| _start_push(self, with_sax=0) |
| 2532 |
|
| SV * self |
| 2533 |
|
| int with_sax |
| 2534 |
|
| PREINIT: |
| 2535 |
|
| HV * real_obj; |
| 2536 |
77 |
| int recover = 0; |
| 2537 |
77 |
| xmlParserCtxtPtr ctxt = NULL; |
| 2538 |
77 |
| PREINIT_SAVED_ERROR |
| 2539 |
|
| CODE: |
| 2540 |
77 |
| RETVAL = &PL_sv_undef; |
| 2541 |
77 |
| INIT_ERROR_HANDLER; |
| 2542 |
|
| |
| 2543 |
|
| /* create empty context */ |
| 2544 |
77 |
| ctxt = xmlCreatePushParserCtxt( NULL, NULL, NULL, 0, NULL ); |
| 2545 |
77 |
| real_obj = LibXML_init_parser(self,ctxt); |
| 2546 |
77 |
| recover = LibXML_get_recover(real_obj); |
| 2547 |
77 |
▶ | if ( with_sax == 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( with_sax == 1 ) { |
36 |
41 |
77 |
|
| 2548 |
36 |
| PmmSAXInitContext( ctxt, self, saved_error ); |
| 2549 |
|
| } |
| 2550 |
|
| |
| 2551 |
77 |
| RETVAL = PmmContextSv( ctxt ); |
| 2552 |
|
| |
| 2553 |
77 |
| LibXML_cleanup_parser(); |
| 2554 |
77 |
| CLEANUP_ERROR_HANDLER; |
| 2555 |
77 |
| REPORT_ERROR(recover); |
| 2556 |
|
| OUTPUT: |
| 2557 |
|
| RETVAL |
| 2558 |
|
| |
| 2559 |
|
| int |
| 2560 |
|
| _push(self, pctxt, data) |
| 2561 |
|
| SV * self |
| 2562 |
|
| SV * pctxt |
| 2563 |
|
| SV * data |
| 2564 |
|
| PREINIT: |
| 2565 |
|
| HV * real_obj; |
| 2566 |
301 |
| int recover = 0; |
| 2567 |
301 |
| xmlParserCtxtPtr ctxt = NULL; |
| 2568 |
301 |
| STRLEN len = 0; |
| 2569 |
301 |
| char * chunk = NULL; |
| 2570 |
301 |
| PREINIT_SAVED_ERROR |
| 2571 |
|
| INIT: |
| 2572 |
301 |
| ctxt = PmmSvContext( pctxt ); |
| 2573 |
301 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
301 |
301 |
|
| 2574 |
0 |
| croak( "parser context already freed\n" ); |
| 2575 |
0 |
| XSRETURN_UNDEF; |
| 2576 |
|
| } |
| 2577 |
301 |
▶ | if ( data == &PL_sv_undef ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data == &PL_sv_undef ) { |
0 |
301 |
301 |
|
| 2578 |
0 |
| XSRETURN_UNDEF; |
| 2579 |
|
| } |
| 2580 |
301 |
| chunk = SvPV( data, len ); |
| 2581 |
301 |
▶ | if ( len <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( len <= 0 ) { |
0 |
301 |
301 |
|
| 2582 |
|
| xs_warn( "empty string" ); |
| 2583 |
0 |
| XSRETURN_UNDEF; |
| 2584 |
|
| } |
| 2585 |
|
| CODE: |
| 2586 |
301 |
| RETVAL = 0; |
| 2587 |
301 |
| INIT_ERROR_HANDLER; |
| 2588 |
301 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2589 |
301 |
| recover = LibXML_get_recover(real_obj); |
| 2590 |
|
| |
| 2591 |
301 |
| xmlParseChunk(ctxt, (const char *)chunk, len, 0); |
| 2592 |
|
| |
| 2593 |
301 |
| LibXML_cleanup_parser(); |
| 2594 |
301 |
| CLEANUP_ERROR_HANDLER; |
| 2595 |
301 |
| REPORT_ERROR(recover); |
| 2596 |
|
| |
| 2597 |
300 |
▶ | if ( ctxt->wellFormed == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt->wellFormed == 0 ) { |
7 |
293 |
300 |
|
| 2598 |
7 |
| croak( "XML not well-formed in xmlParseChunk\n" ); |
| 2599 |
|
| XSRETURN_UNDEF; |
| 2600 |
|
| } |
| 2601 |
293 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
291 |
2 |
293 |
|
| 2602 |
|
| OUTPUT: |
| 2603 |
|
| RETVAL |
| 2604 |
|
| |
| 2605 |
|
| SV* |
| 2606 |
|
| _end_push(self, pctxt, restore) |
| 2607 |
|
| SV * self |
| 2608 |
|
| SV * pctxt |
| 2609 |
|
| int restore |
| 2610 |
|
| PREINIT: |
| 2611 |
|
| HV * real_obj; |
| 2612 |
|
| int well_formed; |
| 2613 |
40 |
| xmlParserCtxtPtr ctxt = NULL; |
| 2614 |
40 |
| xmlDocPtr real_doc = NULL; |
| 2615 |
40 |
| PREINIT_SAVED_ERROR |
| 2616 |
|
| INIT: |
| 2617 |
40 |
| ctxt = PmmSvContext( pctxt ); |
| 2618 |
40 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
40 |
40 |
|
| 2619 |
0 |
| croak( "parser context already freed\n" ); |
| 2620 |
|
| XSRETURN_UNDEF; |
| 2621 |
|
| } |
| 2622 |
|
| CODE: |
| 2623 |
40 |
| RETVAL = &PL_sv_undef; |
| 2624 |
40 |
| INIT_ERROR_HANDLER; |
| 2625 |
40 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2626 |
|
| |
| 2627 |
40 |
| xmlParseChunk(ctxt, "", 0, 1); /* finish the parse */ |
| 2628 |
|
| xs_warn( "Finished with push parser\n" ); |
| 2629 |
|
| |
| 2630 |
40 |
| well_formed = ctxt->wellFormed; |
| 2631 |
40 |
| real_doc = ctxt->myDoc; |
| 2632 |
40 |
| ctxt->myDoc = NULL; |
| 2633 |
40 |
| xmlFreeParserCtxt(ctxt); |
| 2634 |
40 |
| PmmNODE( SvPROXYNODE( pctxt ) ) = NULL; |
| 2635 |
|
| |
| 2636 |
40 |
▶ | if ( real_doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc != NULL ) { |
40 |
0 |
40 |
|
| 2637 |
40 |
▶ | if ( restore || well_formed ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( restore || well_formed ) { |
39 |
1 |
40 |
| if ( restore || well_formed ) { |
38 |
1 |
39 |
|
| 2638 |
39 |
| RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) ); |
| 2639 |
|
| } else { |
| 2640 |
1 |
| xmlFreeDoc(real_doc); |
| 2641 |
1 |
| real_doc = NULL; |
| 2642 |
|
| } |
| 2643 |
|
| } |
| 2644 |
|
| |
| 2645 |
40 |
| LibXML_cleanup_parser(); |
| 2646 |
40 |
| CLEANUP_ERROR_HANDLER; |
| 2647 |
40 |
| REPORT_ERROR(restore); |
| 2648 |
|
| |
| 2649 |
39 |
▶ | if ( real_doc == NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if ( real_doc == NULL ){ |
0 |
39 |
39 |
|
| 2650 |
0 |
| croak( "no document found!\n" ); |
| 2651 |
|
| XSRETURN_UNDEF; |
| 2652 |
|
| } |
| 2653 |
|
| OUTPUT: |
| 2654 |
|
| RETVAL |
| 2655 |
|
| |
| 2656 |
|
| void |
| 2657 |
|
| _end_sax_push(self, pctxt) |
| 2658 |
|
| SV * self |
| 2659 |
|
| SV * pctxt |
| 2660 |
|
| PREINIT: |
| 2661 |
|
| HV * real_obj; |
| 2662 |
36 |
| xmlParserCtxtPtr ctxt = NULL; |
| 2663 |
36 |
| PREINIT_SAVED_ERROR |
| 2664 |
|
| INIT: |
| 2665 |
36 |
| ctxt = PmmSvContext( pctxt ); |
| 2666 |
36 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
36 |
36 |
|
| 2667 |
0 |
| croak( "parser context already freed\n" ); |
| 2668 |
|
| } |
| 2669 |
|
| CODE: |
| 2670 |
36 |
| INIT_ERROR_HANDLER; |
| 2671 |
36 |
| real_obj = LibXML_init_parser(self,NULL); |
| 2672 |
|
| |
| 2673 |
36 |
| xmlParseChunk(ctxt, "", 0, 1); /* finish the parse */ |
| 2674 |
|
| xs_warn( "Finished with SAX push parser\n" ); |
| 2675 |
|
| |
| 2676 |
36 |
| xmlFree(ctxt->sax); |
| 2677 |
36 |
| ctxt->sax = NULL; |
| 2678 |
36 |
| PmmSAXCloseContext(ctxt); |
| 2679 |
36 |
| xmlFreeParserCtxt(ctxt); |
| 2680 |
36 |
| PmmNODE( SvPROXYNODE( pctxt ) ) = NULL; |
| 2681 |
|
| |
| 2682 |
36 |
| LibXML_cleanup_parser(); |
| 2683 |
36 |
| CLEANUP_ERROR_HANDLER; |
| 2684 |
36 |
| REPORT_ERROR(0); |
| 2685 |
|
| |
| 2686 |
|
| SV* |
| 2687 |
|
| import_GDOME( CLASS, sv_gdome, deep=1 ) |
| 2688 |
|
| SV * sv_gdome |
| 2689 |
|
| int deep |
| 2690 |
|
| PREINIT: |
| 2691 |
0 |
▶ | xmlNodePtr node = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNodePtr node = NULL; |
0 |
0 |
0 |
|
| 2692 |
|
| INIT: |
| 2693 |
0 |
| RETVAL = &PL_sv_undef; |
| 2694 |
|
| #ifndef XML_LIBXML_GDOME_SUPPORT |
| 2695 |
0 |
| croak( "GDOME Support not compiled" ); |
| 2696 |
|
| #endif |
| 2697 |
|
| if ( sv_gdome == NULL || sv_gdome == &PL_sv_undef ) { |
| 2698 |
|
| croak( "no XML::GDOME data found" ); |
| 2699 |
|
| } |
| 2700 |
|
| #ifdef XML_LIBXML_GDOME_SUPPORT |
| 2701 |
|
| else { |
| 2702 |
|
| GdomeNode* gnode = NULL; |
| 2703 |
|
| gnode = (GdomeNode*)SvIV((SV*)SvRV( sv_gdome )); |
| 2704 |
|
| if ( gnode == NULL ) { |
| 2705 |
|
| croak( "no XML::GDOME data found (datastructure empty)" ); |
| 2706 |
|
| } |
| 2707 |
|
| |
| 2708 |
|
| node = gdome_xml_n_get_xmlNode( gnode ); |
| 2709 |
|
| if ( node == NULL ) { |
| 2710 |
|
| croak( "no XML::LibXML node found in GDOME object" ); |
| 2711 |
|
| } |
| 2712 |
|
| } |
| 2713 |
|
| #endif |
| 2714 |
|
| CODE: |
| 2715 |
|
| if ( node->type == XML_NAMESPACE_DECL ) { |
| 2716 |
|
| const char * CLASS = "XML::LibXML::Namespace"; |
| 2717 |
|
| RETVAL = NEWSV(0,0); |
| 2718 |
|
| RETVAL = sv_setref_pv( RETVAL, |
| 2719 |
|
| CLASS, |
| 2720 |
|
| (void*)xmlCopyNamespace((xmlNsPtr)node) ); |
| 2721 |
|
| } |
| 2722 |
|
| else { |
| 2723 |
|
| RETVAL = PmmNodeToSv( PmmCloneNode( node, deep ), NULL ); |
| 2724 |
|
| } |
| 2725 |
|
| OUTPUT: |
| 2726 |
|
| RETVAL |
| 2727 |
|
| |
| 2728 |
|
| |
| 2729 |
|
| SV* |
| 2730 |
|
| export_GDOME( CLASS, sv_libxml, deep=1 ) |
| 2731 |
|
| SV * sv_libxml |
| 2732 |
|
| int deep |
| 2733 |
|
| PREINIT: |
| 2734 |
0 |
▶ | xmlNodePtr node = NULL, retnode = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNodePtr node = NULL, retnode = NULL; |
0 |
0 |
0 |
|
| 2735 |
|
| INIT: |
| 2736 |
0 |
| RETVAL = &PL_sv_undef; |
| 2737 |
|
| #ifndef XML_LIBXML_GDOME_SUPPORT |
| 2738 |
0 |
| croak( "GDOME Support not configured!" ); |
| 2739 |
|
| #endif |
| 2740 |
|
| if ( sv_libxml == NULL || sv_libxml == &PL_sv_undef ) { |
| 2741 |
|
| croak( "no XML::LibXML data found" ); |
| 2742 |
|
| } |
| 2743 |
|
| node = PmmSvNode( sv_libxml ); |
| 2744 |
|
| if ( node == NULL ) { |
| 2745 |
|
| croak( "no XML::LibXML data found (empty structure)" ); |
| 2746 |
|
| } |
| 2747 |
|
| CODE: |
| 2748 |
|
| retnode = PmmCloneNode( node, deep ); |
| 2749 |
|
| if ( retnode == NULL ) { |
| 2750 |
|
| croak( "Copy node failed" ); |
| 2751 |
|
| } |
| 2752 |
|
| |
| 2753 |
|
| RETVAL = PmmNodeToGdomeSv( retnode ); |
| 2754 |
|
| OUTPUT: |
| 2755 |
|
| RETVAL |
| 2756 |
|
| |
| 2757 |
|
| |
| 2758 |
|
| int |
| 2759 |
|
| load_catalog( self, filename ) |
| 2760 |
|
| SV * filename |
| 2761 |
|
| PREINIT: |
| 2762 |
1 |
| const char * fn = (const char *) Sv2C(filename, NULL); |
| 2763 |
|
| INIT: |
| 2764 |
1 |
▶ | if ( fn == NULL || xmlStrlen( (xmlChar *)fn ) == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( fn == NULL || xmlStrlen( (xmlChar *)fn ) == 0 ) { |
1 |
0 |
1 |
| if ( fn == NULL || xmlStrlen( (xmlChar *)fn ) == 0 ) { |
0 |
1 |
1 |
|
| 2765 |
0 |
▶ | if ( fn != NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( fn != NULL ) |
0 |
0 |
0 |
|
| 2766 |
0 |
| xmlFree( (xmlChar *)fn ); |
| 2767 |
0 |
| croak( "cannot load catalog" ); |
| 2768 |
|
| } |
| 2769 |
|
| CODE: |
| 2770 |
|
| #ifdef LIBXML_CATALOG_ENABLED |
| 2771 |
1 |
| RETVAL = xmlLoadCatalog( fn ); |
| 2772 |
1 |
| xmlFree( (xmlChar *)fn ); |
| 2773 |
|
| #else |
| 2774 |
|
| xmlFree( (xmlChar *)fn ); |
| 2775 |
|
| XSRETURN_UNDEF; |
| 2776 |
|
| #endif |
| 2777 |
|
| OUTPUT: |
| 2778 |
|
| RETVAL |
| 2779 |
|
| |
| 2780 |
|
| |
| 2781 |
|
| |
| 2782 |
|
| int |
| 2783 |
|
| _default_catalog( self, catalog ) |
| 2784 |
|
| SV * catalog |
| 2785 |
|
| PREINIT: |
| 2786 |
|
| #ifdef LIBXML_CATALOG_ENABLED |
| 2787 |
0 |
▶ | xmlCatalogPtr catal = INT2PTR(xmlCatalogPtr,SvIV(SvRV(catalog))); |
Branch: 1 branch
| Branch | True | False | Total |
| xmlCatalogPtr catal = INT2PTR(xmlCatalogPtr,SvIV(SvRV(catalog))); |
0 |
0 |
0 |
|
| 2788 |
|
| #endif |
| 2789 |
|
| INIT: |
| 2790 |
0 |
▶ | if ( catal == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( catal == NULL ) { |
0 |
0 |
0 |
|
| 2791 |
0 |
| croak( "empty catalog\n" ); |
| 2792 |
|
| } |
| 2793 |
|
| CODE: |
| 2794 |
0 |
| warn( "this feature is not implemented" ); |
| 2795 |
0 |
▶ | RETVAL = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 0; |
0 |
0 |
0 |
|
| 2796 |
|
| OUTPUT: |
| 2797 |
|
| RETVAL |
| 2798 |
|
| |
| 2799 |
|
| # Set or clear the global external entity loader callback. |
| 2800 |
|
| # When called with a coderef: saves the current libxml2 loader, installs |
| 2801 |
|
| # LibXML_load_external_entity as the global loader, and stores the Perl |
| 2802 |
|
| # callback in EXTERNAL_ENTITY_LOADER_FUNC (freeing any previous one). |
| 2803 |
|
| # When called with undef: decrefs the stored callback, restores the |
| 2804 |
|
| # original libxml2 loader, and NULLs both global tracking variables. |
| 2805 |
|
| # Always returns a copy of the previous Perl callback (or undef). |
| 2806 |
|
| SV* |
| 2807 |
|
| _externalEntityLoader( loader ) |
| 2808 |
|
| SV* loader |
| 2809 |
|
| CODE: |
| 2810 |
|
| { |
| 2811 |
|
| /* Always return a fresh refcount-1 SV: xsubpp auto-mortalizes |
| 2812 |
|
| * RETVAL for SV*, and mortalizing the &PL_sv_undef singleton on |
| 2813 |
|
| * every call eventually drives its refcount negative (SEGV under |
| 2814 |
|
| * repeated invocation). Use newSV(0) for "no previous handler". */ |
| 2815 |
51 |
| RETVAL = EXTERNAL_ENTITY_LOADER_FUNC |
| 2816 |
22 |
| ? newSVsv(EXTERNAL_ENTITY_LOADER_FUNC) |
| 2817 |
51 |
▶ | : newSV(0); |
Branch: 1 branch
| Branch | True | False | Total |
| : newSV(0); |
22 |
29 |
51 |
|
| 2818 |
|
| |
| 2819 |
51 |
▶ | if (SvOK(loader)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(loader)) |
24 |
27 |
51 |
|
| 2820 |
|
| { |
| 2821 |
24 |
▶ | if (EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
1 |
23 |
24 |
|
| 2822 |
|
| { |
| 2823 |
1 |
| SvREFCNT_dec(EXTERNAL_ENTITY_LOADER_FUNC); |
| 2824 |
|
| } |
| 2825 |
24 |
| EXTERNAL_ENTITY_LOADER_FUNC = newSVsv(loader); |
| 2826 |
|
| |
| 2827 |
24 |
▶ | if (LibXML_old_ext_ent_loader_global == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (LibXML_old_ext_ent_loader_global == NULL) |
23 |
1 |
24 |
|
| 2828 |
|
| { |
| 2829 |
23 |
| LibXML_old_ext_ent_loader_global = xmlGetExternalEntityLoader(); |
| 2830 |
23 |
| xmlSetExternalEntityLoader( |
| 2831 |
|
| (xmlExternalEntityLoader)LibXML_load_external_entity); |
| 2832 |
|
| } |
| 2833 |
|
| } |
| 2834 |
|
| else |
| 2835 |
|
| { |
| 2836 |
27 |
▶ | if (EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (EXTERNAL_ENTITY_LOADER_FUNC != NULL) |
21 |
6 |
27 |
|
| 2837 |
|
| { |
| 2838 |
21 |
| SvREFCNT_dec(EXTERNAL_ENTITY_LOADER_FUNC); |
| 2839 |
21 |
| EXTERNAL_ENTITY_LOADER_FUNC = NULL; |
| 2840 |
|
| } |
| 2841 |
27 |
▶ | if (LibXML_old_ext_ent_loader_global != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (LibXML_old_ext_ent_loader_global != NULL) |
21 |
6 |
27 |
|
| 2842 |
|
| { |
| 2843 |
21 |
| xmlSetExternalEntityLoader( |
| 2844 |
|
| (xmlExternalEntityLoader)LibXML_old_ext_ent_loader_global); |
| 2845 |
21 |
| LibXML_old_ext_ent_loader_global = NULL; |
| 2846 |
|
| } |
| 2847 |
|
| } |
| 2848 |
|
| } |
| 2849 |
|
| OUTPUT: |
| 2850 |
|
| RETVAL |
| 2851 |
|
| |
| 2852 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::HashTable |
| 2853 |
|
| |
| 2854 |
|
| xmlHashTablePtr |
| 2855 |
|
| new(CLASS) |
| 2856 |
|
| const char * CLASS |
| 2857 |
|
| CODE: |
| 2858 |
0 |
| RETVAL = xmlHashCreate(8); |
| 2859 |
|
| OUTPUT: |
| 2860 |
|
| RETVAL |
| 2861 |
|
| |
| 2862 |
|
| void |
| 2863 |
|
| DESTROY( table ) |
| 2864 |
|
| xmlHashTablePtr table |
| 2865 |
|
| CODE: |
| 2866 |
|
| xs_warn("DESTROY XMLHASHTABLE\n"); |
| 2867 |
0 |
| PmmFreeHashTable(table); |
| 2868 |
|
| |
| 2869 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::ParserContext |
| 2870 |
|
| |
| 2871 |
|
| void |
| 2872 |
|
| DESTROY( self ) |
| 2873 |
|
| SV * self |
| 2874 |
|
| CODE: |
| 2875 |
|
| xs_warn( "DROP PARSER CONTEXT!" ); |
| 2876 |
77 |
| PmmContextREFCNT_dec( SvPROXYNODE( self ) ); |
| 2877 |
|
| |
| 2878 |
|
| |
| 2879 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Document |
| 2880 |
|
| |
| 2881 |
|
| SV * |
| 2882 |
|
| _toString(self, format=0) |
| 2883 |
|
| xmlDocPtr self |
| 2884 |
|
| int format |
| 2885 |
|
| PREINIT: |
| 2886 |
35 |
| xmlChar *result=NULL; |
| 2887 |
35 |
| int len=0; |
| 2888 |
35 |
| SV* internalFlag = NULL; |
| 2889 |
35 |
| int oldTagFlag = xmlSaveNoEmptyTags; |
| 2890 |
35 |
| xmlDtdPtr intSubset = NULL; |
| 2891 |
|
| /* PREINIT_SAVED_ERROR */ |
| 2892 |
|
| CODE: |
| 2893 |
35 |
| RETVAL = &PL_sv_undef; |
| 2894 |
35 |
| internalFlag = get_sv("XML::LibXML::setTagCompression", 0); |
| 2895 |
35 |
▶ | if( internalFlag ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( internalFlag ) { |
35 |
0 |
35 |
|
| 2896 |
35 |
| xmlSaveNoEmptyTags = SvTRUE(internalFlag); |
| 2897 |
|
| } |
| 2898 |
|
| |
| 2899 |
35 |
| internalFlag = get_sv("XML::LibXML::skipDTD", 0); |
| 2900 |
35 |
▶ | if ( internalFlag && SvTRUE(internalFlag) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( internalFlag && SvTRUE(internalFlag) ) { |
35 |
0 |
35 |
| if ( internalFlag && SvTRUE(internalFlag) ) { |
1 |
34 |
35 |
|
| 2901 |
1 |
| intSubset = xmlGetIntSubset( self ); |
| 2902 |
1 |
▶ | if ( intSubset ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( intSubset ) |
1 |
0 |
1 |
|
| 2903 |
1 |
| xmlUnlinkNode( INT2PTR(xmlNodePtr,intSubset) ); |
| 2904 |
|
| } |
| 2905 |
|
| |
| 2906 |
|
| /* INIT_ERROR_HANDLER; */ |
| 2907 |
|
| |
| 2908 |
35 |
▶ | if ( format <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( format <= 0 ) { |
34 |
1 |
35 |
|
| 2909 |
|
| xs_warn( "use no formated toString!" ); |
| 2910 |
34 |
| xmlDocDumpMemory(self, &result, &len); |
| 2911 |
|
| } |
| 2912 |
|
| else { |
| 2913 |
1 |
| int t_indent_var = xmlIndentTreeOutput; |
| 2914 |
|
| xs_warn( "use formated toString!" ); |
| 2915 |
1 |
| xmlIndentTreeOutput = 1; |
| 2916 |
1 |
| xmlDocDumpFormatMemory( self, &result, &len, format ); |
| 2917 |
1 |
| xmlIndentTreeOutput = t_indent_var; |
| 2918 |
|
| } |
| 2919 |
|
| |
| 2920 |
35 |
▶ | if ( intSubset != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( intSubset != NULL ) { |
1 |
34 |
35 |
|
| 2921 |
1 |
▶ | if (self->children == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->children == NULL) { |
0 |
1 |
1 |
|
| 2922 |
0 |
| xmlAddChild(INT2PTR(xmlNodePtr,self), INT2PTR(xmlNodePtr,intSubset)); |
| 2923 |
|
| } |
| 2924 |
|
| else { |
| 2925 |
1 |
| xmlAddPrevSibling(self->children, INT2PTR(xmlNodePtr,intSubset)); |
| 2926 |
|
| } |
| 2927 |
|
| } |
| 2928 |
|
| |
| 2929 |
35 |
| xmlSaveNoEmptyTags = oldTagFlag; |
| 2930 |
|
| |
| 2931 |
|
| /* REPORT_ERROR(0); */ |
| 2932 |
|
| |
| 2933 |
35 |
▶ | if (result == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result == NULL) { |
0 |
35 |
35 |
|
| 2934 |
|
| xs_warn("Failed to convert doc to string"); |
| 2935 |
0 |
| XSRETURN_UNDEF; |
| 2936 |
|
| } else { |
| 2937 |
|
| /* warn("%s, %d\n",result, len); */ |
| 2938 |
35 |
| RETVAL = newSVpvn( (const char *)result, len ); |
| 2939 |
|
| /* C2Sv( result, self->encoding ); */ |
| 2940 |
35 |
| xmlFree(result); |
| 2941 |
|
| } |
| 2942 |
|
| OUTPUT: |
| 2943 |
|
| RETVAL |
| 2944 |
|
| |
| 2945 |
|
| int |
| 2946 |
|
| toFH( self, filehandler, format=0 ) |
| 2947 |
|
| xmlDocPtr self |
| 2948 |
|
| SV * filehandler |
| 2949 |
|
| int format |
| 2950 |
|
| PREINIT: |
| 2951 |
|
| xmlOutputBufferPtr buffer; |
| 2952 |
1 |
| const xmlChar * encoding = NULL; |
| 2953 |
1 |
| xmlCharEncodingHandlerPtr handler = NULL; |
| 2954 |
1 |
| SV* internalFlag = NULL; |
| 2955 |
1 |
| int oldTagFlag = xmlSaveNoEmptyTags; |
| 2956 |
1 |
| xmlDtdPtr intSubset = NULL; |
| 2957 |
1 |
| int t_indent_var = xmlIndentTreeOutput; |
| 2958 |
1 |
| PREINIT_SAVED_ERROR |
| 2959 |
|
| CODE: |
| 2960 |
1 |
| internalFlag = get_sv("XML::LibXML::setTagCompression", 0); |
| 2961 |
1 |
▶ | if( internalFlag ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( internalFlag ) { |
1 |
0 |
1 |
|
| 2962 |
1 |
| xmlSaveNoEmptyTags = SvTRUE(internalFlag); |
| 2963 |
|
| } |
| 2964 |
|
| |
| 2965 |
1 |
| internalFlag = get_sv("XML::LibXML::skipDTD", 0); |
| 2966 |
1 |
▶ | if ( internalFlag && SvTRUE(internalFlag) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( internalFlag && SvTRUE(internalFlag) ) { |
1 |
0 |
1 |
| if ( internalFlag && SvTRUE(internalFlag) ) { |
0 |
1 |
1 |
|
| 2967 |
0 |
| intSubset = xmlGetIntSubset( self ); |
| 2968 |
0 |
▶ | if ( intSubset ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( intSubset ) |
0 |
0 |
0 |
|
| 2969 |
0 |
| xmlUnlinkNode( INT2PTR(xmlNodePtr,intSubset) ); |
| 2970 |
|
| } |
| 2971 |
|
| |
| 2972 |
1 |
| xmlRegisterDefaultOutputCallbacks(); |
| 2973 |
1 |
| encoding = (self)->encoding; |
| 2974 |
1 |
▶ | if ( encoding != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( encoding != NULL ) { |
0 |
1 |
1 |
|
| 2975 |
0 |
▶ | if ( xmlParseCharEncoding((const char*)encoding) != XML_CHAR_ENCODING_UTF8) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlParseCharEncoding((const char*)encoding) != XML_CHAR_ENCODING_UTF8) { |
0 |
0 |
0 |
|
| 2976 |
0 |
| handler = xmlFindCharEncodingHandler((const char*)encoding); |
| 2977 |
|
| } |
| 2978 |
|
| |
| 2979 |
|
| } |
| 2980 |
|
| else { |
| 2981 |
|
| xs_warn("no encoding?"); |
| 2982 |
|
| } |
| 2983 |
|
| |
| 2984 |
1 |
| buffer = xmlOutputBufferCreateIO( (xmlOutputWriteCallback) &LibXML_output_write_handler, |
| 2985 |
|
| (xmlOutputCloseCallback)&LibXML_output_close_handler, |
| 2986 |
|
| filehandler, |
| 2987 |
|
| handler ); |
| 2988 |
|
| |
| 2989 |
1 |
▶ | if ( format <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( format <= 0 ) { |
1 |
0 |
1 |
|
| 2990 |
1 |
| format = 0; |
| 2991 |
1 |
| xmlIndentTreeOutput = 0; |
| 2992 |
|
| } |
| 2993 |
|
| else { |
| 2994 |
0 |
| xmlIndentTreeOutput = 1; |
| 2995 |
|
| } |
| 2996 |
|
| |
| 2997 |
1 |
| INIT_ERROR_HANDLER; |
| 2998 |
|
| |
| 2999 |
1 |
| RETVAL = xmlSaveFormatFileTo( buffer, |
| 3000 |
|
| self, |
| 3001 |
|
| (const char *) encoding, |
| 3002 |
|
| format); |
| 3003 |
|
| |
| 3004 |
1 |
▶ | if ( intSubset != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( intSubset != NULL ) { |
0 |
1 |
1 |
|
| 3005 |
0 |
▶ | if (self->children == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->children == NULL) { |
0 |
0 |
0 |
|
| 3006 |
0 |
| xmlAddChild(INT2PTR(xmlNodePtr,self), INT2PTR(xmlNodePtr,intSubset)); |
| 3007 |
|
| } |
| 3008 |
|
| else { |
| 3009 |
0 |
| xmlAddPrevSibling(self->children, INT2PTR(xmlNodePtr,intSubset)); |
| 3010 |
|
| } |
| 3011 |
|
| } |
| 3012 |
|
| |
| 3013 |
1 |
| xmlIndentTreeOutput = t_indent_var; |
| 3014 |
1 |
| xmlSaveNoEmptyTags = oldTagFlag; |
| 3015 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 3016 |
1 |
| REPORT_ERROR(0); |
| 3017 |
|
| OUTPUT: |
| 3018 |
|
| RETVAL |
| 3019 |
|
| |
| 3020 |
|
| int |
| 3021 |
|
| toFile( self, filename, format=0 ) |
| 3022 |
|
| xmlDocPtr self |
| 3023 |
|
| char * filename |
| 3024 |
|
| int format |
| 3025 |
|
| PREINIT: |
| 3026 |
1 |
| SV* internalFlag = NULL; |
| 3027 |
1 |
| int oldTagFlag = xmlSaveNoEmptyTags; |
| 3028 |
1 |
| PREINIT_SAVED_ERROR |
| 3029 |
|
| CODE: |
| 3030 |
1 |
| internalFlag = get_sv("XML::LibXML::setTagCompression", 0); |
| 3031 |
1 |
▶ | if( internalFlag ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( internalFlag ) { |
1 |
0 |
1 |
|
| 3032 |
1 |
| xmlSaveNoEmptyTags = SvTRUE(internalFlag); |
| 3033 |
|
| } |
| 3034 |
|
| |
| 3035 |
1 |
| INIT_ERROR_HANDLER; |
| 3036 |
|
| |
| 3037 |
1 |
▶ | if ( format <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( format <= 0 ) { |
1 |
0 |
1 |
|
| 3038 |
|
| xs_warn( "use no formated toFile!" ); |
| 3039 |
1 |
| RETVAL = xmlSaveFile( filename, self ); |
| 3040 |
|
| } |
| 3041 |
|
| else { |
| 3042 |
0 |
| int t_indent_var = xmlIndentTreeOutput; |
| 3043 |
0 |
| xmlIndentTreeOutput = 1; |
| 3044 |
0 |
| RETVAL =xmlSaveFormatFile( filename, |
| 3045 |
|
| self, |
| 3046 |
|
| format); |
| 3047 |
0 |
| xmlIndentTreeOutput = t_indent_var; |
| 3048 |
|
| } |
| 3049 |
|
| |
| 3050 |
1 |
| xmlSaveNoEmptyTags = oldTagFlag; |
| 3051 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 3052 |
1 |
| REPORT_ERROR(0); |
| 3053 |
|
| |
| 3054 |
1 |
▶ | if ( RETVAL > 0 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL > 0 ) |
1 |
0 |
1 |
|
| 3055 |
1 |
| RETVAL = 1; |
| 3056 |
|
| else |
| 3057 |
0 |
| XSRETURN_UNDEF; |
| 3058 |
|
| OUTPUT: |
| 3059 |
|
| RETVAL |
| 3060 |
|
| |
| 3061 |
|
| SV * |
| 3062 |
|
| toStringHTML(self) |
| 3063 |
|
| xmlDocPtr self |
| 3064 |
|
| ALIAS: |
| 3065 |
|
| XML::LibXML::Document::serialize_html = 1 |
| 3066 |
|
| PREINIT: |
| 3067 |
4 |
| xmlChar *result=NULL; |
| 3068 |
4 |
| int len = 0; |
| 3069 |
4 |
| PREINIT_SAVED_ERROR |
| 3070 |
|
| CODE: |
| 3071 |
|
| PERL_UNUSED_VAR(ix); |
| 3072 |
|
| xs_warn( "use no formated toString!" ); |
| 3073 |
4 |
| INIT_ERROR_HANDLER; |
| 3074 |
4 |
| htmlDocDumpMemory(self, &result, &len); |
| 3075 |
4 |
| CLEANUP_ERROR_HANDLER; |
| 3076 |
4 |
| REPORT_ERROR(0); |
| 3077 |
|
| |
| 3078 |
4 |
▶ | if (result == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result == NULL) { |
0 |
4 |
4 |
|
| 3079 |
0 |
| XSRETURN_UNDEF; |
| 3080 |
|
| } else { |
| 3081 |
|
| /* warn("%s, %d\n",result, len); */ |
| 3082 |
4 |
| RETVAL = newSVpvn((char *)result, (STRLEN)len); |
| 3083 |
4 |
| xmlFree(result); |
| 3084 |
|
| } |
| 3085 |
|
| OUTPUT: |
| 3086 |
|
| RETVAL |
| 3087 |
|
| |
| 3088 |
|
| |
| 3089 |
|
| const char * |
| 3090 |
|
| URI( self ) |
| 3091 |
|
| xmlDocPtr self |
| 3092 |
|
| ALIAS: |
| 3093 |
|
| XML::LibXML::Document::documentURI = 1 |
| 3094 |
|
| CODE: |
| 3095 |
|
| PERL_UNUSED_VAR(ix); |
| 3096 |
11 |
| RETVAL = (const char*)xmlStrdup(self->URL ); |
| 3097 |
|
| OUTPUT: |
| 3098 |
|
| RETVAL |
| 3099 |
|
| CLEANUP: |
| 3100 |
11 |
| xmlFree((xmlChar*)RETVAL); |
| 3101 |
|
| |
| 3102 |
|
| void |
| 3103 |
|
| setURI( self, new_URI ) |
| 3104 |
|
| xmlDocPtr self |
| 3105 |
|
| char * new_URI |
| 3106 |
|
| CODE: |
| 3107 |
2 |
▶ | if (new_URI) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (new_URI) { |
2 |
0 |
2 |
|
| 3108 |
2 |
| xmlFree((xmlChar*)self->URL ); |
| 3109 |
2 |
| self->URL = xmlStrdup((const xmlChar*)new_URI); |
| 3110 |
|
| } |
| 3111 |
|
| |
| 3112 |
|
| SV* |
| 3113 |
|
| createDocument( CLASS, version="1.0", encoding=NULL ) |
| 3114 |
|
| char * version |
| 3115 |
|
| char * encoding |
| 3116 |
|
| ALIAS: |
| 3117 |
|
| XML::LibXML::Document::new = 1 |
| 3118 |
|
| PREINIT: |
| 3119 |
122 |
▶ | xmlDocPtr doc=NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlDocPtr doc=NULL; |
115 |
7 |
122 |
|
| 3120 |
|
| CODE: |
| 3121 |
|
| PERL_UNUSED_VAR(ix); |
| 3122 |
122 |
| doc = xmlNewDoc((const xmlChar*)version); |
| 3123 |
122 |
▶ | if (encoding && *encoding != 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (encoding && *encoding != 0) { |
6 |
116 |
122 |
| if (encoding && *encoding != 0) { |
6 |
0 |
6 |
|
| 3124 |
6 |
| doc->encoding = (const xmlChar*)xmlStrdup((const xmlChar*)encoding); |
| 3125 |
|
| } |
| 3126 |
122 |
| RETVAL = PmmNodeToSv(INT2PTR(xmlNodePtr,doc),NULL); |
| 3127 |
|
| OUTPUT: |
| 3128 |
|
| RETVAL |
| 3129 |
|
| |
| 3130 |
|
| SV* |
| 3131 |
|
| createInternalSubset( self, Pname, extID, sysID ) |
| 3132 |
|
| xmlDocPtr self |
| 3133 |
|
| SV * Pname |
| 3134 |
|
| SV * extID |
| 3135 |
|
| SV * sysID |
| 3136 |
|
| PREINIT: |
| 3137 |
1 |
| xmlDtdPtr dtd = NULL; |
| 3138 |
1 |
| xmlChar * name = NULL; |
| 3139 |
1 |
| xmlChar * externalID = NULL; |
| 3140 |
1 |
| xmlChar * systemID = NULL; |
| 3141 |
|
| CODE: |
| 3142 |
1 |
| name = Sv2C( Pname, NULL ); |
| 3143 |
1 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
1 |
1 |
|
| 3144 |
0 |
| XSRETURN_UNDEF; |
| 3145 |
|
| } |
| 3146 |
|
| |
| 3147 |
1 |
| externalID = Sv2C(extID, NULL); |
| 3148 |
1 |
| systemID = Sv2C(sysID, NULL); |
| 3149 |
|
| |
| 3150 |
1 |
| dtd = xmlCreateIntSubset( self, name, externalID, systemID ); |
| 3151 |
1 |
| xmlFree(externalID); |
| 3152 |
1 |
| xmlFree(systemID); |
| 3153 |
1 |
| xmlFree(name); |
| 3154 |
1 |
▶ | if ( dtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd ) { |
1 |
0 |
1 |
|
| 3155 |
1 |
| RETVAL = PmmNodeToSv( INT2PTR(xmlNodePtr,dtd), PmmPROXYNODE(self) ); |
| 3156 |
|
| } |
| 3157 |
|
| else { |
| 3158 |
0 |
| XSRETURN_UNDEF; |
| 3159 |
|
| } |
| 3160 |
|
| OUTPUT: |
| 3161 |
|
| RETVAL |
| 3162 |
|
| |
| 3163 |
|
| SV* |
| 3164 |
|
| createExternalSubset( self, Pname, extID, sysID ) |
| 3165 |
|
| xmlDocPtr self |
| 3166 |
|
| SV * Pname |
| 3167 |
|
| SV * extID |
| 3168 |
|
| SV * sysID |
| 3169 |
|
| PREINIT: |
| 3170 |
1 |
| xmlDtdPtr dtd = NULL; |
| 3171 |
1 |
| xmlChar * name = NULL; |
| 3172 |
1 |
| xmlChar * externalID = NULL; |
| 3173 |
1 |
| xmlChar * systemID = NULL; |
| 3174 |
|
| CODE: |
| 3175 |
1 |
| name = Sv2C( Pname, NULL ); |
| 3176 |
1 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
1 |
1 |
|
| 3177 |
0 |
| XSRETURN_UNDEF; |
| 3178 |
|
| } |
| 3179 |
|
| |
| 3180 |
1 |
| externalID = Sv2C(extID, NULL); |
| 3181 |
1 |
| systemID = Sv2C(sysID, NULL); |
| 3182 |
|
| |
| 3183 |
1 |
| dtd = xmlNewDtd( self, name, externalID, systemID ); |
| 3184 |
|
| |
| 3185 |
1 |
| xmlFree(externalID); |
| 3186 |
1 |
| xmlFree(systemID); |
| 3187 |
1 |
| xmlFree(name); |
| 3188 |
1 |
▶ | if ( dtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd ) { |
1 |
0 |
1 |
|
| 3189 |
1 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)dtd, PmmPROXYNODE(self) ); |
| 3190 |
|
| } |
| 3191 |
|
| else { |
| 3192 |
0 |
| XSRETURN_UNDEF; |
| 3193 |
|
| } |
| 3194 |
|
| OUTPUT: |
| 3195 |
|
| RETVAL |
| 3196 |
|
| |
| 3197 |
|
| SV* |
| 3198 |
|
| createDTD( self, Pname, extID, sysID ) |
| 3199 |
|
| xmlDocPtr self |
| 3200 |
|
| SV * Pname |
| 3201 |
|
| SV * extID |
| 3202 |
|
| SV * sysID |
| 3203 |
|
| PREINIT: |
| 3204 |
1 |
| xmlDtdPtr dtd = NULL; |
| 3205 |
1 |
| xmlChar * name = NULL; |
| 3206 |
1 |
| xmlChar * externalID = NULL; |
| 3207 |
1 |
| xmlChar * systemID = NULL; |
| 3208 |
|
| CODE: |
| 3209 |
1 |
| name = Sv2C( Pname, NULL ); |
| 3210 |
1 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
1 |
1 |
|
| 3211 |
0 |
| XSRETURN_UNDEF; |
| 3212 |
|
| } |
| 3213 |
|
| |
| 3214 |
1 |
| externalID = Sv2C(extID, NULL); |
| 3215 |
1 |
| systemID = Sv2C(sysID, NULL); |
| 3216 |
|
| |
| 3217 |
1 |
| dtd = xmlNewDtd( NULL, name, externalID, systemID ); |
| 3218 |
1 |
| dtd->doc = self; |
| 3219 |
|
| |
| 3220 |
1 |
| xmlFree(externalID); |
| 3221 |
1 |
| xmlFree(systemID); |
| 3222 |
1 |
| xmlFree(name); |
| 3223 |
1 |
▶ | if ( dtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd ) { |
1 |
0 |
1 |
|
| 3224 |
1 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)dtd, PmmPROXYNODE(self) ); |
| 3225 |
|
| } |
| 3226 |
|
| else { |
| 3227 |
0 |
| XSRETURN_UNDEF; |
| 3228 |
|
| } |
| 3229 |
|
| OUTPUT: |
| 3230 |
|
| RETVAL |
| 3231 |
|
| |
| 3232 |
|
| SV* |
| 3233 |
|
| createDocumentFragment( self ) |
| 3234 |
|
| xmlDocPtr self |
| 3235 |
|
| CODE: |
| 3236 |
3 |
| RETVAL = PmmNodeToSv(xmlNewDocFragment(self), PmmPROXYNODE(self)); |
| 3237 |
|
| OUTPUT: |
| 3238 |
|
| RETVAL |
| 3239 |
|
| |
| 3240 |
|
| SV* |
| 3241 |
|
| createElement( self, name ) |
| 3242 |
|
| xmlDocPtr self |
| 3243 |
|
| SV* name |
| 3244 |
|
| PREINIT: |
| 3245 |
|
| xmlNodePtr newNode; |
| 3246 |
95 |
| xmlChar * elname = NULL; |
| 3247 |
95 |
| ProxyNodePtr docfrag = NULL; |
| 3248 |
|
| CODE: |
| 3249 |
95 |
| elname = nodeSv2C( name , (xmlNodePtr) self); |
| 3250 |
95 |
▶ | if ( !LibXML_test_node_name( elname ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( elname ) ) { |
18 |
77 |
95 |
|
| 3251 |
18 |
| xmlFree( elname ); |
| 3252 |
18 |
| croak( "bad name" ); |
| 3253 |
|
| } |
| 3254 |
|
| |
| 3255 |
77 |
| newNode = xmlNewNode(NULL , elname); |
| 3256 |
77 |
| xmlFree(elname); |
| 3257 |
77 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
77 |
0 |
77 |
|
| 3258 |
77 |
| docfrag = PmmNewFragment( self ); |
| 3259 |
77 |
| newNode->doc = self; |
| 3260 |
77 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3261 |
77 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3262 |
|
| } |
| 3263 |
|
| else { |
| 3264 |
|
| xs_warn( "no node created!" ); |
| 3265 |
0 |
| XSRETURN_UNDEF; |
| 3266 |
|
| } |
| 3267 |
|
| OUTPUT: |
| 3268 |
|
| RETVAL |
| 3269 |
|
| |
| 3270 |
|
| SV* |
| 3271 |
|
| createRawElement( self, name ) |
| 3272 |
|
| xmlDocPtr self |
| 3273 |
|
| SV* name |
| 3274 |
|
| PREINIT: |
| 3275 |
|
| xmlNodePtr newNode; |
| 3276 |
63 |
| xmlChar * elname = NULL; |
| 3277 |
63 |
| ProxyNodePtr docfrag = NULL; |
| 3278 |
|
| CODE: |
| 3279 |
63 |
| elname = nodeSv2C( name , (xmlNodePtr) self); |
| 3280 |
63 |
▶ | if ( !elname || xmlStrlen(elname) <= 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !elname || xmlStrlen(elname) <= 0 ) { |
63 |
0 |
63 |
| if ( !elname || xmlStrlen(elname) <= 0 ) { |
0 |
63 |
63 |
|
| 3281 |
0 |
| xmlFree( elname ); |
| 3282 |
0 |
| croak( "bad name" ); |
| 3283 |
|
| } |
| 3284 |
|
| |
| 3285 |
63 |
| newNode = xmlNewDocNode(self,NULL , elname, NULL); |
| 3286 |
63 |
| xmlFree(elname); |
| 3287 |
63 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
63 |
0 |
63 |
|
| 3288 |
63 |
| docfrag = PmmNewFragment( self ); |
| 3289 |
63 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3290 |
63 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3291 |
|
| } |
| 3292 |
|
| else { |
| 3293 |
|
| xs_warn( "no node created!" ); |
| 3294 |
0 |
| XSRETURN_UNDEF; |
| 3295 |
|
| } |
| 3296 |
|
| OUTPUT: |
| 3297 |
|
| RETVAL |
| 3298 |
|
| |
| 3299 |
|
| SV* |
| 3300 |
|
| createElementNS( self, nsURI, name ) |
| 3301 |
|
| xmlDocPtr self |
| 3302 |
|
| SV * nsURI |
| 3303 |
|
| SV * name |
| 3304 |
|
| PREINIT: |
| 3305 |
33 |
| xmlChar * ename = NULL; |
| 3306 |
33 |
| xmlChar * prefix = NULL; |
| 3307 |
33 |
| xmlChar * localname = NULL; |
| 3308 |
33 |
| xmlChar * eURI = NULL; |
| 3309 |
33 |
| xmlNsPtr ns = NULL; |
| 3310 |
33 |
| ProxyNodePtr docfrag = NULL; |
| 3311 |
33 |
| xmlNodePtr newNode = NULL; |
| 3312 |
|
| CODE: |
| 3313 |
33 |
| ename = nodeSv2C( name , (xmlNodePtr) self ); |
| 3314 |
33 |
▶ | if ( !LibXML_test_node_name( ename ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( ename ) ) { |
13 |
20 |
33 |
|
| 3315 |
13 |
| xmlFree( ename ); |
| 3316 |
13 |
| croak( "bad name" ); |
| 3317 |
|
| } |
| 3318 |
|
| |
| 3319 |
20 |
| eURI = Sv2C( nsURI , NULL ); |
| 3320 |
|
| |
| 3321 |
20 |
▶ | if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
Branch: 2 branches
| Branch | True | False | Total |
| if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
20 |
0 |
20 |
| if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
20 |
0 |
20 |
|
| 3322 |
20 |
| localname = xmlSplitQName2(ename, &prefix); |
| 3323 |
20 |
▶ | if ( localname == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( localname == NULL ) { |
11 |
9 |
20 |
|
| 3324 |
11 |
| localname = xmlStrdup( ename ); |
| 3325 |
|
| } |
| 3326 |
|
| |
| 3327 |
20 |
| ns = xmlNewNs( NULL, eURI, prefix ); |
| 3328 |
20 |
| newNode = xmlNewDocNode( self, ns, localname, NULL ); |
| 3329 |
20 |
| newNode->nsDef = ns; |
| 3330 |
|
| |
| 3331 |
20 |
| xmlFree(localname); |
| 3332 |
|
| } |
| 3333 |
|
| else { |
| 3334 |
|
| xs_warn( " ordinary element " ); |
| 3335 |
|
| /* ordinary element */ |
| 3336 |
0 |
| localname = ename; |
| 3337 |
|
| |
| 3338 |
0 |
| newNode = xmlNewDocNode( self, NULL , localname, NULL ); |
| 3339 |
|
| } |
| 3340 |
|
| |
| 3341 |
20 |
| docfrag = PmmNewFragment( self ); |
| 3342 |
20 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3343 |
20 |
| RETVAL = PmmNodeToSv(newNode, docfrag); |
| 3344 |
|
| |
| 3345 |
20 |
▶ | if ( prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL ) { |
9 |
11 |
20 |
|
| 3346 |
9 |
| xmlFree(prefix); |
| 3347 |
|
| } |
| 3348 |
20 |
▶ | if ( eURI != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( eURI != NULL ) { |
20 |
0 |
20 |
|
| 3349 |
20 |
| xmlFree(eURI); |
| 3350 |
|
| } |
| 3351 |
20 |
| xmlFree(ename); |
| 3352 |
|
| OUTPUT: |
| 3353 |
|
| RETVAL |
| 3354 |
|
| |
| 3355 |
|
| SV* |
| 3356 |
|
| createRawElementNS( self, nsURI, name ) |
| 3357 |
|
| xmlDocPtr self |
| 3358 |
|
| SV * nsURI |
| 3359 |
|
| SV * name |
| 3360 |
|
| PREINIT: |
| 3361 |
8 |
| xmlChar * ename = NULL; |
| 3362 |
8 |
| xmlChar * prefix = NULL; |
| 3363 |
8 |
| xmlChar * localname = NULL; |
| 3364 |
8 |
| xmlChar * eURI = NULL; |
| 3365 |
8 |
| xmlNsPtr ns = NULL; |
| 3366 |
8 |
| ProxyNodePtr docfrag = NULL; |
| 3367 |
8 |
| xmlNodePtr newNode = NULL; |
| 3368 |
|
| CODE: |
| 3369 |
8 |
| ename = nodeSv2C( name , (xmlNodePtr) self ); |
| 3370 |
8 |
▶ | if ( !LibXML_test_node_name( ename ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( ename ) ) { |
0 |
8 |
8 |
|
| 3371 |
0 |
| xmlFree( ename ); |
| 3372 |
0 |
| croak( "bad name" ); |
| 3373 |
|
| } |
| 3374 |
|
| |
| 3375 |
8 |
| eURI = Sv2C( nsURI , NULL ); |
| 3376 |
|
| |
| 3377 |
8 |
▶ | if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
Branch: 2 branches
| Branch | True | False | Total |
| if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
8 |
0 |
8 |
| if ( eURI != NULL && xmlStrlen(eURI)!=0 ){ |
8 |
0 |
8 |
|
| 3378 |
8 |
| localname = xmlSplitQName2(ename, &prefix); |
| 3379 |
8 |
▶ | if ( localname == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( localname == NULL ) { |
1 |
7 |
8 |
|
| 3380 |
1 |
| localname = xmlStrdup( ename ); |
| 3381 |
|
| } |
| 3382 |
|
| |
| 3383 |
8 |
| newNode = xmlNewDocNode( self,NULL , localname, NULL ); |
| 3384 |
|
| |
| 3385 |
8 |
| ns = xmlSearchNsByHref( self, newNode, eURI ); |
| 3386 |
8 |
▶ | if ( ns == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == NULL ) { |
8 |
0 |
8 |
|
| 3387 |
|
| /* create a new NS if the NS does not already exists */ |
| 3388 |
8 |
| ns = xmlNewNs(newNode, eURI , prefix ); |
| 3389 |
|
| } |
| 3390 |
|
| |
| 3391 |
8 |
▶ | if ( ns == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == NULL ) { |
0 |
8 |
8 |
|
| 3392 |
0 |
| xmlFreeNode( newNode ); |
| 3393 |
0 |
| xmlFree(eURI); |
| 3394 |
0 |
| xmlFree(localname); |
| 3395 |
0 |
▶ | if ( prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL ) { |
0 |
0 |
0 |
|
| 3396 |
0 |
| xmlFree(prefix); |
| 3397 |
|
| } |
| 3398 |
0 |
| xmlFree(ename); |
| 3399 |
0 |
| XSRETURN_UNDEF; |
| 3400 |
|
| } |
| 3401 |
|
| |
| 3402 |
8 |
| xmlFree(localname); |
| 3403 |
|
| } |
| 3404 |
|
| else { |
| 3405 |
|
| xs_warn( " ordinary element " ); |
| 3406 |
|
| /* ordinary element */ |
| 3407 |
0 |
| localname = ename; |
| 3408 |
|
| |
| 3409 |
0 |
| newNode = xmlNewDocNode( self, NULL , localname, NULL ); |
| 3410 |
|
| } |
| 3411 |
|
| |
| 3412 |
8 |
| xmlSetNs(newNode, ns); |
| 3413 |
8 |
| docfrag = PmmNewFragment( self ); |
| 3414 |
8 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3415 |
8 |
| RETVAL = PmmNodeToSv(newNode, docfrag); |
| 3416 |
|
| |
| 3417 |
8 |
▶ | if ( prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL ) { |
7 |
1 |
8 |
|
| 3418 |
7 |
| xmlFree(prefix); |
| 3419 |
|
| } |
| 3420 |
8 |
▶ | if ( eURI != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( eURI != NULL ) { |
8 |
0 |
8 |
|
| 3421 |
8 |
| xmlFree(eURI); |
| 3422 |
|
| } |
| 3423 |
8 |
| xmlFree(ename); |
| 3424 |
|
| OUTPUT: |
| 3425 |
|
| RETVAL |
| 3426 |
|
| |
| 3427 |
|
| SV * |
| 3428 |
|
| createTextNode( self, content ) |
| 3429 |
|
| xmlDocPtr self |
| 3430 |
|
| SV * content |
| 3431 |
|
| PREINIT: |
| 3432 |
|
| xmlNodePtr newNode; |
| 3433 |
15 |
| xmlChar * elname = NULL; |
| 3434 |
15 |
| ProxyNodePtr docfrag = NULL; |
| 3435 |
|
| CODE: |
| 3436 |
15 |
| elname = nodeSv2C( content , (xmlNodePtr) self ); |
| 3437 |
15 |
▶ | if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
15 |
15 |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
0 |
0 |
|
| 3438 |
15 |
| newNode = xmlNewDocText( self, elname ); |
| 3439 |
15 |
| xmlFree(elname); |
| 3440 |
15 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
15 |
0 |
15 |
|
| 3441 |
15 |
| docfrag = PmmNewFragment( self ); |
| 3442 |
15 |
| newNode->doc = self; |
| 3443 |
15 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3444 |
15 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3445 |
|
| } |
| 3446 |
|
| else { |
| 3447 |
|
| xs_warn( "no node created!" ); |
| 3448 |
0 |
| XSRETURN_UNDEF; |
| 3449 |
|
| } |
| 3450 |
|
| } |
| 3451 |
|
| else { |
| 3452 |
0 |
| XSRETURN_UNDEF; |
| 3453 |
|
| } |
| 3454 |
|
| OUTPUT: |
| 3455 |
|
| RETVAL |
| 3456 |
|
| |
| 3457 |
|
| SV * |
| 3458 |
|
| createComment( self , content ) |
| 3459 |
|
| xmlDocPtr self |
| 3460 |
|
| SV * content |
| 3461 |
|
| PREINIT: |
| 3462 |
|
| xmlNodePtr newNode; |
| 3463 |
6 |
| xmlChar * elname = NULL; |
| 3464 |
6 |
| ProxyNodePtr docfrag = NULL; |
| 3465 |
|
| CODE: |
| 3466 |
6 |
| elname = nodeSv2C( content , (xmlNodePtr) self ); |
| 3467 |
6 |
▶ | if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
6 |
6 |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
0 |
0 |
|
| 3468 |
6 |
| newNode = xmlNewDocComment( self, elname ); |
| 3469 |
6 |
| xmlFree(elname); |
| 3470 |
6 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
6 |
0 |
6 |
|
| 3471 |
6 |
| docfrag = PmmNewFragment( self ); |
| 3472 |
6 |
| newNode->doc = self; |
| 3473 |
6 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3474 |
|
| xs_warn( newNode->name ); |
| 3475 |
6 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3476 |
|
| } |
| 3477 |
|
| else { |
| 3478 |
|
| xs_warn( "no node created!" ); |
| 3479 |
0 |
| XSRETURN_UNDEF; |
| 3480 |
|
| } |
| 3481 |
|
| } |
| 3482 |
|
| else { |
| 3483 |
0 |
| XSRETURN_UNDEF; |
| 3484 |
|
| } |
| 3485 |
|
| OUTPUT: |
| 3486 |
|
| RETVAL |
| 3487 |
|
| |
| 3488 |
|
| SV * |
| 3489 |
|
| createCDATASection( self, content ) |
| 3490 |
|
| xmlDocPtr self |
| 3491 |
|
| SV * content |
| 3492 |
|
| PREINIT: |
| 3493 |
|
| xmlNodePtr newNode; |
| 3494 |
6 |
| xmlChar * elname = NULL; |
| 3495 |
6 |
| ProxyNodePtr docfrag = NULL; |
| 3496 |
|
| CODE: |
| 3497 |
6 |
| elname = nodeSv2C( content , (xmlNodePtr)self ); |
| 3498 |
6 |
▶ | if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
6 |
6 |
| if ( elname != NULL || xmlStrlen(elname) > 0 ) { |
0 |
0 |
0 |
|
| 3499 |
6 |
| newNode = xmlNewCDataBlock( self, elname, xmlStrlen(elname) ); |
| 3500 |
6 |
| xmlFree(elname); |
| 3501 |
6 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
6 |
0 |
6 |
|
| 3502 |
6 |
| docfrag = PmmNewFragment( self ); |
| 3503 |
6 |
| newNode->doc = self; |
| 3504 |
6 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3505 |
|
| xs_warn( "[CDATA section]" ); |
| 3506 |
6 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3507 |
|
| } |
| 3508 |
|
| else { |
| 3509 |
|
| xs_warn( "no node created!" ); |
| 3510 |
0 |
| XSRETURN_UNDEF; |
| 3511 |
|
| } |
| 3512 |
|
| } |
| 3513 |
|
| else { |
| 3514 |
0 |
| XSRETURN_UNDEF; |
| 3515 |
|
| } |
| 3516 |
|
| OUTPUT: |
| 3517 |
|
| RETVAL |
| 3518 |
|
| |
| 3519 |
|
| SV* |
| 3520 |
|
| createEntityReference( self , pname ) |
| 3521 |
|
| xmlDocPtr self |
| 3522 |
|
| SV * pname |
| 3523 |
|
| PREINIT: |
| 3524 |
|
| xmlNodePtr newNode; |
| 3525 |
2 |
| xmlChar * name = Sv2C( pname, NULL ); |
| 3526 |
2 |
| ProxyNodePtr docfrag = NULL; |
| 3527 |
|
| CODE: |
| 3528 |
2 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
2 |
2 |
|
| 3529 |
0 |
| XSRETURN_UNDEF; |
| 3530 |
|
| } |
| 3531 |
2 |
| newNode = xmlNewReference( self, name ); |
| 3532 |
2 |
| xmlFree(name); |
| 3533 |
2 |
▶ | if ( newNode == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode == NULL ) { |
0 |
2 |
2 |
|
| 3534 |
0 |
| XSRETURN_UNDEF; |
| 3535 |
|
| } |
| 3536 |
2 |
| docfrag = PmmNewFragment( self ); |
| 3537 |
2 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3538 |
2 |
| RETVAL = PmmNodeToSv( newNode, docfrag ); |
| 3539 |
|
| OUTPUT: |
| 3540 |
|
| RETVAL |
| 3541 |
|
| |
| 3542 |
|
| SV* |
| 3543 |
|
| createAttribute( self, pname, pvalue=&PL_sv_undef ) |
| 3544 |
|
| xmlDocPtr self |
| 3545 |
|
| SV * pname |
| 3546 |
|
| SV * pvalue |
| 3547 |
|
| PREINIT: |
| 3548 |
24 |
| xmlChar * name = NULL; |
| 3549 |
24 |
| xmlChar * value = NULL; |
| 3550 |
24 |
| xmlAttrPtr newAttr = NULL; |
| 3551 |
24 |
| xmlChar * buffer = NULL; |
| 3552 |
|
| CODE: |
| 3553 |
24 |
| name = nodeSv2C( pname , (xmlNodePtr) self ); |
| 3554 |
24 |
▶ | if ( !LibXML_test_node_name( name ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( name ) ) { |
18 |
6 |
24 |
|
| 3555 |
18 |
| xmlFree(name); |
| 3556 |
18 |
| XSRETURN_UNDEF; |
| 3557 |
|
| } |
| 3558 |
|
| |
| 3559 |
6 |
| value = nodeSv2C( pvalue , (xmlNodePtr) self ); |
| 3560 |
|
| /* unlike xmlSetProp, xmlNewDocProp does not encode entities in value */ |
| 3561 |
6 |
| buffer = xmlEncodeEntitiesReentrant(self, value); |
| 3562 |
6 |
| newAttr = xmlNewDocProp( self, name, buffer ); |
| 3563 |
6 |
| RETVAL = PmmNodeToSv((xmlNodePtr)newAttr, PmmPROXYNODE(self)); |
| 3564 |
|
| |
| 3565 |
6 |
| xmlFree(name); |
| 3566 |
6 |
| xmlFree(buffer); |
| 3567 |
6 |
▶ | if ( value ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value ) { |
6 |
0 |
6 |
|
| 3568 |
6 |
| xmlFree(value); |
| 3569 |
|
| } |
| 3570 |
|
| OUTPUT: |
| 3571 |
|
| RETVAL |
| 3572 |
|
| |
| 3573 |
|
| SV* |
| 3574 |
|
| createAttributeNS( self, URI, pname, pvalue=&PL_sv_undef ) |
| 3575 |
|
| xmlDocPtr self |
| 3576 |
|
| SV * URI |
| 3577 |
|
| SV * pname |
| 3578 |
|
| SV * pvalue |
| 3579 |
|
| PREINIT: |
| 3580 |
29 |
| xmlChar * name = NULL; |
| 3581 |
29 |
| xmlChar * value = NULL; |
| 3582 |
29 |
| xmlChar * prefix = NULL; |
| 3583 |
29 |
| const xmlChar * pchar = NULL; |
| 3584 |
29 |
| xmlChar * localname = NULL; |
| 3585 |
29 |
| xmlChar * nsURI = NULL; |
| 3586 |
29 |
| xmlAttrPtr newAttr = NULL; |
| 3587 |
29 |
| xmlNsPtr ns = NULL; |
| 3588 |
|
| CODE: |
| 3589 |
29 |
| name = nodeSv2C( pname , (xmlNodePtr) self ); |
| 3590 |
29 |
▶ | if ( !LibXML_test_node_name( name ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( name ) ) { |
18 |
11 |
29 |
|
| 3591 |
18 |
| xmlFree(name); |
| 3592 |
18 |
| XSRETURN_UNDEF; |
| 3593 |
|
| } |
| 3594 |
|
| |
| 3595 |
11 |
| nsURI = Sv2C( URI , NULL ); |
| 3596 |
11 |
| value = nodeSv2C( pvalue, (xmlNodePtr) self ); |
| 3597 |
|
| |
| 3598 |
19 |
▶ | if ( nsURI != NULL && xmlStrlen(nsURI) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI != NULL && xmlStrlen(nsURI) > 0 ) { |
9 |
2 |
11 |
| if ( nsURI != NULL && xmlStrlen(nsURI) > 0 ) { |
9 |
0 |
9 |
|
| 3599 |
9 |
| xmlNodePtr root = xmlDocGetRootElement(self ); |
| 3600 |
9 |
▶ | if ( root ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( root ) { |
8 |
1 |
9 |
|
| 3601 |
8 |
| pchar = xmlStrchr(name, ':'); |
| 3602 |
8 |
▶ | if ( pchar != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( pchar != NULL ) { |
8 |
0 |
8 |
|
| 3603 |
8 |
| localname = xmlSplitQName2(name, &prefix); |
| 3604 |
|
| } |
| 3605 |
|
| else { |
| 3606 |
0 |
| localname = xmlStrdup( name ); |
| 3607 |
|
| } |
| 3608 |
8 |
| ns = xmlSearchNsByHref( self, root, nsURI ); |
| 3609 |
8 |
▶ | if ( ns == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == NULL ) { |
5 |
3 |
8 |
|
| 3610 |
|
| /* create a new NS if the NS does not already exists */ |
| 3611 |
5 |
| ns = xmlNewNs(root, nsURI , prefix ); |
| 3612 |
|
| } |
| 3613 |
|
| |
| 3614 |
8 |
▶ | if ( ns == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == NULL ) { |
0 |
8 |
8 |
|
| 3615 |
0 |
| xmlFree(nsURI); |
| 3616 |
0 |
| xmlFree(localname); |
| 3617 |
0 |
▶ | if ( prefix ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix ) { |
0 |
0 |
0 |
|
| 3618 |
0 |
| xmlFree(prefix); |
| 3619 |
|
| } |
| 3620 |
0 |
| xmlFree(name); |
| 3621 |
0 |
▶ | if ( value ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value ) { |
0 |
0 |
0 |
|
| 3622 |
0 |
| xmlFree(value); |
| 3623 |
|
| } |
| 3624 |
0 |
| XSRETURN_UNDEF; |
| 3625 |
|
| } |
| 3626 |
|
| |
| 3627 |
8 |
| newAttr = xmlNewDocProp( self, localname, value ); |
| 3628 |
8 |
| xmlSetNs((xmlNodePtr)newAttr, ns); |
| 3629 |
|
| |
| 3630 |
8 |
| RETVAL = PmmNodeToSv((xmlNodePtr)newAttr, PmmPROXYNODE(self) ); |
| 3631 |
|
| |
| 3632 |
8 |
| xmlFree(nsURI); |
| 3633 |
8 |
| xmlFree(name); |
| 3634 |
8 |
▶ | if ( prefix ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix ) { |
8 |
0 |
8 |
|
| 3635 |
8 |
| xmlFree(prefix); |
| 3636 |
|
| } |
| 3637 |
8 |
| xmlFree(localname); |
| 3638 |
8 |
▶ | if ( value ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value ) { |
8 |
0 |
8 |
|
| 3639 |
8 |
| xmlFree(value); |
| 3640 |
|
| } |
| 3641 |
|
| } |
| 3642 |
|
| else { |
| 3643 |
1 |
| xmlFree(nsURI); |
| 3644 |
1 |
| xmlFree(name); |
| 3645 |
1 |
▶ | if ( value ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value ) { |
1 |
0 |
1 |
|
| 3646 |
1 |
| xmlFree(value); |
| 3647 |
|
| } |
| 3648 |
1 |
| croak( "can't create a new namespace on an attribute!" ); |
| 3649 |
|
| } |
| 3650 |
|
| } |
| 3651 |
|
| else { |
| 3652 |
|
| xmlChar *buffer; |
| 3653 |
|
| /* unlike xmlSetProp, xmlNewDocProp does not encode entities in value */ |
| 3654 |
2 |
| buffer = xmlEncodeEntitiesReentrant(self, value); |
| 3655 |
2 |
| newAttr = xmlNewDocProp( self, name, buffer ); |
| 3656 |
2 |
| RETVAL = PmmNodeToSv((xmlNodePtr)newAttr,PmmPROXYNODE(self)); |
| 3657 |
2 |
| xmlFree(name); |
| 3658 |
2 |
| xmlFree(buffer); |
| 3659 |
2 |
▶ | if ( value ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value ) { |
2 |
0 |
2 |
|
| 3660 |
2 |
| xmlFree(value); |
| 3661 |
|
| } |
| 3662 |
|
| } |
| 3663 |
|
| OUTPUT: |
| 3664 |
|
| RETVAL |
| 3665 |
|
| |
| 3666 |
|
| SV* |
| 3667 |
|
| createProcessingInstruction(self, name, value=&PL_sv_undef) |
| 3668 |
|
| xmlDocPtr self |
| 3669 |
|
| SV * name |
| 3670 |
|
| SV * value |
| 3671 |
|
| ALIAS: |
| 3672 |
|
| createPI = 1 |
| 3673 |
|
| PREINIT: |
| 3674 |
4 |
| xmlChar * n = NULL; |
| 3675 |
4 |
| xmlChar * v = NULL; |
| 3676 |
4 |
| xmlNodePtr newNode = NULL; |
| 3677 |
4 |
| ProxyNodePtr docfrag = NULL; |
| 3678 |
|
| CODE: |
| 3679 |
|
| PERL_UNUSED_VAR(ix); |
| 3680 |
4 |
| n = nodeSv2C(name, (xmlNodePtr)self); |
| 3681 |
4 |
▶ | if ( !n ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !n ) { |
0 |
4 |
4 |
|
| 3682 |
0 |
| XSRETURN_UNDEF; |
| 3683 |
|
| } |
| 3684 |
4 |
| v = nodeSv2C(value, (xmlNodePtr)self); |
| 3685 |
4 |
| newNode = xmlNewPI(n,v); |
| 3686 |
4 |
| xmlFree(v); |
| 3687 |
4 |
| xmlFree(n); |
| 3688 |
4 |
▶ | if ( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ) { |
4 |
0 |
4 |
|
| 3689 |
4 |
| docfrag = PmmNewFragment( self ); |
| 3690 |
4 |
| newNode->doc = self; |
| 3691 |
4 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 3692 |
4 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 3693 |
|
| } else { |
| 3694 |
|
| xs_warn( "no node created!" ); |
| 3695 |
0 |
| XSRETURN_UNDEF; |
| 3696 |
|
| } |
| 3697 |
|
| OUTPUT: |
| 3698 |
|
| RETVAL |
| 3699 |
|
| |
| 3700 |
|
| void |
| 3701 |
|
| _setDocumentElement( self , proxy ) |
| 3702 |
|
| xmlDocPtr self |
| 3703 |
|
| SV * proxy |
| 3704 |
|
| PREINIT: |
| 3705 |
|
| xmlNodePtr elem, oelem; |
| 3706 |
|
| INIT: |
| 3707 |
97 |
| elem = PmmSvNode(proxy); |
| 3708 |
97 |
▶ | if ( elem == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( elem == NULL ) { |
0 |
97 |
97 |
|
| 3709 |
0 |
| XSRETURN_UNDEF; |
| 3710 |
|
| } |
| 3711 |
|
| CODE: |
| 3712 |
|
| /* please correct me if i am wrong: the document element HAS to be |
| 3713 |
|
| * an ELEMENT NODE |
| 3714 |
|
| */ |
| 3715 |
97 |
▶ | if ( elem->type == XML_ELEMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( elem->type == XML_ELEMENT_NODE ) { |
97 |
0 |
97 |
|
| 3716 |
97 |
▶ | if ( self != elem->doc ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self != elem->doc ) { |
2 |
95 |
97 |
|
| 3717 |
2 |
| domImportNode( self, elem, 1, 1 ); |
| 3718 |
|
| } |
| 3719 |
|
| |
| 3720 |
97 |
| oelem = xmlDocGetRootElement( self ); |
| 3721 |
97 |
▶ | if ( oelem == NULL || oelem->_private == NULL ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( oelem == NULL || oelem->_private == NULL ) { |
0 |
97 |
97 |
| if ( oelem == NULL || oelem->_private == NULL ) { |
0 |
0 |
0 |
|
| 3722 |
97 |
| xmlDocSetRootElement( self, elem ); |
| 3723 |
|
| } |
| 3724 |
|
| else { |
| 3725 |
0 |
| ProxyNodePtr docfrag = PmmNewFragment( self ); |
| 3726 |
0 |
| xmlReplaceNode( oelem, elem ); |
| 3727 |
0 |
| xmlAddChild( PmmNODE(docfrag), oelem ); |
| 3728 |
0 |
| PmmFixOwner( ((ProxyNodePtr)oelem->_private), docfrag); |
| 3729 |
|
| } |
| 3730 |
|
| |
| 3731 |
97 |
▶ | if ( elem->_private != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( elem->_private != NULL ) { |
97 |
0 |
97 |
|
| 3732 |
97 |
| PmmFixOwner( SvPROXYNODE(proxy), PmmPROXYNODE(self)); |
| 3733 |
|
| } |
| 3734 |
|
| } else { |
| 3735 |
0 |
| croak("setDocumentElement: ELEMENT node required"); |
| 3736 |
|
| } |
| 3737 |
|
| |
| 3738 |
|
| SV * |
| 3739 |
|
| documentElement( self ) |
| 3740 |
|
| xmlDocPtr self |
| 3741 |
|
| ALIAS: |
| 3742 |
|
| XML::LibXML::Document::getDocumentElement = 1 |
| 3743 |
|
| PREINIT: |
| 3744 |
|
| xmlNodePtr elem; |
| 3745 |
|
| CODE: |
| 3746 |
|
| PERL_UNUSED_VAR(ix); |
| 3747 |
256 |
| elem = xmlDocGetRootElement( self ); |
| 3748 |
256 |
▶ | if ( elem ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( elem ) { |
160 |
96 |
256 |
|
| 3749 |
160 |
| RETVAL = PmmNodeToSv(elem, PmmPROXYNODE(self)); |
| 3750 |
|
| } |
| 3751 |
|
| else { |
| 3752 |
96 |
| XSRETURN_UNDEF; |
| 3753 |
|
| } |
| 3754 |
|
| OUTPUT: |
| 3755 |
|
| RETVAL |
| 3756 |
|
| |
| 3757 |
|
| SV * |
| 3758 |
|
| externalSubset( self ) |
| 3759 |
|
| xmlDocPtr self |
| 3760 |
|
| PREINIT: |
| 3761 |
|
| xmlDtdPtr dtd; |
| 3762 |
|
| CODE: |
| 3763 |
10 |
▶ | if ( self->extSubset == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->extSubset == NULL ) { |
8 |
2 |
10 |
|
| 3764 |
8 |
| XSRETURN_UNDEF; |
| 3765 |
|
| } |
| 3766 |
|
| |
| 3767 |
2 |
| dtd = self->extSubset; |
| 3768 |
2 |
| RETVAL = PmmNodeToSv((xmlNodePtr)dtd, PmmPROXYNODE(self)); |
| 3769 |
|
| OUTPUT: |
| 3770 |
|
| RETVAL |
| 3771 |
|
| |
| 3772 |
|
| SV * |
| 3773 |
|
| internalSubset( self ) |
| 3774 |
|
| xmlDocPtr self |
| 3775 |
|
| PREINIT: |
| 3776 |
|
| xmlDtdPtr dtd; |
| 3777 |
|
| CODE: |
| 3778 |
41 |
▶ | if ( self->intSubset == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->intSubset == NULL ) { |
5 |
36 |
41 |
|
| 3779 |
5 |
| XSRETURN_UNDEF; |
| 3780 |
|
| } |
| 3781 |
|
| |
| 3782 |
36 |
| dtd = self->intSubset; |
| 3783 |
36 |
| RETVAL = PmmNodeToSv(INT2PTR(xmlNodePtr,dtd), PmmPROXYNODE(self)); |
| 3784 |
|
| OUTPUT: |
| 3785 |
|
| RETVAL |
| 3786 |
|
| |
| 3787 |
|
| void |
| 3788 |
|
| setExternalSubset( self, extdtd ) |
| 3789 |
|
| xmlDocPtr self |
| 3790 |
|
| SV * extdtd |
| 3791 |
|
| PREINIT: |
| 3792 |
2 |
| xmlDtdPtr dtd = NULL; |
| 3793 |
2 |
| xmlDtdPtr olddtd = NULL; |
| 3794 |
|
| INIT: |
| 3795 |
2 |
| dtd = (xmlDtdPtr)PmmSvNode(extdtd); |
| 3796 |
2 |
▶ | if ( dtd == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd == NULL ) { |
0 |
2 |
2 |
|
| 3797 |
0 |
| croak( "lost DTD node" ); |
| 3798 |
|
| } |
| 3799 |
|
| CODE: |
| 3800 |
2 |
▶ | if ( dtd && dtd != self->extSubset ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( dtd && dtd != self->extSubset ) { |
2 |
0 |
2 |
| if ( dtd && dtd != self->extSubset ) { |
2 |
0 |
2 |
|
| 3801 |
2 |
▶ | if ( dtd->doc == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd->doc == NULL ) { |
0 |
2 |
2 |
|
| 3802 |
0 |
| xmlSetTreeDoc( (xmlNodePtr) dtd, self ); |
| 3803 |
2 |
▶ | } else if ( dtd->doc != self ) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if ( dtd->doc != self ) { |
0 |
2 |
2 |
|
| 3804 |
0 |
| domImportNode( self, (xmlNodePtr) dtd,1,1); |
| 3805 |
|
| } |
| 3806 |
|
| |
| 3807 |
2 |
▶ | if ( dtd == self->intSubset ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd == self->intSubset ) { |
1 |
1 |
2 |
|
| 3808 |
1 |
| xmlUnlinkNode( (xmlNodePtr)dtd ); |
| 3809 |
1 |
| self->intSubset = NULL; |
| 3810 |
|
| } |
| 3811 |
|
| |
| 3812 |
2 |
| olddtd = self->extSubset; |
| 3813 |
2 |
▶ | if ( olddtd && olddtd->_private == NULL ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( olddtd && olddtd->_private == NULL ) { |
0 |
2 |
2 |
| if ( olddtd && olddtd->_private == NULL ) { |
0 |
0 |
0 |
|
| 3814 |
0 |
| xmlFreeDtd( olddtd ); |
| 3815 |
|
| } |
| 3816 |
2 |
| self->extSubset = dtd; |
| 3817 |
|
| } |
| 3818 |
|
| |
| 3819 |
|
| void |
| 3820 |
|
| setInternalSubset( self, extdtd ) |
| 3821 |
|
| xmlDocPtr self |
| 3822 |
|
| SV * extdtd |
| 3823 |
|
| PREINIT: |
| 3824 |
2 |
| xmlDtdPtr dtd = NULL; |
| 3825 |
2 |
| xmlDtdPtr olddtd = NULL; |
| 3826 |
|
| INIT: |
| 3827 |
2 |
| dtd = (xmlDtdPtr)PmmSvNode(extdtd); |
| 3828 |
2 |
▶ | if ( dtd == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd == NULL ) { |
0 |
2 |
2 |
|
| 3829 |
0 |
| croak( "lost DTD node" ); |
| 3830 |
|
| } |
| 3831 |
|
| CODE: |
| 3832 |
2 |
▶ | if ( dtd && dtd != self->intSubset ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( dtd && dtd != self->intSubset ) { |
2 |
0 |
2 |
| if ( dtd && dtd != self->intSubset ) { |
2 |
0 |
2 |
|
| 3833 |
2 |
▶ | if ( dtd->doc != self ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd->doc != self ) { |
0 |
2 |
2 |
|
| 3834 |
0 |
| croak( "can't import DTDs" ); |
| 3835 |
|
| domImportNode( self, (xmlNodePtr) dtd,1,1); |
| 3836 |
|
| } |
| 3837 |
|
| |
| 3838 |
2 |
▶ | if ( dtd == self->extSubset ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd == self->extSubset ) { |
1 |
1 |
2 |
|
| 3839 |
1 |
| self->extSubset = NULL; |
| 3840 |
|
| } |
| 3841 |
|
| |
| 3842 |
2 |
| olddtd = xmlGetIntSubset( self ); |
| 3843 |
2 |
▶ | if( olddtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( olddtd ) { |
1 |
1 |
2 |
|
| 3844 |
1 |
| xmlReplaceNode( (xmlNodePtr)olddtd, (xmlNodePtr) dtd ); |
| 3845 |
1 |
▶ | if ( olddtd->_private == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( olddtd->_private == NULL ) { |
0 |
1 |
1 |
|
| 3846 |
0 |
| xmlFreeDtd( olddtd ); |
| 3847 |
|
| } |
| 3848 |
|
| } |
| 3849 |
|
| else { |
| 3850 |
1 |
▶ | if (self->children == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->children == NULL) |
1 |
0 |
1 |
|
| 3851 |
1 |
| xmlAddChild((xmlNodePtr) self, (xmlNodePtr) dtd); |
| 3852 |
|
| else |
| 3853 |
0 |
| xmlAddPrevSibling(self->children, (xmlNodePtr) dtd); |
| 3854 |
|
| } |
| 3855 |
2 |
| self->intSubset = dtd; |
| 3856 |
|
| } |
| 3857 |
|
| |
| 3858 |
|
| SV * |
| 3859 |
|
| removeInternalSubset( self ) |
| 3860 |
|
| xmlDocPtr self |
| 3861 |
|
| PREINIT: |
| 3862 |
1 |
| xmlDtdPtr dtd = NULL; |
| 3863 |
|
| CODE: |
| 3864 |
1 |
| dtd = xmlGetIntSubset(self); |
| 3865 |
1 |
▶ | if ( !dtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !dtd ) { |
0 |
1 |
1 |
|
| 3866 |
0 |
| XSRETURN_UNDEF; |
| 3867 |
|
| } |
| 3868 |
1 |
| xmlUnlinkNode( (xmlNodePtr)dtd ); |
| 3869 |
1 |
| self->intSubset = NULL; |
| 3870 |
1 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)dtd, PmmPROXYNODE(self) ); |
| 3871 |
|
| OUTPUT: |
| 3872 |
|
| RETVAL |
| 3873 |
|
| |
| 3874 |
|
| SV * |
| 3875 |
|
| removeExternalSubset( self ) |
| 3876 |
|
| xmlDocPtr self |
| 3877 |
|
| PREINIT: |
| 3878 |
1 |
| xmlDtdPtr dtd = NULL; |
| 3879 |
|
| CODE: |
| 3880 |
1 |
| dtd = self->extSubset; |
| 3881 |
1 |
▶ | if ( !dtd ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !dtd ) { |
0 |
1 |
1 |
|
| 3882 |
0 |
| XSRETURN_UNDEF; |
| 3883 |
|
| } |
| 3884 |
1 |
| self->extSubset = NULL; |
| 3885 |
1 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)dtd, PmmPROXYNODE(self) ); |
| 3886 |
|
| OUTPUT: |
| 3887 |
|
| RETVAL |
| 3888 |
|
| |
| 3889 |
|
| SV * |
| 3890 |
|
| importNode( self, node, dummy=0 ) |
| 3891 |
|
| xmlDocPtr self |
| 3892 |
|
| xmlNodePtr node |
| 3893 |
|
| int dummy |
| 3894 |
|
| PREINIT: |
| 3895 |
4 |
| xmlNodePtr ret = NULL; |
| 3896 |
4 |
| ProxyNodePtr docfrag = NULL; |
| 3897 |
|
| CODE: |
| 3898 |
4 |
▶ | if ( node->type == XML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node->type == XML_DOCUMENT_NODE |
4 |
0 |
4 |
|
| 3899 |
4 |
▶ | || node->type == XML_HTML_DOCUMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || node->type == XML_HTML_DOCUMENT_NODE ) { |
0 |
4 |
4 |
|
| 3900 |
0 |
| croak( "Can't import Documents!" ); |
| 3901 |
|
| XSRETURN_UNDEF; |
| 3902 |
|
| } |
| 3903 |
4 |
▶ | if (node->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_DTD_NODE) { |
0 |
4 |
4 |
|
| 3904 |
0 |
| croak("Can't import DTD nodes"); |
| 3905 |
|
| } |
| 3906 |
|
| |
| 3907 |
4 |
| ret = domImportNode( self, node, 0, 1 ); |
| 3908 |
4 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
4 |
0 |
4 |
|
| 3909 |
4 |
| docfrag = PmmNewFragment( self ); |
| 3910 |
4 |
| xmlAddChild( PmmNODE(docfrag), ret ); |
| 3911 |
4 |
| RETVAL = PmmNodeToSv( ret, docfrag); |
| 3912 |
|
| } |
| 3913 |
|
| else { |
| 3914 |
0 |
| XSRETURN_UNDEF; |
| 3915 |
|
| } |
| 3916 |
|
| OUTPUT: |
| 3917 |
|
| RETVAL |
| 3918 |
|
| |
| 3919 |
|
| SV * |
| 3920 |
|
| adoptNode( self, node ) |
| 3921 |
|
| xmlDocPtr self |
| 3922 |
|
| xmlNodePtr node |
| 3923 |
|
| PREINIT: |
| 3924 |
7 |
| xmlNodePtr ret = NULL; |
| 3925 |
7 |
| ProxyNodePtr docfrag = NULL; |
| 3926 |
|
| CODE: |
| 3927 |
7 |
▶ | if ( node->type == XML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node->type == XML_DOCUMENT_NODE |
7 |
0 |
7 |
|
| 3928 |
7 |
▶ | || node->type == XML_HTML_DOCUMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || node->type == XML_HTML_DOCUMENT_NODE ) { |
0 |
7 |
7 |
|
| 3929 |
0 |
| croak( "Can't adopt Documents!" ); |
| 3930 |
|
| XSRETURN_UNDEF; |
| 3931 |
|
| } |
| 3932 |
7 |
▶ | if (node->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_DTD_NODE) { |
0 |
7 |
7 |
|
| 3933 |
0 |
| croak("Can't adopt DTD nodes"); |
| 3934 |
|
| } |
| 3935 |
|
| |
| 3936 |
7 |
| ret = domImportNode( self, node, 1, 1 ); |
| 3937 |
|
| |
| 3938 |
7 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
7 |
0 |
7 |
|
| 3939 |
7 |
| docfrag = PmmNewFragment( self ); |
| 3940 |
7 |
| RETVAL = PmmNodeToSv(node, docfrag); |
| 3941 |
7 |
| xmlAddChild( PmmNODE(docfrag), ret ); |
| 3942 |
7 |
| PmmFixOwner(SvPROXYNODE(RETVAL), docfrag); |
| 3943 |
|
| } |
| 3944 |
|
| else { |
| 3945 |
0 |
| XSRETURN_UNDEF; |
| 3946 |
|
| } |
| 3947 |
|
| OUTPUT: |
| 3948 |
|
| RETVAL |
| 3949 |
|
| |
| 3950 |
|
| char* |
| 3951 |
|
| encoding( self ) |
| 3952 |
|
| xmlDocPtr self |
| 3953 |
|
| ALIAS: |
| 3954 |
|
| XML::LibXML::Document::getEncoding = 1 |
| 3955 |
|
| XML::LibXML::Document::xmlEncoding = 2 |
| 3956 |
|
| CODE: |
| 3957 |
|
| PERL_UNUSED_VAR(ix); |
| 3958 |
23 |
| RETVAL = (char *) self->encoding; |
| 3959 |
|
| OUTPUT: |
| 3960 |
|
| RETVAL |
| 3961 |
|
| |
| 3962 |
|
| void |
| 3963 |
|
| setEncoding( self, encoding = NULL ) |
| 3964 |
|
| xmlDocPtr self |
| 3965 |
|
| char *encoding |
| 3966 |
|
| PREINIT: |
| 3967 |
7 |
| int charset = XML_CHAR_ENCODING_ERROR; |
| 3968 |
|
| CODE: |
| 3969 |
7 |
▶ | if ( self->encoding != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->encoding != NULL ) { |
1 |
6 |
7 |
|
| 3970 |
1 |
| xmlFree( (xmlChar*) self->encoding ); |
| 3971 |
|
| } |
| 3972 |
7 |
▶ | if (encoding!=NULL && strlen(encoding)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (encoding!=NULL && strlen(encoding)) { |
6 |
1 |
7 |
| if (encoding!=NULL && strlen(encoding)) { |
6 |
0 |
6 |
|
| 3973 |
6 |
| self->encoding = xmlStrdup( (const xmlChar *)encoding ); |
| 3974 |
6 |
| charset = (int)xmlParseCharEncoding( (const char*)self->encoding ); |
| 3975 |
6 |
▶ | if ( charset <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( charset <= 0 ) { |
0 |
6 |
6 |
|
| 3976 |
0 |
| charset = XML_CHAR_ENCODING_ERROR; |
| 3977 |
|
| } |
| 3978 |
|
| } else { |
| 3979 |
1 |
| self->encoding=NULL; |
| 3980 |
1 |
| charset = XML_CHAR_ENCODING_UTF8; |
| 3981 |
|
| } |
| 3982 |
7 |
| SetPmmNodeEncoding(self, charset); |
| 3983 |
|
| |
| 3984 |
|
| |
| 3985 |
|
| int |
| 3986 |
|
| standalone( self ) |
| 3987 |
|
| xmlDocPtr self |
| 3988 |
|
| ALIAS: |
| 3989 |
|
| XML::LibXML::Document::xmlStandalone = 1 |
| 3990 |
|
| CODE: |
| 3991 |
|
| PERL_UNUSED_VAR(ix); |
| 3992 |
3 |
▶ | RETVAL = self->standalone; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->standalone; |
0 |
3 |
3 |
|
| 3993 |
|
| OUTPUT: |
| 3994 |
|
| RETVAL |
| 3995 |
|
| |
| 3996 |
|
| void |
| 3997 |
|
| setStandalone( self, value = 0 ) |
| 3998 |
|
| xmlDocPtr self |
| 3999 |
|
| int value |
| 4000 |
|
| CODE: |
| 4001 |
1 |
▶ | if ( value > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value > 0 ) { |
1 |
0 |
1 |
|
| 4002 |
1 |
| self->standalone = 1; |
| 4003 |
|
| } |
| 4004 |
0 |
▶ | else if ( value < 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( value < 0 ) { |
0 |
0 |
0 |
|
| 4005 |
0 |
| self->standalone = -1; |
| 4006 |
|
| } |
| 4007 |
|
| else { |
| 4008 |
0 |
| self->standalone = 0; |
| 4009 |
|
| } |
| 4010 |
|
| |
| 4011 |
|
| char* |
| 4012 |
|
| version( self ) |
| 4013 |
|
| xmlDocPtr self |
| 4014 |
|
| ALIAS: |
| 4015 |
|
| XML::LibXML::Document::getVersion = 1 |
| 4016 |
|
| XML::LibXML::Document::xmlVersion = 2 |
| 4017 |
|
| CODE: |
| 4018 |
|
| PERL_UNUSED_VAR(ix); |
| 4019 |
15 |
| RETVAL = (char *) self->version; |
| 4020 |
|
| OUTPUT: |
| 4021 |
|
| RETVAL |
| 4022 |
|
| |
| 4023 |
|
| void |
| 4024 |
|
| setVersion( self, version ) |
| 4025 |
|
| xmlDocPtr self |
| 4026 |
|
| char *version |
| 4027 |
|
| CODE: |
| 4028 |
71 |
▶ | if ( self->version != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->version != NULL ) { |
71 |
0 |
71 |
|
| 4029 |
71 |
| xmlFree( (xmlChar*) self->version ); |
| 4030 |
|
| } |
| 4031 |
71 |
| self->version = xmlStrdup( (const xmlChar*)version ); |
| 4032 |
|
| |
| 4033 |
|
| int |
| 4034 |
|
| compression( self ) |
| 4035 |
|
| xmlDocPtr self |
| 4036 |
|
| CODE: |
| 4037 |
1 |
| RETVAL = xmlGetDocCompressMode(self); |
| 4038 |
|
| OUTPUT: |
| 4039 |
|
| RETVAL |
| 4040 |
|
| |
| 4041 |
|
| void |
| 4042 |
|
| setCompression( self, zLevel ) |
| 4043 |
|
| xmlDocPtr self |
| 4044 |
|
| int zLevel |
| 4045 |
|
| CODE: |
| 4046 |
0 |
| xmlSetDocCompressMode(self, zLevel); |
| 4047 |
|
| |
| 4048 |
|
| |
| 4049 |
|
| int |
| 4050 |
|
| is_valid(self, ...) |
| 4051 |
|
| xmlDocPtr self |
| 4052 |
|
| PREINIT: |
| 4053 |
|
| xmlValidCtxt cvp; |
| 4054 |
3 |
| xmlDtdPtr dtd = NULL; |
| 4055 |
|
| SV * dtd_sv; |
| 4056 |
3 |
| PREINIT_SAVED_ERROR |
| 4057 |
|
| CODE: |
| 4058 |
3 |
| INIT_ERROR_HANDLER; |
| 4059 |
|
| |
| 4060 |
3 |
| memset(&cvp, 0, sizeof(cvp)); |
| 4061 |
3 |
| cvp.userData = saved_error; |
| 4062 |
3 |
| cvp.error = (xmlValidityErrorFunc)LibXML_validity_error_ctx; |
| 4063 |
3 |
| cvp.warning = (xmlValidityWarningFunc)LibXML_validity_warning_ctx; |
| 4064 |
|
| |
| 4065 |
3 |
▶ | PmmClearPSVI(self); |
Branch: 4 branches
| Branch | True | False | Total |
| PmmClearPSVI(self); |
3 |
0 |
3 |
| PmmClearPSVI(self); |
3 |
0 |
3 |
| PmmClearPSVI(self); |
3 |
0 |
3 |
| PmmClearPSVI(self); |
1 |
2 |
3 |
|
| 4066 |
3 |
▶ | PmmInvalidatePSVI(self); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI(self); |
3 |
0 |
3 |
| PmmInvalidatePSVI(self); |
3 |
0 |
3 |
|
| 4067 |
3 |
▶ | if (items > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 1) { |
2 |
1 |
3 |
|
| 4068 |
2 |
| dtd_sv = ST(1); |
| 4069 |
2 |
▶ | if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
2 |
0 |
2 |
| if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
2 |
0 |
2 |
|
| 4070 |
2 |
| dtd = (xmlDtdPtr)PmmSvNode(dtd_sv); |
| 4071 |
|
| } |
| 4072 |
2 |
| RETVAL = xmlValidateDtd(&cvp, self, dtd); |
| 4073 |
|
| } |
| 4074 |
|
| else { |
| 4075 |
1 |
| RETVAL = xmlValidateDocument(&cvp, self); |
| 4076 |
|
| } |
| 4077 |
3 |
| CLEANUP_ERROR_HANDLER; |
| 4078 |
|
| /* REPORT_ERROR(1); */ |
| 4079 |
|
| OUTPUT: |
| 4080 |
|
| RETVAL |
| 4081 |
|
| |
| 4082 |
|
| int |
| 4083 |
|
| validate(self, ...) |
| 4084 |
|
| xmlDocPtr self |
| 4085 |
|
| PREINIT: |
| 4086 |
|
| xmlValidCtxt cvp; |
| 4087 |
|
| xmlDtdPtr dtd; |
| 4088 |
|
| SV * dtd_sv; |
| 4089 |
5 |
| PREINIT_SAVED_ERROR |
| 4090 |
|
| CODE: |
| 4091 |
5 |
| INIT_ERROR_HANDLER; |
| 4092 |
|
| |
| 4093 |
5 |
| memset(&cvp, 0, sizeof(cvp)); |
| 4094 |
5 |
| cvp.userData = saved_error; |
| 4095 |
5 |
| cvp.error = (xmlValidityErrorFunc)LibXML_validity_error_ctx; |
| 4096 |
5 |
| cvp.warning = (xmlValidityWarningFunc)LibXML_validity_warning_ctx; |
| 4097 |
|
| |
| 4098 |
5 |
▶ | PmmClearPSVI(self); |
Branch: 4 branches
| Branch | True | False | Total |
| PmmClearPSVI(self); |
5 |
0 |
5 |
| PmmClearPSVI(self); |
5 |
0 |
5 |
| PmmClearPSVI(self); |
5 |
0 |
5 |
| PmmClearPSVI(self); |
3 |
2 |
5 |
|
| 4099 |
5 |
▶ | PmmInvalidatePSVI(self); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI(self); |
5 |
0 |
5 |
| PmmInvalidatePSVI(self); |
5 |
0 |
5 |
|
| 4100 |
|
| |
| 4101 |
5 |
▶ | if (items > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 1) { |
2 |
3 |
5 |
|
| 4102 |
2 |
| dtd_sv = ST(1); |
| 4103 |
2 |
▶ | if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
2 |
0 |
2 |
| if ( sv_isobject(dtd_sv) && (SvTYPE(SvRV(dtd_sv)) == SVt_PVMG) ) { |
2 |
0 |
2 |
|
| 4104 |
2 |
| dtd = (xmlDtdPtr)PmmSvNode(dtd_sv); |
| 4105 |
|
| } |
| 4106 |
|
| else { |
| 4107 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 4108 |
0 |
| croak("is_valid: argument must be a DTD object"); |
| 4109 |
|
| } |
| 4110 |
2 |
| RETVAL = xmlValidateDtd(&cvp, self , dtd); |
| 4111 |
|
| } |
| 4112 |
|
| else { |
| 4113 |
3 |
| RETVAL = xmlValidateDocument(&cvp, self); |
| 4114 |
|
| } |
| 4115 |
5 |
| CLEANUP_ERROR_HANDLER; |
| 4116 |
5 |
| REPORT_ERROR(RETVAL ? 1 : 0); |
| 4117 |
|
| OUTPUT: |
| 4118 |
|
| RETVAL |
| 4119 |
|
| |
| 4120 |
|
| SV* |
| 4121 |
|
| cloneNode( self, deep=0 ) |
| 4122 |
|
| xmlDocPtr self |
| 4123 |
|
| int deep |
| 4124 |
|
| PREINIT: |
| 4125 |
2 |
| xmlDocPtr ret = NULL; |
| 4126 |
|
| CODE: |
| 4127 |
2 |
| ret = xmlCopyDoc( self, deep ); |
| 4128 |
2 |
▶ | if ( ret == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret == NULL ) { |
0 |
2 |
2 |
|
| 4129 |
0 |
| XSRETURN_UNDEF; |
| 4130 |
|
| } |
| 4131 |
2 |
| RETVAL = PmmNodeToSv((xmlNodePtr)ret, NULL); |
| 4132 |
|
| OUTPUT: |
| 4133 |
|
| RETVAL |
| 4134 |
|
| |
| 4135 |
|
| SV* |
| 4136 |
|
| getElementById( self, id ) |
| 4137 |
|
| xmlDocPtr self |
| 4138 |
|
| const char * id |
| 4139 |
|
| ALIAS: |
| 4140 |
|
| XML::LibXML::Document::getElementsById = 1 |
| 4141 |
|
| PREINIT: |
| 4142 |
|
| xmlNodePtr elem; |
| 4143 |
|
| xmlAttrPtr attr; |
| 4144 |
|
| CODE: |
| 4145 |
|
| PERL_UNUSED_VAR(ix); |
| 4146 |
22 |
▶ | if ( id != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( id != NULL ) { |
22 |
0 |
22 |
|
| 4147 |
22 |
| attr = xmlGetID(self, (xmlChar *) id); |
| 4148 |
22 |
▶ | if (attr == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (attr == NULL) |
5 |
17 |
22 |
|
| 4149 |
5 |
| elem = NULL; |
| 4150 |
17 |
▶ | else if (attr->type == XML_ATTRIBUTE_NODE) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (attr->type == XML_ATTRIBUTE_NODE) |
17 |
0 |
17 |
|
| 4151 |
17 |
| elem = attr->parent; |
| 4152 |
0 |
▶ | else if (attr->type == XML_ELEMENT_NODE) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (attr->type == XML_ELEMENT_NODE) |
0 |
0 |
0 |
|
| 4153 |
0 |
| elem = (xmlNodePtr) attr; |
| 4154 |
|
| else |
| 4155 |
0 |
| elem = NULL; |
| 4156 |
22 |
▶ | if (elem != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem != NULL) { |
17 |
5 |
22 |
|
| 4157 |
17 |
| RETVAL = PmmNodeToSv(elem, PmmPROXYNODE(self)); |
| 4158 |
|
| } |
| 4159 |
|
| else { |
| 4160 |
5 |
| XSRETURN_UNDEF; |
| 4161 |
|
| } |
| 4162 |
|
| } |
| 4163 |
|
| else { |
| 4164 |
0 |
| XSRETURN_UNDEF; |
| 4165 |
|
| } |
| 4166 |
|
| OUTPUT: |
| 4167 |
|
| RETVAL |
| 4168 |
|
| |
| 4169 |
|
| int |
| 4170 |
|
| indexElements ( self ) |
| 4171 |
|
| xmlDocPtr self |
| 4172 |
|
| CODE: |
| 4173 |
|
| #if LIBXML_VERSION >= 20508 |
| 4174 |
0 |
▶ | RETVAL = xmlXPathOrderDocElems( self ); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = xmlXPathOrderDocElems( self ); |
0 |
0 |
0 |
|
| 4175 |
|
| #else |
| 4176 |
|
| RETVAL = -2; |
| 4177 |
|
| #endif |
| 4178 |
|
| OUTPUT: |
| 4179 |
|
| RETVAL |
| 4180 |
|
| |
| 4181 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Node |
| 4182 |
|
| |
| 4183 |
|
| void |
| 4184 |
|
| DESTROY( node ) |
| 4185 |
|
| SV * node |
| 4186 |
|
| PREINIT: |
| 4187 |
|
| int count; |
| 4188 |
|
| SV *is_shared; |
| 4189 |
|
| CODE: |
| 4190 |
|
| #ifdef XML_LIBXML_THREADS |
| 4191 |
|
| if ( (is_shared = get_sv("XML::LibXML::__threads_shared", 0)) == NULL ) { |
| 4192 |
|
| is_shared = &PL_sv_undef; |
| 4193 |
|
| } |
| 4194 |
|
| if ( SvTRUE(is_shared) ) { |
| 4195 |
|
| dSP; |
| 4196 |
|
| ENTER; |
| 4197 |
|
| SAVETMPS; |
| 4198 |
|
| PUSHMARK(SP); |
| 4199 |
|
| XPUSHs(node); |
| 4200 |
|
| PUTBACK; |
| 4201 |
|
| count = call_pv("threads::shared::is_shared", G_SCALAR); |
| 4202 |
|
| SPAGAIN; |
| 4203 |
|
| if (count != 1) |
| 4204 |
|
| croak("Couldn't checks if the variable is shared or not\n"); |
| 4205 |
|
| is_shared = POPs; |
| 4206 |
|
| PUTBACK; |
| 4207 |
|
| FREETMPS; |
| 4208 |
|
| LEAVE; |
| 4209 |
|
| if (is_shared != &PL_sv_undef) { |
| 4210 |
|
| XSRETURN_UNDEF; |
| 4211 |
|
| } |
| 4212 |
|
| } |
| 4213 |
|
| if( PmmUSEREGISTRY ) { |
| 4214 |
|
| SvLOCK(PROXY_NODE_REGISTRY_MUTEX); |
| 4215 |
|
| PmmRegistryREFCNT_dec(SvPROXYNODE(node)); |
| 4216 |
|
| } |
| 4217 |
|
| #endif |
| 4218 |
20555 |
| PmmREFCNT_dec(SvPROXYNODE(node)); |
| 4219 |
|
| #ifdef XML_LIBXML_THREADS |
| 4220 |
|
| if( PmmUSEREGISTRY ) |
| 4221 |
|
| SvUNLOCK(PROXY_NODE_REGISTRY_MUTEX); |
| 4222 |
|
| #endif |
| 4223 |
|
| |
| 4224 |
|
| SV* |
| 4225 |
|
| nodeName( self ) |
| 4226 |
|
| xmlNodePtr self |
| 4227 |
|
| ALIAS: |
| 4228 |
|
| XML::LibXML::Node::getName = 1 |
| 4229 |
|
| XML::LibXML::Element::tagName = 2 |
| 4230 |
|
| PREINIT: |
| 4231 |
254 |
| xmlChar * name = NULL; |
| 4232 |
|
| CODE: |
| 4233 |
|
| PERL_UNUSED_VAR(ix); |
| 4234 |
254 |
| name = (xmlChar*)domName( self ); |
| 4235 |
254 |
▶ | if ( name != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name != NULL ) { |
254 |
0 |
254 |
|
| 4236 |
254 |
| RETVAL = C2Sv(name,NULL); |
| 4237 |
254 |
| xmlFree( name ); |
| 4238 |
|
| } |
| 4239 |
|
| else { |
| 4240 |
0 |
| XSRETURN_UNDEF; |
| 4241 |
|
| } |
| 4242 |
|
| OUTPUT: |
| 4243 |
|
| RETVAL |
| 4244 |
|
| |
| 4245 |
|
| SV* |
| 4246 |
|
| localname( self ) |
| 4247 |
|
| xmlNodePtr self |
| 4248 |
|
| ALIAS: |
| 4249 |
|
| XML::LibXML::Node::getLocalName = 1 |
| 4250 |
|
| XML::LibXML::Attr::name = 2 |
| 4251 |
|
| XML::LibXML::Node::localName = 3 |
| 4252 |
|
| CODE: |
| 4253 |
|
| PERL_UNUSED_VAR(ix); |
| 4254 |
126 |
▶ | if ( self->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type == XML_ELEMENT_NODE |
55 |
71 |
126 |
|
| 4255 |
55 |
▶ | || self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_NODE |
0 |
55 |
55 |
|
| 4256 |
0 |
▶ | || self->type == XML_ELEMENT_DECL |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ELEMENT_DECL |
0 |
0 |
0 |
|
| 4257 |
0 |
▶ | || self->type == XML_ATTRIBUTE_DECL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_DECL ) { |
0 |
0 |
0 |
|
| 4258 |
126 |
| RETVAL = C2Sv(self->name,NULL); |
| 4259 |
|
| } |
| 4260 |
|
| else { |
| 4261 |
0 |
| XSRETURN_UNDEF; |
| 4262 |
|
| } |
| 4263 |
|
| OUTPUT: |
| 4264 |
|
| RETVAL |
| 4265 |
|
| |
| 4266 |
|
| SV* |
| 4267 |
|
| prefix( self ) |
| 4268 |
|
| xmlNodePtr self |
| 4269 |
|
| ALIAS: |
| 4270 |
|
| XML::LibXML::Node::getPrefix = 1 |
| 4271 |
|
| CODE: |
| 4272 |
|
| PERL_UNUSED_VAR(ix); |
| 4273 |
59 |
▶ | if( ( self->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if( ( self->type == XML_ELEMENT_NODE |
14 |
45 |
59 |
|
| 4274 |
14 |
▶ | || self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_NODE |
0 |
14 |
14 |
|
| 4275 |
0 |
▶ | || self->type == XML_PI_NODE ) |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_PI_NODE ) |
0 |
0 |
0 |
|
| 4276 |
59 |
▶ | && self->ns != NULL |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns != NULL |
12 |
47 |
59 |
|
| 4277 |
12 |
▶ | && self->ns->prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns->prefix != NULL ) { |
7 |
5 |
12 |
|
| 4278 |
7 |
| RETVAL = C2Sv(self->ns->prefix, NULL); |
| 4279 |
|
| } |
| 4280 |
|
| else { |
| 4281 |
52 |
| XSRETURN_UNDEF; |
| 4282 |
|
| } |
| 4283 |
|
| OUTPUT: |
| 4284 |
|
| RETVAL |
| 4285 |
|
| |
| 4286 |
|
| SV* |
| 4287 |
|
| namespaceURI( self ) |
| 4288 |
|
| xmlNodePtr self |
| 4289 |
|
| ALIAS: |
| 4290 |
|
| getNamespaceURI = 1 |
| 4291 |
|
| PREINIT: |
| 4292 |
|
| xmlChar * nsURI; |
| 4293 |
|
| CODE: |
| 4294 |
|
| PERL_UNUSED_VAR(ix); |
| 4295 |
78 |
▶ | if ( ( self->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ( self->type == XML_ELEMENT_NODE |
26 |
52 |
78 |
|
| 4296 |
26 |
▶ | || self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_NODE |
0 |
26 |
26 |
|
| 4297 |
0 |
▶ | || self->type == XML_PI_NODE ) |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_PI_NODE ) |
0 |
0 |
0 |
|
| 4298 |
78 |
▶ | && self->ns != NULL |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns != NULL |
26 |
52 |
78 |
|
| 4299 |
26 |
▶ | && self->ns->href != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns->href != NULL ) { |
26 |
0 |
26 |
|
| 4300 |
26 |
| nsURI = xmlStrdup(self->ns->href); |
| 4301 |
26 |
| RETVAL = C2Sv( nsURI, NULL ); |
| 4302 |
26 |
| xmlFree( nsURI ); |
| 4303 |
|
| } |
| 4304 |
|
| else { |
| 4305 |
52 |
| XSRETURN_UNDEF; |
| 4306 |
|
| } |
| 4307 |
|
| OUTPUT: |
| 4308 |
|
| RETVAL |
| 4309 |
|
| |
| 4310 |
|
| |
| 4311 |
|
| SV* |
| 4312 |
|
| lookupNamespaceURI( self, svprefix=&PL_sv_undef ) |
| 4313 |
|
| xmlNodePtr self |
| 4314 |
|
| SV * svprefix |
| 4315 |
|
| PREINIT: |
| 4316 |
|
| xmlChar * nsURI; |
| 4317 |
23 |
| xmlChar * prefix = NULL; |
| 4318 |
|
| xmlNsPtr ns; |
| 4319 |
|
| CODE: |
| 4320 |
23 |
| prefix = nodeSv2C( svprefix , self ); |
| 4321 |
23 |
▶ | if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
22 |
1 |
23 |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
5 |
17 |
22 |
|
| 4322 |
5 |
| xmlFree( prefix ); |
| 4323 |
5 |
| prefix = NULL; |
| 4324 |
|
| } |
| 4325 |
23 |
| ns = xmlSearchNs( self->doc, self, prefix ); |
| 4326 |
23 |
▶ | if ( prefix != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL) { |
17 |
6 |
23 |
|
| 4327 |
17 |
| xmlFree( prefix ); |
| 4328 |
|
| } |
| 4329 |
23 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
16 |
7 |
23 |
|
| 4330 |
16 |
| nsURI = xmlStrdup(ns->href); |
| 4331 |
16 |
| RETVAL = C2Sv( nsURI, NULL ); |
| 4332 |
16 |
| xmlFree( nsURI ); |
| 4333 |
|
| } |
| 4334 |
|
| else { |
| 4335 |
7 |
| XSRETURN_UNDEF; |
| 4336 |
|
| } |
| 4337 |
|
| OUTPUT: |
| 4338 |
|
| RETVAL |
| 4339 |
|
| |
| 4340 |
|
| SV* |
| 4341 |
|
| lookupNamespacePrefix( self, svuri ) |
| 4342 |
|
| xmlNodePtr self |
| 4343 |
|
| SV * svuri |
| 4344 |
|
| PREINIT: |
| 4345 |
|
| xmlChar * nsprefix; |
| 4346 |
7 |
| xmlChar * href = NULL; |
| 4347 |
|
| CODE: |
| 4348 |
7 |
| href = nodeSv2C( svuri , self ); |
| 4349 |
11 |
▶ | if ( href != NULL && xmlStrlen(href) > 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( href != NULL && xmlStrlen(href) > 0) { |
7 |
0 |
7 |
| if ( href != NULL && xmlStrlen(href) > 0) { |
7 |
0 |
7 |
|
| 4350 |
7 |
| xmlNsPtr ns = xmlSearchNsByHref( self->doc, self, href ); |
| 4351 |
7 |
| xmlFree( href ); |
| 4352 |
7 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
4 |
3 |
7 |
|
| 4353 |
4 |
▶ | if ( ns->prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns->prefix != NULL ) { |
3 |
1 |
4 |
|
| 4354 |
3 |
| nsprefix = xmlStrdup( ns->prefix ); |
| 4355 |
3 |
| RETVAL = C2Sv( nsprefix, NULL ); |
| 4356 |
3 |
| xmlFree(nsprefix); |
| 4357 |
|
| } else { |
| 4358 |
1 |
| RETVAL = newSVpv("",0); |
| 4359 |
|
| } |
| 4360 |
|
| } |
| 4361 |
|
| else { |
| 4362 |
3 |
| XSRETURN_UNDEF; |
| 4363 |
|
| } |
| 4364 |
|
| } |
| 4365 |
|
| else { |
| 4366 |
0 |
▶ | if ( href != NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( href != NULL ) |
0 |
0 |
0 |
|
| 4367 |
0 |
| xmlFree( href ); |
| 4368 |
0 |
| XSRETURN_UNDEF; |
| 4369 |
|
| } |
| 4370 |
|
| OUTPUT: |
| 4371 |
|
| RETVAL |
| 4372 |
|
| |
| 4373 |
|
| |
| 4374 |
|
| void |
| 4375 |
|
| setNodeName( self , value ) |
| 4376 |
|
| xmlNodePtr self |
| 4377 |
|
| SV* value |
| 4378 |
|
| ALIAS: |
| 4379 |
|
| setName = 1 |
| 4380 |
|
| PREINIT: |
| 4381 |
|
| xmlChar* string; |
| 4382 |
|
| xmlChar* localname; |
| 4383 |
|
| xmlChar* prefix; |
| 4384 |
|
| CODE: |
| 4385 |
|
| PERL_UNUSED_VAR(ix); |
| 4386 |
24 |
| string = nodeSv2C( value , self ); |
| 4387 |
24 |
▶ | if ( !LibXML_test_node_name( string ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name( string ) ) { |
17 |
7 |
24 |
|
| 4388 |
17 |
| xmlFree(string); |
| 4389 |
17 |
| croak( "bad name" ); |
| 4390 |
|
| } |
| 4391 |
7 |
▶ | if( ( self->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if( ( self->type == XML_ELEMENT_NODE |
2 |
5 |
7 |
|
| 4392 |
2 |
▶ | || self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_NODE |
0 |
2 |
2 |
|
| 4393 |
0 |
▶ | || self->type == XML_PI_NODE) |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_PI_NODE) |
0 |
0 |
0 |
|
| 4394 |
7 |
▶ | && self->ns ){ |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns ){ |
5 |
2 |
7 |
|
| 4395 |
5 |
| localname = xmlSplitQName2(string, &prefix); |
| 4396 |
5 |
▶ | if ( localname == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( localname == NULL ) { |
3 |
2 |
5 |
|
| 4397 |
3 |
| localname = xmlStrdup( string ); |
| 4398 |
|
| } |
| 4399 |
5 |
| xmlNodeSetName(self, localname ); |
| 4400 |
5 |
| xmlFree(localname); |
| 4401 |
5 |
| xmlFree(prefix); |
| 4402 |
|
| } |
| 4403 |
|
| else { |
| 4404 |
|
| xs_warn("node name normal\n"); |
| 4405 |
2 |
| xmlNodeSetName(self, string ); |
| 4406 |
|
| } |
| 4407 |
7 |
| xmlFree(string); |
| 4408 |
|
| |
| 4409 |
|
| void |
| 4410 |
|
| setRawName( self, value ) |
| 4411 |
|
| xmlNodePtr self |
| 4412 |
|
| SV * value |
| 4413 |
|
| PREINIT: |
| 4414 |
|
| xmlChar* string; |
| 4415 |
|
| xmlChar* localname; |
| 4416 |
|
| xmlChar* prefix; |
| 4417 |
|
| CODE: |
| 4418 |
0 |
| string = nodeSv2C( value , self ); |
| 4419 |
0 |
▶ | if ( !string || xmlStrlen( string) <= 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !string || xmlStrlen( string) <= 0 ) { |
0 |
0 |
0 |
| if ( !string || xmlStrlen( string) <= 0 ) { |
0 |
0 |
0 |
|
| 4420 |
0 |
| xmlFree(string); |
| 4421 |
0 |
| XSRETURN_UNDEF; |
| 4422 |
|
| } |
| 4423 |
0 |
▶ | if( ( self->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if( ( self->type == XML_ELEMENT_NODE |
0 |
0 |
0 |
|
| 4424 |
0 |
▶ | || self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_ATTRIBUTE_NODE |
0 |
0 |
0 |
|
| 4425 |
0 |
▶ | || self->type == XML_PI_NODE) |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_PI_NODE) |
0 |
0 |
0 |
|
| 4426 |
0 |
▶ | && self->ns ){ |
Branch: 1 branch
| Branch | True | False | Total |
| && self->ns ){ |
0 |
0 |
0 |
|
| 4427 |
0 |
| localname = xmlSplitQName2(string, &prefix); |
| 4428 |
0 |
| xmlNodeSetName(self, localname ); |
| 4429 |
0 |
| xmlFree(localname); |
| 4430 |
0 |
| xmlFree(prefix); |
| 4431 |
|
| } |
| 4432 |
|
| else { |
| 4433 |
0 |
| xmlNodeSetName(self, string ); |
| 4434 |
|
| } |
| 4435 |
0 |
| xmlFree(string); |
| 4436 |
|
| |
| 4437 |
|
| |
| 4438 |
|
| SV* |
| 4439 |
|
| nodeValue( self, useDomEncoding = &PL_sv_undef ) |
| 4440 |
|
| xmlNodePtr self |
| 4441 |
|
| SV * useDomEncoding |
| 4442 |
|
| ALIAS: |
| 4443 |
|
| XML::LibXML::Attr::value = 1 |
| 4444 |
|
| XML::LibXML::Attr::getValue = 2 |
| 4445 |
|
| XML::LibXML::Text::data = 3 |
| 4446 |
|
| XML::LibXML::Node::getValue = 4 |
| 4447 |
|
| XML::LibXML::Node::getData = 5 |
| 4448 |
|
| PREINIT: |
| 4449 |
172 |
| xmlChar * content = NULL; |
| 4450 |
|
| CODE: |
| 4451 |
|
| PERL_UNUSED_VAR(ix); |
| 4452 |
171 |
| content = domGetNodeValue( self ); |
| 4453 |
|
| |
| 4454 |
171 |
▶ | if ( content != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( content != NULL ) { |
169 |
2 |
171 |
|
| 4455 |
169 |
▶ | if ( SvTRUE(useDomEncoding) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( SvTRUE(useDomEncoding) ) { |
0 |
169 |
169 |
|
| 4456 |
0 |
| RETVAL = nodeC2Sv(content, self); |
| 4457 |
|
| } |
| 4458 |
|
| else { |
| 4459 |
169 |
| RETVAL = C2Sv(content, NULL); |
| 4460 |
|
| } |
| 4461 |
169 |
| xmlFree(content); |
| 4462 |
|
| } |
| 4463 |
|
| else { |
| 4464 |
2 |
| XSRETURN_UNDEF; |
| 4465 |
|
| } |
| 4466 |
|
| OUTPUT: |
| 4467 |
|
| RETVAL |
| 4468 |
|
| |
| 4469 |
|
| int |
| 4470 |
|
| nodeType( self ) |
| 4471 |
|
| xmlNodePtr self |
| 4472 |
|
| ALIAS: |
| 4473 |
|
| XML::LibXML::Node::getType = 1 |
| 4474 |
|
| CODE: |
| 4475 |
|
| PERL_UNUSED_VAR(ix); |
| 4476 |
213 |
▶ | RETVAL = self->type; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->type; |
177 |
36 |
213 |
|
| 4477 |
|
| OUTPUT: |
| 4478 |
|
| RETVAL |
| 4479 |
|
| |
| 4480 |
|
| SV* |
| 4481 |
|
| parentNode( self ) |
| 4482 |
|
| xmlNodePtr self |
| 4483 |
|
| ALIAS: |
| 4484 |
|
| XML::LibXML::Attr::ownerElement = 1 |
| 4485 |
|
| XML::LibXML::Node::getParentNode = 2 |
| 4486 |
|
| XML::LibXML::Attr::getOwnerElement = 3 |
| 4487 |
|
| CODE: |
| 4488 |
|
| PERL_UNUSED_VAR(ix); |
| 4489 |
158 |
| RETVAL = PmmNodeToSv( self->parent, |
| 4490 |
158 |
▶ | PmmOWNERPO( PmmPROXYNODE(self) ) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
158 |
0 |
158 |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
158 |
0 |
158 |
|
| 4491 |
|
| OUTPUT: |
| 4492 |
|
| RETVAL |
| 4493 |
|
| |
| 4494 |
|
| SV* |
| 4495 |
|
| nextSibling( self ) |
| 4496 |
|
| xmlNodePtr self |
| 4497 |
|
| ALIAS: |
| 4498 |
|
| getNextSibling = 1 |
| 4499 |
|
| CODE: |
| 4500 |
|
| PERL_UNUSED_VAR(ix); |
| 4501 |
15 |
| RETVAL = PmmNodeToSv( self->next, |
| 4502 |
15 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
15 |
0 |
15 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
15 |
0 |
15 |
|
| 4503 |
|
| OUTPUT: |
| 4504 |
|
| RETVAL |
| 4505 |
|
| |
| 4506 |
|
| SV* |
| 4507 |
|
| nextNonBlankSibling( self ) |
| 4508 |
|
| xmlNodePtr self |
| 4509 |
|
| PREINIT: |
| 4510 |
|
| xmlNodePtr next; |
| 4511 |
|
| CODE: |
| 4512 |
14 |
| next = self->next; |
| 4513 |
28 |
▶ | while (next != NULL && xmlIsBlankNode(next)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (next != NULL && xmlIsBlankNode(next)) |
26 |
2 |
28 |
| while (next != NULL && xmlIsBlankNode(next)) |
14 |
12 |
26 |
|
| 4514 |
14 |
| next = next->next; |
| 4515 |
14 |
| RETVAL = PmmNodeToSv( next, |
| 4516 |
14 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
14 |
0 |
14 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
14 |
0 |
14 |
|
| 4517 |
|
| OUTPUT: |
| 4518 |
|
| RETVAL |
| 4519 |
|
| |
| 4520 |
|
| |
| 4521 |
|
| SV* |
| 4522 |
|
| previousSibling( self ) |
| 4523 |
|
| xmlNodePtr self |
| 4524 |
|
| ALIAS: |
| 4525 |
|
| getPreviousSibling = 1 |
| 4526 |
|
| CODE: |
| 4527 |
|
| PERL_UNUSED_VAR(ix); |
| 4528 |
4 |
| RETVAL = PmmNodeToSv( self->prev, |
| 4529 |
4 |
▶ | PmmOWNERPO( PmmPROXYNODE(self) ) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
4 |
0 |
4 |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
4 |
0 |
4 |
|
| 4530 |
|
| OUTPUT: |
| 4531 |
|
| RETVAL |
| 4532 |
|
| |
| 4533 |
|
| SV* |
| 4534 |
|
| previousNonBlankSibling( self ) |
| 4535 |
|
| xmlNodePtr self |
| 4536 |
|
| PREINIT: |
| 4537 |
|
| xmlNodePtr prev; |
| 4538 |
|
| CODE: |
| 4539 |
14 |
| prev = self->prev; |
| 4540 |
30 |
▶ | while (prev != NULL && xmlIsBlankNode(prev)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (prev != NULL && xmlIsBlankNode(prev)) |
28 |
2 |
30 |
| while (prev != NULL && xmlIsBlankNode(prev)) |
16 |
12 |
28 |
|
| 4541 |
16 |
| prev = prev->prev; |
| 4542 |
14 |
| RETVAL = PmmNodeToSv( prev, |
| 4543 |
14 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
14 |
0 |
14 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
14 |
0 |
14 |
|
| 4544 |
|
| OUTPUT: |
| 4545 |
|
| RETVAL |
| 4546 |
|
| |
| 4547 |
|
| |
| 4548 |
|
| void |
| 4549 |
|
| _childNodes( self, only_nonblank = 0 ) |
| 4550 |
|
| xmlNodePtr self |
| 4551 |
|
| int only_nonblank |
| 4552 |
|
| ALIAS: |
| 4553 |
|
| XML::LibXML::Node::getChildnodes = 1 |
| 4554 |
|
| PREINIT: |
| 4555 |
|
| xmlNodePtr cld; |
| 4556 |
|
| SV * element; |
| 4557 |
164 |
| int len = 0; |
| 4558 |
164 |
| int wantarray = GIMME_V; |
| 4559 |
|
| PPCODE: |
| 4560 |
|
| PERL_UNUSED_VAR(ix); |
| 4561 |
164 |
▶ | if ( self->type != XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type != XML_ATTRIBUTE_NODE ) { |
164 |
0 |
164 |
|
| 4562 |
164 |
| cld = self->children; |
| 4563 |
|
| xs_warn("childnodes start"); |
| 4564 |
616 |
▶ | while ( cld ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( cld ) { |
452 |
164 |
616 |
|
| 4565 |
452 |
▶ | if ( !(only_nonblank && xmlIsBlankNode(cld)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !(only_nonblank && xmlIsBlankNode(cld)) ) { |
30 |
422 |
452 |
| if ( !(only_nonblank && xmlIsBlankNode(cld)) ) { |
14 |
16 |
30 |
|
| 4566 |
436 |
▶ | if( wantarray != G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( wantarray != G_SCALAR ) { |
436 |
0 |
436 |
|
| 4567 |
436 |
▶ | element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
436 |
0 |
436 |
| element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
312 |
124 |
436 |
|
| 4568 |
436 |
▶ | XPUSHs(sv_2mortal(element)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(element)); |
0 |
436 |
436 |
|
| 4569 |
|
| } |
| 4570 |
436 |
| len++; |
| 4571 |
|
| } |
| 4572 |
452 |
| cld = cld->next; |
| 4573 |
|
| } |
| 4574 |
|
| } |
| 4575 |
164 |
▶ | if ( wantarray == G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( wantarray == G_SCALAR ) { |
0 |
164 |
164 |
|
| 4576 |
0 |
▶ | XPUSHs(sv_2mortal(newSViv(len)) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(len)) ); |
0 |
0 |
0 |
|
| 4577 |
|
| } |
| 4578 |
|
| |
| 4579 |
|
| void |
| 4580 |
|
| _getChildrenByTagNameNS( self, namespaceURI, node_name ) |
| 4581 |
|
| xmlNodePtr self |
| 4582 |
|
| SV * namespaceURI |
| 4583 |
|
| SV * node_name |
| 4584 |
|
| PREINIT: |
| 4585 |
|
| xmlChar * name; |
| 4586 |
|
| xmlChar * nsURI; |
| 4587 |
|
| xmlNodePtr cld; |
| 4588 |
|
| SV * element; |
| 4589 |
12 |
| int len = 0; |
| 4590 |
12 |
| int name_wildcard = 0; |
| 4591 |
12 |
| int ns_wildcard = 0; |
| 4592 |
12 |
| int wantarray = GIMME_V; |
| 4593 |
|
| PPCODE: |
| 4594 |
12 |
| name = nodeSv2C(node_name, self ); |
| 4595 |
12 |
| nsURI = nodeSv2C(namespaceURI, self ); |
| 4596 |
|
| |
| 4597 |
12 |
▶ | if ( nsURI != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI != NULL ) { |
12 |
0 |
12 |
|
| 4598 |
12 |
▶ | if (xmlStrlen(nsURI) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xmlStrlen(nsURI) == 0 ) { |
0 |
12 |
12 |
|
| 4599 |
0 |
| xmlFree(nsURI); |
| 4600 |
0 |
| nsURI = NULL; |
| 4601 |
12 |
▶ | } else if (xmlStrcmp( nsURI, (xmlChar *)"*" )==0) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (xmlStrcmp( nsURI, (xmlChar *)"*" )==0) { |
9 |
3 |
12 |
|
| 4602 |
9 |
| ns_wildcard = 1; |
| 4603 |
|
| } |
| 4604 |
|
| } |
| 4605 |
12 |
▶ | if ( name !=NULL && xmlStrcmp( name, (xmlChar *)"*" ) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( name !=NULL && xmlStrcmp( name, (xmlChar *)"*" ) == 0) { |
12 |
0 |
12 |
| if ( name !=NULL && xmlStrcmp( name, (xmlChar *)"*" ) == 0) { |
6 |
6 |
12 |
|
| 4606 |
6 |
| name_wildcard = 1; |
| 4607 |
|
| } |
| 4608 |
12 |
▶ | if ( self->type != XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type != XML_ATTRIBUTE_NODE ) { |
12 |
0 |
12 |
|
| 4609 |
12 |
| cld = self->children; |
| 4610 |
|
| xs_warn("childnodes start"); |
| 4611 |
48 |
▶ | while ( cld ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( cld ) { |
36 |
12 |
48 |
|
| 4612 |
60 |
▶ | if (((name_wildcard && (cld->type == XML_ELEMENT_NODE)) || |
Branch: 1 branch
| Branch | True | False | Total |
| if (((name_wildcard && (cld->type == XML_ELEMENT_NODE)) || |
18 |
18 |
36 |
|
| 4613 |
24 |
| xmlStrcmp( name, cld->name ) == 0) |
| 4614 |
24 |
▶ | && (ns_wildcard || |
Branch: 1 branch
| Branch | True | False | Total |
| && (ns_wildcard || |
6 |
18 |
24 |
|
| 4615 |
9 |
| (cld->ns != NULL && |
| 4616 |
3 |
| xmlStrcmp(nsURI,cld->ns->href) == 0 ) || |
| 4617 |
3 |
▶ | (cld->ns == NULL && nsURI == NULL))) { |
Branch: 2 branches
| Branch | True | False | Total |
| (cld->ns == NULL && nsURI == NULL))) { |
3 |
0 |
3 |
| (cld->ns == NULL && nsURI == NULL))) { |
0 |
3 |
3 |
|
| 4618 |
21 |
▶ | if( wantarray != G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( wantarray != G_SCALAR ) { |
21 |
0 |
21 |
|
| 4619 |
21 |
▶ | element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
21 |
0 |
21 |
| element = PmmNodeToSv(cld, PmmOWNERPO(PmmPROXYNODE(self)) ); |
21 |
0 |
21 |
|
| 4620 |
21 |
▶ | XPUSHs(sv_2mortal(element)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(element)); |
0 |
21 |
21 |
|
| 4621 |
|
| } |
| 4622 |
21 |
| len++; |
| 4623 |
|
| } |
| 4624 |
36 |
| cld = cld->next; |
| 4625 |
|
| } |
| 4626 |
|
| } |
| 4627 |
12 |
▶ | if ( wantarray == G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( wantarray == G_SCALAR ) { |
0 |
12 |
12 |
|
| 4628 |
0 |
▶ | XPUSHs(sv_2mortal(newSViv(len)) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(len)) ); |
0 |
0 |
0 |
|
| 4629 |
|
| } |
| 4630 |
12 |
| xmlFree(name); |
| 4631 |
12 |
▶ | if (nsURI) xmlFree(nsURI); |
Branch: 1 branch
| Branch | True | False | Total |
| if (nsURI) xmlFree(nsURI); |
12 |
0 |
12 |
|
| 4632 |
|
| |
| 4633 |
|
| SV* |
| 4634 |
|
| firstChild( self ) |
| 4635 |
|
| xmlNodePtr self |
| 4636 |
|
| ALIAS: |
| 4637 |
|
| getFirstChild = 1 |
| 4638 |
|
| CODE: |
| 4639 |
|
| PERL_UNUSED_VAR(ix); |
| 4640 |
52 |
| RETVAL = PmmNodeToSv( self->children, |
| 4641 |
52 |
▶ | PmmOWNERPO( PmmPROXYNODE(self) ) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
52 |
0 |
52 |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
21 |
31 |
52 |
|
| 4642 |
|
| OUTPUT: |
| 4643 |
|
| RETVAL |
| 4644 |
|
| |
| 4645 |
|
| SV* |
| 4646 |
|
| firstNonBlankChild( self ) |
| 4647 |
|
| xmlNodePtr self |
| 4648 |
|
| PREINIT: |
| 4649 |
|
| xmlNodePtr child; |
| 4650 |
|
| CODE: |
| 4651 |
2 |
| child = self->children; |
| 4652 |
4 |
▶ | while (child !=NULL && xmlIsBlankNode(child)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (child !=NULL && xmlIsBlankNode(child)) |
4 |
0 |
4 |
| while (child !=NULL && xmlIsBlankNode(child)) |
2 |
2 |
4 |
|
| 4653 |
2 |
| child = child->next; |
| 4654 |
2 |
| RETVAL = PmmNodeToSv( child, |
| 4655 |
2 |
▶ | PmmOWNERPO( PmmPROXYNODE(self) ) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
2 |
0 |
2 |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
2 |
0 |
2 |
|
| 4656 |
|
| OUTPUT: |
| 4657 |
|
| RETVAL |
| 4658 |
|
| |
| 4659 |
|
| SV* |
| 4660 |
|
| lastChild( self ) |
| 4661 |
|
| xmlNodePtr self |
| 4662 |
|
| ALIAS: |
| 4663 |
|
| getLastChild = 1 |
| 4664 |
|
| CODE: |
| 4665 |
|
| PERL_UNUSED_VAR(ix); |
| 4666 |
28 |
| RETVAL = PmmNodeToSv( self->last, |
| 4667 |
28 |
▶ | PmmOWNERPO( PmmPROXYNODE(self) ) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
28 |
0 |
28 |
| PmmOWNERPO( PmmPROXYNODE(self) ) ); |
3 |
25 |
28 |
|
| 4668 |
|
| OUTPUT: |
| 4669 |
|
| RETVAL |
| 4670 |
|
| |
| 4671 |
|
| void |
| 4672 |
|
| _attributes( self ) |
| 4673 |
|
| xmlNodePtr self |
| 4674 |
|
| ALIAS: |
| 4675 |
|
| XML::LibXML::Node::getAttributes = 1 |
| 4676 |
|
| PREINIT: |
| 4677 |
51 |
| xmlAttrPtr attr = NULL; |
| 4678 |
51 |
| xmlNsPtr ns = NULL; |
| 4679 |
|
| SV * element; |
| 4680 |
51 |
| int len=0; |
| 4681 |
51 |
| int wantarray = GIMME_V; |
| 4682 |
|
| PPCODE: |
| 4683 |
|
| PERL_UNUSED_VAR(ix); |
| 4684 |
51 |
▶ | if ( self->type != XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type != XML_ATTRIBUTE_NODE |
51 |
0 |
51 |
|
| 4685 |
51 |
▶ | && self->type != XML_DTD_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && self->type != XML_DTD_NODE ) { |
50 |
1 |
51 |
|
| 4686 |
50 |
| attr = self->properties; |
| 4687 |
83 |
▶ | while ( attr != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( attr != NULL ) { |
33 |
50 |
83 |
|
| 4688 |
33 |
▶ | if ( wantarray != G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( wantarray != G_SCALAR ) { |
33 |
0 |
33 |
|
| 4689 |
33 |
| element = PmmNodeToSv((xmlNodePtr)attr, |
| 4690 |
33 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
33 |
0 |
33 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
33 |
0 |
33 |
|
| 4691 |
33 |
▶ | XPUSHs(sv_2mortal(element)); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(element)); |
0 |
33 |
33 |
|
| 4692 |
|
| } |
| 4693 |
33 |
| attr = attr->next; |
| 4694 |
33 |
| len++; |
| 4695 |
|
| } |
| 4696 |
50 |
▶ | if (self->type == XML_ELEMENT_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->type == XML_ELEMENT_NODE) { |
50 |
0 |
50 |
|
| 4697 |
50 |
| ns = self->nsDef; |
| 4698 |
64 |
▶ | while ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns != NULL ) { |
14 |
50 |
64 |
|
| 4699 |
14 |
| const char * CLASS = "XML::LibXML::Namespace"; |
| 4700 |
14 |
▶ | if ( wantarray != G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( wantarray != G_SCALAR ) { |
14 |
0 |
14 |
|
| 4701 |
|
| /* namespace handling is kinda odd: |
| 4702 |
|
| * as soon we have a namespace isolated from its |
| 4703 |
|
| * owner, we loose the context. therefore it is |
| 4704 |
|
| * forbidden to access the NS information directly. |
| 4705 |
|
| * instead the use will receive a copy of the real |
| 4706 |
|
| * namespace, that can be destroied and is not |
| 4707 |
|
| * bound to a document. |
| 4708 |
|
| * |
| 4709 |
|
| * this avoids segfaults in the end. |
| 4710 |
|
| */ |
| 4711 |
14 |
▶ | if ((ns->prefix != NULL || ns->href != NULL)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ((ns->prefix != NULL || ns->href != NULL)) { |
2 |
12 |
14 |
| if ((ns->prefix != NULL || ns->href != NULL)) { |
2 |
0 |
2 |
|
| 4712 |
14 |
| xmlNsPtr tns = xmlCopyNamespace(ns); |
| 4713 |
14 |
▶ | if ( tns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( tns != NULL ) { |
14 |
0 |
14 |
|
| 4714 |
14 |
| element = sv_newmortal(); |
| 4715 |
14 |
▶ | XPUSHs(sv_setref_pv( element, |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_setref_pv( element, |
0 |
14 |
14 |
|
| 4716 |
|
| (char *)CLASS, |
| 4717 |
|
| (void*)tns)); |
| 4718 |
|
| } |
| 4719 |
|
| } |
| 4720 |
|
| } |
| 4721 |
14 |
| ns = ns->next; |
| 4722 |
14 |
| len++; |
| 4723 |
|
| } |
| 4724 |
|
| } |
| 4725 |
|
| } |
| 4726 |
51 |
▶ | if( wantarray == G_SCALAR ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( wantarray == G_SCALAR ) { |
0 |
51 |
51 |
|
| 4727 |
0 |
▶ | XPUSHs( sv_2mortal(newSViv(len)) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(newSViv(len)) ); |
0 |
0 |
0 |
|
| 4728 |
|
| } |
| 4729 |
|
| |
| 4730 |
|
| int |
| 4731 |
|
| hasChildNodes( self ) |
| 4732 |
|
| xmlNodePtr self |
| 4733 |
|
| CODE: |
| 4734 |
125 |
▶ | if ( self->type == XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type == XML_ATTRIBUTE_NODE ) { |
2 |
123 |
125 |
|
| 4735 |
2 |
| RETVAL = 0; |
| 4736 |
|
| } |
| 4737 |
|
| else { |
| 4738 |
123 |
| RETVAL = self->children ? 1 : 0 ; |
| 4739 |
|
| } |
| 4740 |
|
| OUTPUT: |
| 4741 |
|
| RETVAL |
| 4742 |
|
| |
| 4743 |
|
| int |
| 4744 |
|
| hasAttributes( self ) |
| 4745 |
|
| xmlNodePtr self |
| 4746 |
|
| CODE: |
| 4747 |
2 |
▶ | if ( self->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type == XML_ATTRIBUTE_NODE |
2 |
0 |
2 |
|
| 4748 |
2 |
▶ | || self->type == XML_DTD_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_DTD_NODE ) { |
1 |
1 |
2 |
|
| 4749 |
1 |
| RETVAL = 0; |
| 4750 |
|
| } |
| 4751 |
|
| else { |
| 4752 |
1 |
| RETVAL = self->properties ? 1 : 0 ; |
| 4753 |
|
| } |
| 4754 |
|
| OUTPUT: |
| 4755 |
|
| RETVAL |
| 4756 |
|
| |
| 4757 |
|
| SV* |
| 4758 |
|
| ownerDocument( self ) |
| 4759 |
|
| xmlNodePtr self |
| 4760 |
|
| ALIAS: |
| 4761 |
|
| XML::LibXML::Node::getOwnerDocument = 1 |
| 4762 |
|
| CODE: |
| 4763 |
|
| PERL_UNUSED_VAR(ix); |
| 4764 |
|
| xs_warn( "GET OWNERDOC\n" ); |
| 4765 |
19 |
▶ | if( self != NULL |
Branch: 1 branch
| Branch | True | False | Total |
| if( self != NULL |
19 |
0 |
19 |
|
| 4766 |
19 |
▶ | && self->doc != NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| && self->doc != NULL ){ |
17 |
2 |
19 |
|
| 4767 |
17 |
| RETVAL = PmmNodeToSv((xmlNodePtr)(self->doc), NULL); |
| 4768 |
|
| } |
| 4769 |
|
| else { |
| 4770 |
2 |
| XSRETURN_UNDEF; |
| 4771 |
|
| } |
| 4772 |
|
| OUTPUT: |
| 4773 |
|
| RETVAL |
| 4774 |
|
| |
| 4775 |
|
| SV* |
| 4776 |
|
| ownerNode( self ) |
| 4777 |
|
| xmlNodePtr self |
| 4778 |
|
| ALIAS: |
| 4779 |
|
| XML::LibXML::Node::getOwner = 1 |
| 4780 |
|
| XML::LibXML::Node::getOwnerElement = 2 |
| 4781 |
|
| CODE: |
| 4782 |
|
| PERL_UNUSED_VAR(ix); |
| 4783 |
0 |
▶ | RETVAL = PmmNodeToSv(PmmNODE(PmmOWNERPO(PmmPROXYNODE(self))), NULL); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = PmmNodeToSv(PmmNODE(PmmOWNERPO(PmmPROXYNODE(self))), NULL); |
0 |
0 |
0 |
| RETVAL = PmmNodeToSv(PmmNODE(PmmOWNERPO(PmmPROXYNODE(self))), NULL); |
0 |
0 |
0 |
|
| 4784 |
|
| OUTPUT: |
| 4785 |
|
| RETVAL |
| 4786 |
|
| |
| 4787 |
|
| |
| 4788 |
|
| void |
| 4789 |
|
| normalize( self ) |
| 4790 |
|
| xmlNodePtr self |
| 4791 |
|
| CODE: |
| 4792 |
3 |
| domNodeNormalize( self ); |
| 4793 |
|
| |
| 4794 |
|
| |
| 4795 |
|
| SV* |
| 4796 |
|
| insertBefore( self, nNode, refNode ) |
| 4797 |
|
| xmlNodePtr self |
| 4798 |
|
| xmlNodePtr nNode |
| 4799 |
|
| SV * refNode |
| 4800 |
|
| PREINIT: |
| 4801 |
9 |
| xmlNodePtr oNode=NULL, rNode; |
| 4802 |
|
| INIT: |
| 4803 |
9 |
| oNode = PmmSvNode(refNode); |
| 4804 |
|
| CODE: |
| 4805 |
9 |
| rNode = domInsertBefore( self, nNode, oNode ); |
| 4806 |
8 |
▶ | if ( rNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rNode != NULL ) { |
8 |
0 |
8 |
|
| 4807 |
8 |
| RETVAL = PmmNodeToSv( rNode, |
| 4808 |
8 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
8 |
0 |
8 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
5 |
3 |
8 |
|
| 4809 |
8 |
▶ | if (rNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rNode->type == XML_DTD_NODE) { |
2 |
6 |
8 |
|
| 4810 |
2 |
| LibXML_set_int_subset(self->doc, rNode); |
| 4811 |
|
| } |
| 4812 |
8 |
▶ | PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
8 |
0 |
8 |
| PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
5 |
3 |
8 |
|
| 4813 |
|
| } |
| 4814 |
|
| else { |
| 4815 |
0 |
| XSRETURN_UNDEF; |
| 4816 |
|
| } |
| 4817 |
|
| OUTPUT: |
| 4818 |
|
| RETVAL |
| 4819 |
|
| |
| 4820 |
|
| SV* |
| 4821 |
|
| insertAfter( self, nNode, refNode ) |
| 4822 |
|
| xmlNodePtr self |
| 4823 |
|
| xmlNodePtr nNode |
| 4824 |
|
| SV* refNode |
| 4825 |
|
| PREINIT: |
| 4826 |
6 |
| xmlNodePtr oNode = NULL, rNode; |
| 4827 |
|
| INIT: |
| 4828 |
6 |
| oNode = PmmSvNode(refNode); |
| 4829 |
|
| CODE: |
| 4830 |
6 |
| rNode = domInsertAfter( self, nNode, oNode ); |
| 4831 |
6 |
▶ | if ( rNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rNode != NULL ) { |
6 |
0 |
6 |
|
| 4832 |
6 |
| RETVAL = PmmNodeToSv( rNode, |
| 4833 |
6 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
6 |
0 |
6 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
3 |
3 |
6 |
|
| 4834 |
6 |
▶ | if (rNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rNode->type == XML_DTD_NODE) { |
2 |
4 |
6 |
|
| 4835 |
2 |
| LibXML_set_int_subset(self->doc, rNode); |
| 4836 |
|
| } |
| 4837 |
6 |
▶ | PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
6 |
0 |
6 |
| PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self))); |
3 |
3 |
6 |
|
| 4838 |
|
| } |
| 4839 |
|
| else { |
| 4840 |
0 |
| XSRETURN_UNDEF; |
| 4841 |
|
| } |
| 4842 |
|
| OUTPUT: |
| 4843 |
|
| RETVAL |
| 4844 |
|
| |
| 4845 |
|
| SV* |
| 4846 |
|
| replaceChild( self, nNode, oNode ) |
| 4847 |
|
| xmlNodePtr self |
| 4848 |
|
| xmlNodePtr nNode |
| 4849 |
|
| xmlNodePtr oNode |
| 4850 |
|
| PREINIT: |
| 4851 |
6 |
| xmlNodePtr ret = NULL; |
| 4852 |
|
| CODE: |
| 4853 |
|
| /* if newNode == oldNode or self == newNode then do nothing, just return nNode. */ |
| 4854 |
6 |
▶ | if (nNode == oNode || self == nNode ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (nNode == oNode || self == nNode ) { |
5 |
1 |
6 |
| if (nNode == oNode || self == nNode ) { |
0 |
5 |
5 |
|
| 4855 |
1 |
| ret = nNode; |
| 4856 |
1 |
▶ | RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
1 |
0 |
1 |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
1 |
0 |
1 |
|
| 4857 |
|
| } |
| 4858 |
|
| else{ |
| 4859 |
5 |
▶ | if ( self->type == XML_DOCUMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type == XML_DOCUMENT_NODE ) { |
2 |
3 |
5 |
|
| 4860 |
2 |
| switch ( nNode->type ) { |
| 4861 |
0 |
| case XML_ELEMENT_NODE: |
| 4862 |
0 |
| warn("replaceChild with an element on a document node not supported yet!"); |
| 4863 |
0 |
| XSRETURN_UNDEF; |
| 4864 |
|
| break; |
| 4865 |
0 |
| case XML_DOCUMENT_FRAG_NODE: |
| 4866 |
0 |
| warn("replaceChild with a document fragment node on a document node not supported yet!"); |
| 4867 |
0 |
| XSRETURN_UNDEF; |
| 4868 |
|
| break; |
| 4869 |
0 |
| case XML_TEXT_NODE: |
| 4870 |
|
| case XML_CDATA_SECTION_NODE: |
| 4871 |
0 |
| warn("replaceChild with a text node not supported on a document node!"); |
| 4872 |
0 |
| XSRETURN_UNDEF; |
| 4873 |
|
| break; |
| 4874 |
2 |
| default: |
| 4875 |
2 |
| break; |
| 4876 |
|
| } |
| 4877 |
|
| } |
| 4878 |
5 |
| ret = domReplaceChild( self, nNode, oNode ); |
| 4879 |
5 |
▶ | if (ret == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ret == NULL) { |
0 |
5 |
5 |
|
| 4880 |
0 |
| XSRETURN_UNDEF; |
| 4881 |
|
| } |
| 4882 |
|
| else { |
| 4883 |
5 |
| LibXML_reparent_removed_node(ret); |
| 4884 |
5 |
▶ | RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
5 |
0 |
5 |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
5 |
0 |
5 |
|
| 4885 |
5 |
▶ | if (nNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nNode->type == XML_DTD_NODE) { |
2 |
3 |
5 |
|
| 4886 |
2 |
| LibXML_set_int_subset(nNode->doc, nNode); |
| 4887 |
|
| } |
| 4888 |
5 |
▶ | if ( nNode->_private != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nNode->_private != NULL ) { |
5 |
0 |
5 |
|
| 4889 |
5 |
| PmmFixOwner( PmmPROXYNODE(nNode), |
| 4890 |
5 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
5 |
0 |
5 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
3 |
2 |
5 |
|
| 4891 |
|
| } |
| 4892 |
|
| } |
| 4893 |
|
| } |
| 4894 |
|
| OUTPUT: |
| 4895 |
|
| RETVAL |
| 4896 |
|
| |
| 4897 |
|
| SV* |
| 4898 |
|
| replaceNode( self,nNode ) |
| 4899 |
|
| xmlNodePtr self |
| 4900 |
|
| xmlNodePtr nNode |
| 4901 |
|
| PREINIT: |
| 4902 |
5 |
| xmlNodePtr ret = NULL; |
| 4903 |
5 |
| ProxyNodePtr owner = NULL; |
| 4904 |
|
| CODE: |
| 4905 |
5 |
▶ | if ( domIsParent( self, nNode ) == 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( domIsParent( self, nNode ) == 1 ) { |
0 |
5 |
5 |
|
| 4906 |
0 |
| XSRETURN_UNDEF; |
| 4907 |
|
| } |
| 4908 |
5 |
▶ | owner = PmmOWNERPO(PmmPROXYNODE(self)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(PmmPROXYNODE(self)); |
5 |
0 |
5 |
| owner = PmmOWNERPO(PmmPROXYNODE(self)); |
5 |
0 |
5 |
|
| 4909 |
|
| |
| 4910 |
5 |
▶ | if ( self->type != XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type != XML_ATTRIBUTE_NODE ) { |
4 |
1 |
5 |
|
| 4911 |
4 |
| ret = domReplaceChild( self->parent, nNode, self); |
| 4912 |
|
| } |
| 4913 |
|
| else { |
| 4914 |
1 |
| ret = xmlReplaceNode( self, nNode ); |
| 4915 |
|
| } |
| 4916 |
5 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
5 |
0 |
5 |
|
| 4917 |
5 |
| LibXML_reparent_removed_node(ret); |
| 4918 |
5 |
▶ | RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
5 |
0 |
5 |
| RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret))); |
5 |
0 |
5 |
|
| 4919 |
5 |
▶ | if (nNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nNode->type == XML_DTD_NODE) { |
3 |
2 |
5 |
|
| 4920 |
3 |
| LibXML_set_int_subset(nNode->doc, nNode); |
| 4921 |
|
| } |
| 4922 |
5 |
▶ | if ( nNode->_private != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nNode->_private != NULL ) { |
5 |
0 |
5 |
|
| 4923 |
5 |
| PmmFixOwner(PmmPROXYNODE(nNode), owner); |
| 4924 |
|
| } |
| 4925 |
|
| } |
| 4926 |
|
| else { |
| 4927 |
0 |
| croak( "replacement failed" ); |
| 4928 |
|
| XSRETURN_UNDEF; |
| 4929 |
|
| } |
| 4930 |
|
| OUTPUT: |
| 4931 |
|
| RETVAL |
| 4932 |
|
| |
| 4933 |
|
| SV* |
| 4934 |
|
| removeChild( self, node ) |
| 4935 |
|
| xmlNodePtr self |
| 4936 |
|
| xmlNodePtr node |
| 4937 |
|
| PREINIT: |
| 4938 |
|
| xmlNodePtr ret; |
| 4939 |
|
| CODE: |
| 4940 |
15 |
| ret = domRemoveChild( self, node ); |
| 4941 |
15 |
▶ | if (ret == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ret == NULL) { |
1 |
14 |
15 |
|
| 4942 |
1 |
| XSRETURN_UNDEF; |
| 4943 |
|
| } |
| 4944 |
|
| else { |
| 4945 |
14 |
| LibXML_reparent_removed_node(ret); |
| 4946 |
14 |
| RETVAL = PmmNodeToSv(ret, NULL); |
| 4947 |
|
| } |
| 4948 |
|
| OUTPUT: |
| 4949 |
|
| RETVAL |
| 4950 |
|
| |
| 4951 |
|
| void |
| 4952 |
|
| removeChildNodes( self ) |
| 4953 |
|
| xmlNodePtr self |
| 4954 |
|
| PREINIT: |
| 4955 |
|
| xmlNodePtr elem, fragment; |
| 4956 |
|
| ProxyNodePtr docfrag; |
| 4957 |
|
| CODE: |
| 4958 |
2 |
| docfrag = PmmNewFragment( self->doc ); |
| 4959 |
2 |
| fragment = PmmNODE( docfrag ); |
| 4960 |
2 |
| elem = self->children; |
| 4961 |
6 |
▶ | while ( elem ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( elem ) { |
4 |
2 |
6 |
|
| 4962 |
4 |
| xmlNodePtr next = elem->next; |
| 4963 |
4 |
| xmlUnlinkNode( elem ); |
| 4964 |
4 |
▶ | if (elem->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem->type == XML_ATTRIBUTE_NODE |
4 |
0 |
4 |
|
| 4965 |
4 |
▶ | || elem->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| || elem->type == XML_DTD_NODE) { |
1 |
3 |
4 |
|
| 4966 |
1 |
▶ | if (PmmPROXYNODE(elem) == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PmmPROXYNODE(elem) == NULL) { |
0 |
1 |
1 |
|
| 4967 |
0 |
| xmlFreeNode(elem); |
| 4968 |
|
| } |
| 4969 |
|
| } |
| 4970 |
|
| else { |
| 4971 |
|
| /* this following piece is the function of domAppendChild() |
| 4972 |
|
| * but in this special case we can avoid most of the logic of |
| 4973 |
|
| * that function. |
| 4974 |
|
| */ |
| 4975 |
3 |
▶ | if ( fragment->children != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( fragment->children != NULL ) { |
1 |
2 |
3 |
|
| 4976 |
|
| xs_warn("unlink node!\n"); |
| 4977 |
1 |
| domAddNodeToList( elem, fragment->last, NULL ); |
| 4978 |
|
| } |
| 4979 |
|
| else { |
| 4980 |
2 |
| fragment->children = elem; |
| 4981 |
2 |
| fragment->last = elem; |
| 4982 |
2 |
| elem->parent= fragment; |
| 4983 |
|
| } |
| 4984 |
3 |
| PmmFixOwnerNode( elem, docfrag ); |
| 4985 |
|
| } |
| 4986 |
4 |
| elem = next; |
| 4987 |
|
| } |
| 4988 |
|
| |
| 4989 |
2 |
| self->children = self->last = NULL; |
| 4990 |
2 |
▶ | if ( PmmREFCNT(docfrag) <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( PmmREFCNT(docfrag) <= 0 ) { |
2 |
0 |
2 |
|
| 4991 |
|
| xs_warn( "have not references left" ); |
| 4992 |
2 |
| PmmREFCNT_inc( docfrag ); |
| 4993 |
2 |
| PmmREFCNT_dec( docfrag ); |
| 4994 |
|
| } |
| 4995 |
|
| |
| 4996 |
|
| void |
| 4997 |
|
| unbindNode( self ) |
| 4998 |
|
| xmlNodePtr self |
| 4999 |
|
| ALIAS: |
| 5000 |
|
| XML::LibXML::Node::unlink = 1 |
| 5001 |
|
| XML::LibXML::Node::unlinkNode = 2 |
| 5002 |
|
| PREINIT: |
| 5003 |
10 |
| ProxyNodePtr docfrag = NULL; |
| 5004 |
|
| CODE: |
| 5005 |
|
| PERL_UNUSED_VAR(ix); |
| 5006 |
10 |
▶ | if ( self->type != XML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type != XML_DOCUMENT_NODE |
10 |
0 |
10 |
|
| 5007 |
10 |
▶ | && self->type != XML_DOCUMENT_FRAG_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && self->type != XML_DOCUMENT_FRAG_NODE ) { |
10 |
0 |
10 |
|
| 5008 |
10 |
| xmlUnlinkNode( self ); |
| 5009 |
10 |
| LibXML_reparent_removed_node(self); |
| 5010 |
|
| } |
| 5011 |
|
| |
| 5012 |
|
| SV* |
| 5013 |
|
| appendChild( self, nNode ) |
| 5014 |
|
| xmlNodePtr self |
| 5015 |
|
| xmlNodePtr nNode |
| 5016 |
|
| PREINIT: |
| 5017 |
|
| xmlNodePtr rNode; |
| 5018 |
|
| CODE: |
| 5019 |
61 |
▶ | if (self->type == XML_DOCUMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->type == XML_DOCUMENT_NODE ) { |
3 |
58 |
61 |
|
| 5020 |
|
| /* NOT_SUPPORTED_ERR |
| 5021 |
|
| */ |
| 5022 |
3 |
| switch ( nNode->type ) { |
| 5023 |
1 |
| case XML_ELEMENT_NODE: |
| 5024 |
1 |
| warn("Appending an element to a document node not supported yet!"); |
| 5025 |
1 |
| XSRETURN_UNDEF; |
| 5026 |
|
| break; |
| 5027 |
0 |
| case XML_DOCUMENT_FRAG_NODE: |
| 5028 |
0 |
| warn("Appending a document fragment node to a document node not supported yet!"); |
| 5029 |
0 |
| XSRETURN_UNDEF; |
| 5030 |
|
| break; |
| 5031 |
0 |
| case XML_TEXT_NODE: |
| 5032 |
|
| case XML_CDATA_SECTION_NODE: |
| 5033 |
0 |
| warn("Appending text node not supported on a document node yet!"); |
| 5034 |
0 |
| XSRETURN_UNDEF; |
| 5035 |
|
| break; |
| 5036 |
2 |
| default: |
| 5037 |
2 |
| break; |
| 5038 |
|
| } |
| 5039 |
|
| } |
| 5040 |
|
| |
| 5041 |
60 |
| rNode = domAppendChild( self, nNode ); |
| 5042 |
|
| |
| 5043 |
59 |
▶ | if ( rNode == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rNode == NULL ) { |
0 |
59 |
59 |
|
| 5044 |
0 |
| XSRETURN_UNDEF; |
| 5045 |
|
| } |
| 5046 |
|
| |
| 5047 |
59 |
| RETVAL = PmmNodeToSv( nNode, |
| 5048 |
59 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
59 |
0 |
59 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
55 |
4 |
59 |
|
| 5049 |
59 |
▶ | if (nNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nNode->type == XML_DTD_NODE) { |
1 |
58 |
59 |
|
| 5050 |
1 |
| LibXML_set_int_subset(self->doc, nNode); |
| 5051 |
|
| } |
| 5052 |
59 |
| PmmFixOwner( SvPROXYNODE(RETVAL), PmmPROXYNODE(self) ); |
| 5053 |
|
| OUTPUT: |
| 5054 |
|
| RETVAL |
| 5055 |
|
| |
| 5056 |
|
| SV* |
| 5057 |
|
| addChild( self, nNode ) |
| 5058 |
|
| xmlNodePtr self |
| 5059 |
|
| xmlNodePtr nNode |
| 5060 |
|
| PREINIT: |
| 5061 |
39 |
| xmlNodePtr retval = NULL; |
| 5062 |
|
| ProxyNodePtr proxy; |
| 5063 |
|
| CODE: |
| 5064 |
39 |
| switch ( nNode->type ) { |
| 5065 |
0 |
| case XML_DOCUMENT_FRAG_NODE: |
| 5066 |
0 |
| croak("Adding document fragments with addChild not supported!"); |
| 5067 |
|
| XSRETURN_UNDEF; |
| 5068 |
0 |
| case XML_DOCUMENT_NODE : |
| 5069 |
|
| case XML_HTML_DOCUMENT_NODE : |
| 5070 |
|
| case XML_DOCB_DOCUMENT_NODE : |
| 5071 |
0 |
| croak("addChild: HIERARCHY_REQUEST_ERR\n"); |
| 5072 |
|
| XSRETURN_UNDEF; |
| 5073 |
0 |
| case XML_NOTATION_NODE : |
| 5074 |
|
| case XML_NAMESPACE_DECL : |
| 5075 |
|
| case XML_DTD_NODE : |
| 5076 |
|
| case XML_DOCUMENT_TYPE_NODE : |
| 5077 |
|
| case XML_ENTITY_DECL : |
| 5078 |
|
| case XML_ELEMENT_DECL : |
| 5079 |
|
| case XML_ATTRIBUTE_DECL : |
| 5080 |
0 |
| croak("addChild: unsupported node type!"); |
| 5081 |
|
| XSRETURN_UNDEF; |
| 5082 |
39 |
| default: |
| 5083 |
39 |
| break; |
| 5084 |
|
| } |
| 5085 |
|
| |
| 5086 |
39 |
| xmlUnlinkNode(nNode); |
| 5087 |
39 |
| proxy = PmmPROXYNODE(nNode); |
| 5088 |
39 |
| retval = xmlAddChild( self, nNode ); |
| 5089 |
|
| |
| 5090 |
39 |
▶ | if ( retval == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( retval == NULL ) { |
0 |
39 |
39 |
|
| 5091 |
0 |
| croak( "Error: addChild failed (check node types)!\n" ); |
| 5092 |
|
| } |
| 5093 |
|
| |
| 5094 |
39 |
▶ | if ( retval != nNode ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( retval != nNode ) { |
1 |
38 |
39 |
|
| 5095 |
|
| xs_warn( "node was lost during operation\n" ); |
| 5096 |
1 |
| PmmNODE(proxy) = NULL; |
| 5097 |
|
| } |
| 5098 |
|
| |
| 5099 |
39 |
| RETVAL = PmmNodeToSv( retval, |
| 5100 |
39 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
39 |
0 |
39 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
20 |
19 |
39 |
|
| 5101 |
39 |
▶ | if ( retval != self ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( retval != self ) { |
38 |
1 |
39 |
|
| 5102 |
38 |
| PmmFixOwner( SvPROXYNODE(RETVAL), PmmPROXYNODE(self) ); |
| 5103 |
|
| } |
| 5104 |
|
| OUTPUT: |
| 5105 |
|
| RETVAL |
| 5106 |
|
| |
| 5107 |
|
| |
| 5108 |
|
| SV* |
| 5109 |
|
| addSibling( self, nNode ) |
| 5110 |
|
| xmlNodePtr self |
| 5111 |
|
| xmlNodePtr nNode |
| 5112 |
|
| PREINIT: |
| 5113 |
6 |
| xmlNodePtr ret = NULL; |
| 5114 |
6 |
| ProxyNodePtr owner = NULL; |
| 5115 |
|
| CODE: |
| 5116 |
6 |
▶ | if ( nNode->type == XML_DOCUMENT_FRAG_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nNode->type == XML_DOCUMENT_FRAG_NODE ) { |
0 |
6 |
6 |
|
| 5117 |
0 |
| croak("Adding document fragments with addSibling not yet supported!"); |
| 5118 |
|
| XSRETURN_UNDEF; |
| 5119 |
|
| } |
| 5120 |
6 |
▶ | owner = PmmOWNERPO(PmmPROXYNODE(self)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(PmmPROXYNODE(self)); |
6 |
0 |
6 |
| owner = PmmOWNERPO(PmmPROXYNODE(self)); |
6 |
0 |
6 |
|
| 5121 |
|
| |
| 5122 |
6 |
▶ | if (self->type == XML_TEXT_NODE && nNode->type == XML_TEXT_NODE |
Branch: 2 branches
| Branch | True | False | Total |
| if (self->type == XML_TEXT_NODE && nNode->type == XML_TEXT_NODE |
1 |
5 |
6 |
| if (self->type == XML_TEXT_NODE && nNode->type == XML_TEXT_NODE |
1 |
0 |
1 |
|
| 5123 |
2 |
▶ | && self->name == nNode->name) { |
Branch: 1 branch
| Branch | True | False | Total |
| && self->name == nNode->name) { |
1 |
0 |
1 |
|
| 5124 |
|
| /* As a result of text merging, the added node may be freed. */ |
| 5125 |
1 |
| xmlNodePtr copy = xmlCopyNode(nNode, 0); |
| 5126 |
1 |
| ret = xmlAddSibling(self, copy); |
| 5127 |
|
| |
| 5128 |
1 |
▶ | if (ret) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ret) { |
1 |
0 |
1 |
|
| 5129 |
1 |
| RETVAL = PmmNodeToSv(ret, owner); |
| 5130 |
|
| /* Unlink original node. */ |
| 5131 |
1 |
| xmlUnlinkNode(nNode); |
| 5132 |
1 |
| LibXML_reparent_removed_node(nNode); |
| 5133 |
|
| } |
| 5134 |
|
| else { |
| 5135 |
0 |
| xmlFreeNode(copy); |
| 5136 |
0 |
| XSRETURN_UNDEF; |
| 5137 |
|
| } |
| 5138 |
|
| } |
| 5139 |
|
| else { |
| 5140 |
5 |
| ret = xmlAddSibling( self, nNode ); |
| 5141 |
|
| |
| 5142 |
5 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
5 |
0 |
5 |
|
| 5143 |
5 |
| RETVAL = PmmNodeToSv(ret, owner); |
| 5144 |
5 |
▶ | if (nNode->type == XML_DTD_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nNode->type == XML_DTD_NODE) { |
2 |
3 |
5 |
|
| 5145 |
2 |
| LibXML_set_int_subset(self->doc, nNode); |
| 5146 |
|
| } |
| 5147 |
5 |
| PmmFixOwner(SvPROXYNODE(RETVAL), owner); |
| 5148 |
|
| } |
| 5149 |
|
| else { |
| 5150 |
0 |
| XSRETURN_UNDEF; |
| 5151 |
|
| } |
| 5152 |
|
| } |
| 5153 |
|
| OUTPUT: |
| 5154 |
|
| RETVAL |
| 5155 |
|
| |
| 5156 |
|
| SV* |
| 5157 |
|
| cloneNode( self, deep=0 ) |
| 5158 |
|
| xmlNodePtr self |
| 5159 |
|
| int deep |
| 5160 |
|
| PREINIT: |
| 5161 |
|
| xmlNodePtr ret; |
| 5162 |
6 |
| xmlDocPtr doc = NULL; |
| 5163 |
6 |
| ProxyNodePtr docfrag = NULL; |
| 5164 |
|
| CODE: |
| 5165 |
6 |
| ret = PmmCloneNode( self, deep ); |
| 5166 |
6 |
▶ | if ( ret == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret == NULL ) { |
0 |
6 |
6 |
|
| 5167 |
0 |
| XSRETURN_UNDEF; |
| 5168 |
|
| } |
| 5169 |
|
| |
| 5170 |
6 |
▶ | if ( ret->type == XML_DTD_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret->type == XML_DTD_NODE ) { |
1 |
5 |
6 |
|
| 5171 |
1 |
| RETVAL = PmmNodeToSv(ret, NULL); |
| 5172 |
|
| } |
| 5173 |
|
| else { |
| 5174 |
5 |
| doc = self->doc; |
| 5175 |
|
| |
| 5176 |
5 |
▶ | if ( doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( doc != NULL ) { |
5 |
0 |
5 |
|
| 5177 |
5 |
| xmlSetTreeDoc(ret, doc); /* setting to self, no need to clear psvi */ |
| 5178 |
|
| } |
| 5179 |
|
| |
| 5180 |
5 |
| docfrag = PmmNewFragment( doc ); |
| 5181 |
5 |
| xmlAddChild( PmmNODE(docfrag), ret ); |
| 5182 |
5 |
| RETVAL = PmmNodeToSv(ret, docfrag); |
| 5183 |
|
| } |
| 5184 |
|
| OUTPUT: |
| 5185 |
|
| RETVAL |
| 5186 |
|
| |
| 5187 |
|
| int |
| 5188 |
|
| isSameNode( self, oNode ) |
| 5189 |
|
| xmlNodePtr self |
| 5190 |
|
| xmlNodePtr oNode |
| 5191 |
|
| ALIAS: |
| 5192 |
|
| XML::LibXML::Node::isEqual = 1 |
| 5193 |
|
| CODE: |
| 5194 |
|
| PERL_UNUSED_VAR(ix); |
| 5195 |
152 |
▶ | RETVAL = ( self == oNode ) ? 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ( self == oNode ) ? 1 : 0; |
52 |
100 |
152 |
|
| 5196 |
|
| OUTPUT: |
| 5197 |
|
| RETVAL |
| 5198 |
|
| |
| 5199 |
|
| IV |
| 5200 |
|
| unique_key( self ) |
| 5201 |
|
| xmlNodePtr self |
| 5202 |
|
| CODE: |
| 5203 |
|
| /* Cast pointer to IV */ |
| 5204 |
50 |
▶ | RETVAL = PTR2IV(self); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = PTR2IV(self); |
46 |
4 |
50 |
|
| 5205 |
|
| OUTPUT: |
| 5206 |
|
| RETVAL |
| 5207 |
|
| |
| 5208 |
|
| SV * |
| 5209 |
|
| baseURI( self ) |
| 5210 |
|
| xmlNodePtr self |
| 5211 |
|
| PREINIT: |
| 5212 |
|
| xmlChar * uri; |
| 5213 |
|
| CODE: |
| 5214 |
13 |
| uri = xmlNodeGetBase( self->doc, self ); |
| 5215 |
13 |
| RETVAL = C2Sv( uri, NULL ); |
| 5216 |
13 |
| xmlFree( uri ); |
| 5217 |
|
| OUTPUT: |
| 5218 |
|
| RETVAL |
| 5219 |
|
| |
| 5220 |
|
| void |
| 5221 |
|
| setBaseURI( self, URI ) |
| 5222 |
|
| xmlNodePtr self |
| 5223 |
|
| SV * URI |
| 5224 |
|
| PREINIT: |
| 5225 |
|
| xmlChar * uri; |
| 5226 |
|
| CODE: |
| 5227 |
7 |
| uri = nodeSv2C( URI, self ); |
| 5228 |
7 |
▶ | if ( uri != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( uri != NULL ) { |
7 |
0 |
7 |
|
| 5229 |
7 |
| xmlNodeSetBase( self, uri ); |
| 5230 |
7 |
| xmlFree( uri ); |
| 5231 |
|
| } |
| 5232 |
|
| |
| 5233 |
|
| SV* |
| 5234 |
|
| toString( self, format=0, useDomEncoding = &PL_sv_undef ) |
| 5235 |
|
| xmlNodePtr self |
| 5236 |
|
| SV * useDomEncoding |
| 5237 |
|
| int format |
| 5238 |
|
| ALIAS: |
| 5239 |
|
| XML::LibXML::Node::serialize = 1 |
| 5240 |
|
| PREINIT: |
| 5241 |
|
| xmlBufferPtr buffer; |
| 5242 |
157 |
| const xmlChar *ret = NULL; |
| 5243 |
157 |
| SV* internalFlag = NULL; |
| 5244 |
157 |
| int oldTagFlag = xmlSaveNoEmptyTags; |
| 5245 |
|
| CODE: |
| 5246 |
|
| PERL_UNUSED_VAR(ix); |
| 5247 |
157 |
| internalFlag = get_sv("XML::LibXML::setTagCompression", 0); |
| 5248 |
|
| |
| 5249 |
157 |
▶ | if ( internalFlag ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( internalFlag ) { |
157 |
0 |
157 |
|
| 5250 |
157 |
| xmlSaveNoEmptyTags = SvTRUE(internalFlag); |
| 5251 |
|
| } |
| 5252 |
157 |
| buffer = xmlBufferCreate(); |
| 5253 |
|
| |
| 5254 |
157 |
▶ | if ( format <= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( format <= 0 ) { |
153 |
4 |
157 |
|
| 5255 |
153 |
| xmlNodeDump( buffer, |
| 5256 |
153 |
| self->doc, |
| 5257 |
|
| self, 0, format); |
| 5258 |
|
| } |
| 5259 |
|
| else { |
| 5260 |
4 |
| int t_indent_var = xmlIndentTreeOutput; |
| 5261 |
4 |
| xmlIndentTreeOutput = 1; |
| 5262 |
4 |
| xmlNodeDump( buffer, |
| 5263 |
4 |
| self->doc, |
| 5264 |
|
| self, 0, format); |
| 5265 |
4 |
| xmlIndentTreeOutput = t_indent_var; |
| 5266 |
|
| } |
| 5267 |
|
| |
| 5268 |
157 |
| ret = xmlBufferContent( buffer ); |
| 5269 |
|
| |
| 5270 |
157 |
| xmlSaveNoEmptyTags = oldTagFlag; |
| 5271 |
|
| |
| 5272 |
157 |
▶ | if ( ret != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != NULL ) { |
157 |
0 |
157 |
|
| 5273 |
157 |
▶ | if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
2 |
155 |
157 |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
2 |
0 |
2 |
|
| 5274 |
2 |
| RETVAL = nodeC2Sv((xmlChar*)ret, PmmNODE(PmmPROXYNODE(self))) ; |
| 5275 |
2 |
| SvUTF8_off(RETVAL); |
| 5276 |
|
| } |
| 5277 |
|
| else { |
| 5278 |
155 |
| RETVAL = C2Sv((xmlChar*)ret, NULL) ; |
| 5279 |
|
| } |
| 5280 |
157 |
| xmlBufferFree( buffer ); |
| 5281 |
|
| } |
| 5282 |
|
| else { |
| 5283 |
0 |
| xmlBufferFree( buffer ); |
| 5284 |
|
| xs_warn("Failed to convert node to string"); |
| 5285 |
0 |
| XSRETURN_UNDEF; |
| 5286 |
|
| } |
| 5287 |
|
| OUTPUT: |
| 5288 |
|
| RETVAL |
| 5289 |
|
| |
| 5290 |
|
| |
| 5291 |
|
| SV * |
| 5292 |
|
| _toStringC14N(self, comments=0, xpath=&PL_sv_undef, exclusive=0, inc_prefix_list=NULL, xpath_context) |
| 5293 |
|
| xmlNodePtr self |
| 5294 |
|
| int comments |
| 5295 |
|
| SV * xpath |
| 5296 |
|
| int exclusive |
| 5297 |
|
| char** inc_prefix_list |
| 5298 |
|
| SV * xpath_context |
| 5299 |
|
| |
| 5300 |
|
| PREINIT: |
| 5301 |
24 |
| xmlChar *result = NULL; |
| 5302 |
24 |
| xmlChar *nodepath = NULL; |
| 5303 |
24 |
| xmlXPathContextPtr child_ctxt = NULL; |
| 5304 |
24 |
| xmlXPathObjectPtr xpath_res = NULL; |
| 5305 |
24 |
| xmlNodeSetPtr nodelist = NULL; |
| 5306 |
24 |
| xmlNodePtr refNode = NULL; |
| 5307 |
24 |
| PREINIT_SAVED_ERROR |
| 5308 |
|
| INIT: |
| 5309 |
|
| /* due to how c14n is implemented, the nodeset it receives must |
| 5310 |
|
| include child nodes; ie, child nodes aren't assumed to be rendered. |
| 5311 |
|
| so we use an xpath expression to find all of the child nodes. */ |
| 5312 |
|
| |
| 5313 |
24 |
▶ | if ( self->doc == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->doc == NULL ) { |
0 |
24 |
24 |
|
| 5314 |
0 |
| croak("Node passed to toStringC14N must be part of a document"); |
| 5315 |
|
| } |
| 5316 |
|
| |
| 5317 |
24 |
| refNode = self; |
| 5318 |
|
| CODE: |
| 5319 |
24 |
▶ | if ( xpath != NULL && xpath != &PL_sv_undef ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( xpath != NULL && xpath != &PL_sv_undef ) { |
24 |
0 |
24 |
| if ( xpath != NULL && xpath != &PL_sv_undef ) { |
11 |
13 |
24 |
|
| 5320 |
11 |
| nodepath = Sv2C( xpath, NULL ); |
| 5321 |
|
| } |
| 5322 |
|
| |
| 5323 |
24 |
▶ | if ( nodepath != NULL && xmlStrlen( nodepath ) == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nodepath != NULL && xmlStrlen( nodepath ) == 0 ) { |
11 |
13 |
24 |
| if ( nodepath != NULL && xmlStrlen( nodepath ) == 0 ) { |
0 |
11 |
11 |
|
| 5324 |
0 |
| xmlFree( nodepath ); |
| 5325 |
0 |
| nodepath = NULL; |
| 5326 |
|
| } |
| 5327 |
|
| |
| 5328 |
24 |
▶ | if ( nodepath == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodepath == NULL |
13 |
11 |
24 |
|
| 5329 |
13 |
▶ | && self->type != XML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| && self->type != XML_DOCUMENT_NODE |
3 |
10 |
13 |
|
| 5330 |
3 |
▶ | && self->type != XML_HTML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| && self->type != XML_HTML_DOCUMENT_NODE |
3 |
0 |
3 |
|
| 5331 |
3 |
▶ | && self->type != XML_DOCB_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| && self->type != XML_DOCB_DOCUMENT_NODE |
3 |
0 |
3 |
|
| 5332 |
|
| ) { |
| 5333 |
3 |
▶ | if (comments) |
Branch: 1 branch
| Branch | True | False | Total |
| if (comments) |
0 |
3 |
3 |
|
| 5334 |
0 |
| nodepath = xmlStrdup( (const xmlChar *) "(. | .//node() | .//@* | .//namespace::*)" ); |
| 5335 |
|
| else |
| 5336 |
3 |
| nodepath = xmlStrdup( (const xmlChar *) "(. | .//node() | .//@* | .//namespace::*)[not(self::comment())]" ); |
| 5337 |
|
| } |
| 5338 |
|
| |
| 5339 |
24 |
▶ | if ( nodepath != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodepath != NULL ) { |
14 |
10 |
24 |
|
| 5340 |
14 |
▶ | if ( self->type == XML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->type == XML_DOCUMENT_NODE |
4 |
10 |
14 |
|
| 5341 |
4 |
▶ | || self->type == XML_HTML_DOCUMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_HTML_DOCUMENT_NODE |
4 |
0 |
4 |
|
| 5342 |
4 |
▶ | || self->type == XML_DOCB_DOCUMENT_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || self->type == XML_DOCB_DOCUMENT_NODE ) { |
0 |
4 |
4 |
|
| 5343 |
10 |
| refNode = xmlDocGetRootElement( self->doc ); |
| 5344 |
|
| } |
| 5345 |
14 |
▶ | if (SvOK(xpath_context)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(xpath_context)) { |
2 |
12 |
14 |
|
| 5346 |
2 |
| child_ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(xpath_context))); |
| 5347 |
2 |
▶ | if ( child_ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( child_ctxt == NULL ) { |
0 |
2 |
2 |
|
| 5348 |
0 |
| xmlFree( nodepath ); |
| 5349 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 5350 |
|
| } |
| 5351 |
|
| } else { |
| 5352 |
12 |
| xpath_context = NULL; |
| 5353 |
12 |
| child_ctxt = xmlXPathNewContext(self->doc); |
| 5354 |
|
| } |
| 5355 |
14 |
▶ | if (!child_ctxt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!child_ctxt) { |
0 |
14 |
14 |
|
| 5356 |
0 |
▶ | if ( nodepath != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodepath != NULL ) { |
0 |
0 |
0 |
|
| 5357 |
0 |
| xmlFree( nodepath ); |
| 5358 |
|
| } |
| 5359 |
0 |
| croak("Failed to create xpath context"); |
| 5360 |
|
| } |
| 5361 |
|
| |
| 5362 |
14 |
| child_ctxt->node = self; |
| 5363 |
14 |
| LibXML_configure_namespaces(child_ctxt); |
| 5364 |
|
| |
| 5365 |
14 |
| xpath_res = xmlXPathEval(nodepath, child_ctxt); |
| 5366 |
14 |
▶ | if (child_ctxt->namespaces != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (child_ctxt->namespaces != NULL) { |
13 |
1 |
14 |
|
| 5367 |
13 |
| xmlFree( child_ctxt->namespaces ); |
| 5368 |
13 |
| child_ctxt->namespaces = NULL; |
| 5369 |
|
| } |
| 5370 |
14 |
▶ | if (!xpath_context) xmlXPathFreeContext(child_ctxt); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!xpath_context) xmlXPathFreeContext(child_ctxt); |
12 |
2 |
14 |
|
| 5371 |
14 |
▶ | if ( nodepath != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodepath != NULL ) { |
14 |
0 |
14 |
|
| 5372 |
14 |
| xmlFree( nodepath ); |
| 5373 |
|
| } |
| 5374 |
|
| |
| 5375 |
14 |
▶ | if (xpath_res == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xpath_res == NULL) { |
0 |
14 |
14 |
|
| 5376 |
0 |
| croak("2 Failed to compile xpath expression"); |
| 5377 |
|
| } |
| 5378 |
|
| |
| 5379 |
14 |
| nodelist = xpath_res->nodesetval; |
| 5380 |
14 |
▶ | if ( nodelist == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist == NULL ) { |
0 |
14 |
14 |
|
| 5381 |
0 |
| xmlXPathFreeObject(xpath_res); |
| 5382 |
0 |
| croak( "cannot canonize empty nodeset!" ); |
| 5383 |
|
| } |
| 5384 |
|
| } |
| 5385 |
|
| |
| 5386 |
24 |
| INIT_ERROR_HANDLER; |
| 5387 |
|
| |
| 5388 |
24 |
| xmlC14NDocDumpMemory( self->doc, |
| 5389 |
|
| nodelist, |
| 5390 |
|
| exclusive, (xmlChar **) inc_prefix_list, |
| 5391 |
|
| comments, |
| 5392 |
|
| &result ); |
| 5393 |
|
| |
| 5394 |
24 |
▶ | if ( xpath_res ) xmlXPathFreeObject(xpath_res); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath_res ) xmlXPathFreeObject(xpath_res); |
14 |
10 |
24 |
|
| 5395 |
24 |
| CLEANUP_ERROR_HANDLER; |
| 5396 |
24 |
| REPORT_ERROR(0); |
| 5397 |
|
| |
| 5398 |
24 |
▶ | if (result == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result == NULL) { |
0 |
24 |
24 |
|
| 5399 |
0 |
| croak("Failed to convert doc to string in doc->toStringC14N"); |
| 5400 |
|
| } else { |
| 5401 |
24 |
| RETVAL = C2Sv( result, NULL ); |
| 5402 |
24 |
| xmlFree(result); |
| 5403 |
|
| } |
| 5404 |
|
| OUTPUT: |
| 5405 |
|
| RETVAL |
| 5406 |
|
| |
| 5407 |
|
| SV* |
| 5408 |
|
| string_value ( self, useDomEncoding = &PL_sv_undef ) |
| 5409 |
|
| xmlNodePtr self |
| 5410 |
|
| SV * useDomEncoding |
| 5411 |
|
| ALIAS: |
| 5412 |
|
| to_literal = 1 |
| 5413 |
|
| textContent = 2 |
| 5414 |
|
| PREINIT: |
| 5415 |
109 |
| xmlChar * string = NULL; |
| 5416 |
|
| CODE: |
| 5417 |
|
| PERL_UNUSED_VAR(ix); |
| 5418 |
|
| /* we can't just return a string, because of UTF8! */ |
| 5419 |
109 |
| string = xmlXPathCastNodeToString(self); |
| 5420 |
109 |
▶ | if ( SvTRUE(useDomEncoding) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( SvTRUE(useDomEncoding) ) { |
1 |
108 |
109 |
|
| 5421 |
1 |
| RETVAL = nodeC2Sv(string, |
| 5422 |
|
| self); |
| 5423 |
|
| } |
| 5424 |
|
| else { |
| 5425 |
108 |
| RETVAL = C2Sv(string, |
| 5426 |
|
| NULL); |
| 5427 |
|
| } |
| 5428 |
109 |
| xmlFree(string); |
| 5429 |
|
| OUTPUT: |
| 5430 |
|
| RETVAL |
| 5431 |
|
| |
| 5432 |
|
| double |
| 5433 |
|
| to_number ( self ) |
| 5434 |
|
| xmlNodePtr self |
| 5435 |
|
| CODE: |
| 5436 |
0 |
| RETVAL = xmlXPathCastNodeToNumber(self); |
| 5437 |
|
| OUTPUT: |
| 5438 |
|
| RETVAL |
| 5439 |
|
| |
| 5440 |
|
| |
| 5441 |
|
| void |
| 5442 |
|
| _find( pnode, pxpath, to_bool ) |
| 5443 |
|
| SV* pnode |
| 5444 |
|
| SV * pxpath |
| 5445 |
|
| int to_bool |
| 5446 |
|
| PREINIT: |
| 5447 |
63 |
| xmlNodePtr node = PmmSvNode(pnode); |
| 5448 |
63 |
| ProxyNodePtr owner = NULL; |
| 5449 |
63 |
| xmlXPathObjectPtr found = NULL; |
| 5450 |
63 |
| xmlNodeSetPtr nodelist = NULL; |
| 5451 |
63 |
| xmlChar * xpath = NULL; |
| 5452 |
63 |
| xmlXPathCompExprPtr comp = NULL; |
| 5453 |
63 |
| PREINIT_SAVED_ERROR |
| 5454 |
|
| INIT: |
| 5455 |
63 |
▶ | if ( node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node == NULL ) { |
0 |
63 |
63 |
|
| 5456 |
0 |
| croak( "lost node" ); |
| 5457 |
|
| } |
| 5458 |
63 |
▶ | if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
3 |
60 |
63 |
| if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
3 |
0 |
3 |
|
| 5459 |
3 |
| comp = INT2PTR(xmlXPathCompExprPtr,SvIV((SV*)SvRV( pxpath ))); |
| 5460 |
3 |
▶ | if (!comp) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!comp) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 5461 |
|
| } else { |
| 5462 |
60 |
| xpath = nodeSv2C(pxpath, node); |
| 5463 |
60 |
▶ | if ( !(xpath && xmlStrlen(xpath)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
60 |
0 |
60 |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
0 |
60 |
60 |
|
| 5464 |
|
| xs_warn( "bad xpath\n" ); |
| 5465 |
0 |
▶ | if ( xpath ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath ) |
0 |
0 |
0 |
|
| 5466 |
0 |
| xmlFree(xpath); |
| 5467 |
0 |
| croak( "empty XPath found" ); |
| 5468 |
|
| XSRETURN_UNDEF; |
| 5469 |
|
| } |
| 5470 |
|
| } |
| 5471 |
|
| PPCODE: |
| 5472 |
63 |
| INIT_ERROR_HANDLER; |
| 5473 |
63 |
▶ | if (comp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (comp) { |
3 |
60 |
63 |
|
| 5474 |
3 |
| found = domXPathCompFind( node, comp, to_bool ); |
| 5475 |
|
| } else { |
| 5476 |
60 |
| found = domXPathFind( node, xpath, to_bool ); |
| 5477 |
60 |
| xmlFree( xpath ); |
| 5478 |
|
| } |
| 5479 |
63 |
| CLEANUP_ERROR_HANDLER; |
| 5480 |
63 |
▶ | if (found) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (found) { |
51 |
12 |
63 |
|
| 5481 |
51 |
| REPORT_ERROR(1); |
| 5482 |
51 |
| switch (found->type) { |
| 5483 |
34 |
| case XPATH_NODESET: |
| 5484 |
|
| /* return as a NodeList */ |
| 5485 |
|
| /* access ->nodesetval */ |
| 5486 |
34 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
0 |
34 |
34 |
|
| 5487 |
34 |
| nodelist = found->nodesetval; |
| 5488 |
34 |
▶ | if ( nodelist ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist ) { |
34 |
0 |
34 |
|
| 5489 |
34 |
▶ | if ( nodelist->nodeNr > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist->nodeNr > 0 ) { |
34 |
0 |
34 |
|
| 5490 |
|
| int i; |
| 5491 |
34 |
| const char * cls = "XML::LibXML::Node"; |
| 5492 |
|
| xmlNodePtr tnode; |
| 5493 |
|
| SV * element; |
| 5494 |
34 |
| int l = nodelist->nodeNr; |
| 5495 |
|
| |
| 5496 |
34 |
▶ | owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
34 |
0 |
34 |
| owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
1 |
33 |
34 |
|
| 5497 |
83 |
▶ | for( i=0 ; i < l; i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( i=0 ; i < l; i++){ |
49 |
34 |
83 |
|
| 5498 |
|
| /* we have to create a new instance of an |
| 5499 |
|
| * objectptr. and then |
| 5500 |
|
| * place the current node into the new |
| 5501 |
|
| * object. afterwards we can |
| 5502 |
|
| * push the object to the array! |
| 5503 |
|
| */ |
| 5504 |
49 |
| tnode = nodelist->nodeTab[i]; |
| 5505 |
|
| |
| 5506 |
|
| /* let's be paranoid */ |
| 5507 |
49 |
▶ | if (tnode->type == XML_NAMESPACE_DECL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->type == XML_NAMESPACE_DECL) { |
0 |
49 |
49 |
|
| 5508 |
0 |
| xmlNsPtr newns = xmlCopyNamespace((xmlNsPtr)tnode); |
| 5509 |
0 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
0 |
0 |
0 |
|
| 5510 |
0 |
| element = NEWSV(0,0); |
| 5511 |
0 |
| cls = PmmNodeTypeName( tnode ); |
| 5512 |
0 |
| element = sv_setref_pv( element, |
| 5513 |
|
| (const char *)cls, |
| 5514 |
|
| (void*)newns |
| 5515 |
|
| ); |
| 5516 |
|
| } |
| 5517 |
|
| else { |
| 5518 |
0 |
| continue; |
| 5519 |
|
| } |
| 5520 |
|
| } |
| 5521 |
|
| else { |
| 5522 |
49 |
| element = PmmNodeToSv(tnode, owner); |
| 5523 |
|
| } |
| 5524 |
|
| |
| 5525 |
49 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
49 |
49 |
|
| 5526 |
|
| } |
| 5527 |
|
| } |
| 5528 |
34 |
| xmlXPathFreeNodeSet( found->nodesetval ); |
| 5529 |
34 |
| found->nodesetval = NULL; |
| 5530 |
|
| } |
| 5531 |
34 |
| break; |
| 5532 |
12 |
| case XPATH_BOOLEAN: |
| 5533 |
|
| /* return as a Boolean */ |
| 5534 |
|
| /* access ->boolval */ |
| 5535 |
12 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
0 |
12 |
12 |
|
| 5536 |
12 |
▶ | XPUSHs(sv_2mortal(newSViv(found->boolval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(found->boolval))); |
0 |
12 |
12 |
|
| 5537 |
12 |
| break; |
| 5538 |
2 |
| case XPATH_NUMBER: |
| 5539 |
|
| /* return as a Number */ |
| 5540 |
|
| /* access ->floatval */ |
| 5541 |
2 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
0 |
2 |
2 |
|
| 5542 |
2 |
▶ | XPUSHs(sv_2mortal(newSVnv(found->floatval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVnv(found->floatval))); |
0 |
2 |
2 |
|
| 5543 |
2 |
| break; |
| 5544 |
3 |
| case XPATH_STRING: |
| 5545 |
|
| /* access ->stringval */ |
| 5546 |
|
| /* return as a Literal */ |
| 5547 |
3 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
0 |
3 |
3 |
|
| 5548 |
3 |
▶ | XPUSHs(sv_2mortal(C2Sv(found->stringval, NULL))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(found->stringval, NULL))); |
0 |
3 |
3 |
|
| 5549 |
3 |
| break; |
| 5550 |
0 |
| default: |
| 5551 |
0 |
| xmlXPathFreeObject(found); |
| 5552 |
0 |
| croak("Unknown XPath return type"); |
| 5553 |
|
| } |
| 5554 |
51 |
| xmlXPathFreeObject(found); |
| 5555 |
|
| } else { |
| 5556 |
12 |
| REPORT_ERROR(0); |
| 5557 |
|
| } |
| 5558 |
|
| |
| 5559 |
|
| void |
| 5560 |
|
| _findnodes( pnode, perl_xpath ) |
| 5561 |
|
| SV* pnode |
| 5562 |
|
| SV * perl_xpath |
| 5563 |
|
| PREINIT: |
| 5564 |
95 |
| xmlNodePtr node = PmmSvNode(pnode); |
| 5565 |
95 |
| ProxyNodePtr owner = NULL; |
| 5566 |
95 |
| xmlNodeSetPtr nodelist = NULL; |
| 5567 |
95 |
| SV * element = NULL ; |
| 5568 |
95 |
| xmlChar * xpath = NULL ; |
| 5569 |
95 |
| xmlXPathCompExprPtr comp = NULL; |
| 5570 |
95 |
| PREINIT_SAVED_ERROR |
| 5571 |
|
| INIT: |
| 5572 |
95 |
▶ | if ( node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node == NULL ) { |
0 |
95 |
95 |
|
| 5573 |
0 |
▶ | if ( xpath ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath ) |
0 |
0 |
0 |
|
| 5574 |
0 |
| xmlFree(xpath); |
| 5575 |
0 |
| croak( "lost node" ); |
| 5576 |
|
| } |
| 5577 |
95 |
▶ | if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
3 |
92 |
95 |
| if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
3 |
0 |
3 |
|
| 5578 |
3 |
| comp = INT2PTR(xmlXPathCompExprPtr,SvIV((SV*)SvRV( perl_xpath ))); |
| 5579 |
3 |
▶ | if (!comp) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!comp) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 5580 |
|
| } else { |
| 5581 |
92 |
| xpath = nodeSv2C(perl_xpath, node); |
| 5582 |
92 |
▶ | if ( !(xpath && xmlStrlen(xpath)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
92 |
0 |
92 |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
0 |
92 |
92 |
|
| 5583 |
|
| xs_warn( "bad xpath\n" ); |
| 5584 |
0 |
▶ | if ( xpath ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath ) |
0 |
0 |
0 |
|
| 5585 |
0 |
| xmlFree(xpath); |
| 5586 |
0 |
| croak( "empty XPath found" ); |
| 5587 |
|
| XSRETURN_UNDEF; |
| 5588 |
|
| } |
| 5589 |
|
| } |
| 5590 |
|
| PPCODE: |
| 5591 |
95 |
| INIT_ERROR_HANDLER; |
| 5592 |
95 |
▶ | if (comp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (comp) { |
3 |
92 |
95 |
|
| 5593 |
3 |
| nodelist = domXPathCompSelect( node, comp ); |
| 5594 |
|
| } else { |
| 5595 |
92 |
| nodelist = domXPathSelect( node, xpath ); |
| 5596 |
92 |
| xmlFree(xpath); |
| 5597 |
|
| } |
| 5598 |
95 |
| CLEANUP_ERROR_HANDLER; |
| 5599 |
|
| |
| 5600 |
95 |
▶ | if ( nodelist ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist ) { |
87 |
8 |
95 |
|
| 5601 |
87 |
| REPORT_ERROR(1); |
| 5602 |
87 |
▶ | if ( nodelist->nodeNr > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist->nodeNr > 0 ) { |
81 |
6 |
87 |
|
| 5603 |
|
| int i; |
| 5604 |
81 |
| int len = nodelist->nodeNr; |
| 5605 |
81 |
| const char * cls = "XML::LibXML::Node"; |
| 5606 |
|
| xmlNodePtr tnode; |
| 5607 |
81 |
▶ | owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
81 |
0 |
81 |
| owner = PmmOWNERPO(SvPROXYNODE(pnode)); |
23 |
58 |
81 |
|
| 5608 |
|
| |
| 5609 |
6280 |
▶ | for(i=0 ; i < len; i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for(i=0 ; i < len; i++){ |
6199 |
81 |
6280 |
|
| 5610 |
|
| /* we have to create a new instance of an objectptr. |
| 5611 |
|
| * and then place the current node into the new object. |
| 5612 |
|
| * afterwards we can push the object to the array! |
| 5613 |
|
| */ |
| 5614 |
6199 |
| element = NULL; |
| 5615 |
6199 |
| tnode = nodelist->nodeTab[i]; |
| 5616 |
6199 |
▶ | if (tnode->type == XML_NAMESPACE_DECL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->type == XML_NAMESPACE_DECL) { |
3 |
6196 |
6199 |
|
| 5617 |
3 |
| xmlNsPtr newns = xmlCopyNamespace((xmlNsPtr)tnode); |
| 5618 |
3 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
3 |
0 |
3 |
|
| 5619 |
3 |
| element = NEWSV(0,0); |
| 5620 |
3 |
| cls = PmmNodeTypeName( tnode ); |
| 5621 |
3 |
| element = sv_setref_pv( element, |
| 5622 |
|
| (const char *)cls, |
| 5623 |
|
| newns |
| 5624 |
|
| ); |
| 5625 |
|
| } |
| 5626 |
|
| else { |
| 5627 |
0 |
| continue; |
| 5628 |
|
| } |
| 5629 |
|
| } |
| 5630 |
|
| else { |
| 5631 |
6196 |
| element = PmmNodeToSv(tnode, owner); |
| 5632 |
|
| } |
| 5633 |
|
| |
| 5634 |
6199 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
6199 |
6199 |
|
| 5635 |
|
| } |
| 5636 |
|
| } |
| 5637 |
87 |
| xmlXPathFreeNodeSet( nodelist ); |
| 5638 |
|
| } else { |
| 5639 |
8 |
| REPORT_ERROR(0); |
| 5640 |
|
| } |
| 5641 |
|
| |
| 5642 |
|
| void |
| 5643 |
|
| getNamespaces( pnode ) |
| 5644 |
|
| SV * pnode |
| 5645 |
|
| ALIAS: |
| 5646 |
|
| namespaces = 1 |
| 5647 |
|
| PREINIT: |
| 5648 |
|
| xmlNodePtr node; |
| 5649 |
37 |
| xmlNsPtr ns = NULL; |
| 5650 |
37 |
| xmlNsPtr newns = NULL; |
| 5651 |
37 |
| SV* element = &PL_sv_undef; |
| 5652 |
37 |
| const char * class = "XML::LibXML::Namespace"; |
| 5653 |
|
| INIT: |
| 5654 |
|
| PERL_UNUSED_VAR(ix); |
| 5655 |
37 |
| node = PmmSvNode(pnode); |
| 5656 |
37 |
▶ | if ( node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node == NULL ) { |
0 |
37 |
37 |
|
| 5657 |
0 |
| croak( "lost node" ); |
| 5658 |
|
| } |
| 5659 |
|
| PPCODE: |
| 5660 |
37 |
▶ | if (node->type == XML_ELEMENT_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_ELEMENT_NODE) { |
37 |
0 |
37 |
|
| 5661 |
37 |
| ns = node->nsDef; |
| 5662 |
42 |
▶ | while ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns != NULL ) { |
5 |
37 |
42 |
|
| 5663 |
5 |
▶ | if (ns->prefix != NULL || ns->href != NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ns->prefix != NULL || ns->href != NULL) { |
2 |
3 |
5 |
| if (ns->prefix != NULL || ns->href != NULL) { |
2 |
0 |
2 |
|
| 5664 |
5 |
| newns = xmlCopyNamespace(ns); |
| 5665 |
5 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
5 |
0 |
5 |
|
| 5666 |
5 |
| element = NEWSV(0,0); |
| 5667 |
5 |
| element = sv_setref_pv( element, |
| 5668 |
|
| (const char *)class, |
| 5669 |
|
| (void*)newns |
| 5670 |
|
| ); |
| 5671 |
5 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
5 |
5 |
|
| 5672 |
|
| } |
| 5673 |
|
| } |
| 5674 |
5 |
| ns = ns->next; |
| 5675 |
|
| } |
| 5676 |
|
| } |
| 5677 |
|
| |
| 5678 |
|
| SV * |
| 5679 |
|
| getNamespace( node ) |
| 5680 |
|
| xmlNodePtr node |
| 5681 |
|
| ALIAS: |
| 5682 |
|
| localNamespace = 1 |
| 5683 |
|
| localNS = 2 |
| 5684 |
|
| PREINIT: |
| 5685 |
1 |
| xmlNsPtr ns = NULL; |
| 5686 |
1 |
| xmlNsPtr newns = NULL; |
| 5687 |
1 |
| const char * class = "XML::LibXML::Namespace"; |
| 5688 |
|
| CODE: |
| 5689 |
|
| PERL_UNUSED_VAR(ix); |
| 5690 |
1 |
▶ | if ( node->type == XML_ELEMENT_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node->type == XML_ELEMENT_NODE |
0 |
1 |
1 |
|
| 5691 |
0 |
▶ | || node->type == XML_ATTRIBUTE_NODE |
Branch: 1 branch
| Branch | True | False | Total |
| || node->type == XML_ATTRIBUTE_NODE |
0 |
0 |
0 |
|
| 5692 |
0 |
▶ | || node->type == XML_PI_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| || node->type == XML_PI_NODE ) { |
0 |
0 |
0 |
|
| 5693 |
1 |
| ns = node->ns; |
| 5694 |
1 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
1 |
0 |
1 |
|
| 5695 |
1 |
| newns = xmlCopyNamespace(ns); |
| 5696 |
1 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
1 |
0 |
1 |
|
| 5697 |
1 |
| RETVAL = NEWSV(0,0); |
| 5698 |
1 |
| RETVAL = sv_setref_pv( RETVAL, |
| 5699 |
|
| (const char *)class, |
| 5700 |
|
| (void*)newns |
| 5701 |
|
| ); |
| 5702 |
|
| } else { |
| 5703 |
0 |
| XSRETURN_UNDEF; |
| 5704 |
|
| } |
| 5705 |
|
| } |
| 5706 |
|
| else { |
| 5707 |
0 |
| XSRETURN_UNDEF; |
| 5708 |
|
| } |
| 5709 |
|
| } else { |
| 5710 |
0 |
| XSRETURN_UNDEF; |
| 5711 |
|
| } |
| 5712 |
|
| OUTPUT: |
| 5713 |
|
| RETVAL |
| 5714 |
|
| |
| 5715 |
|
| |
| 5716 |
|
| SV * |
| 5717 |
|
| nodePath( self ) |
| 5718 |
|
| xmlNodePtr self |
| 5719 |
|
| PREINIT: |
| 5720 |
3 |
| xmlChar * path = NULL; |
| 5721 |
|
| CODE: |
| 5722 |
3 |
| path = xmlGetNodePath( self ); |
| 5723 |
3 |
▶ | if ( path == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( path == NULL ) { |
0 |
3 |
3 |
|
| 5724 |
0 |
| croak( "cannot calculate path for the given node" ); |
| 5725 |
|
| } |
| 5726 |
3 |
| RETVAL = C2Sv( path, NULL ); |
| 5727 |
3 |
| xmlFree(path); |
| 5728 |
|
| OUTPUT: |
| 5729 |
|
| RETVAL |
| 5730 |
|
| |
| 5731 |
|
| int |
| 5732 |
|
| line_number( self ) |
| 5733 |
|
| xmlNodePtr self |
| 5734 |
|
| CODE: |
| 5735 |
3 |
▶ | RETVAL = xmlGetLineNo( self ); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = xmlGetLineNo( self ); |
0 |
3 |
3 |
|
| 5736 |
|
| OUTPUT: |
| 5737 |
|
| RETVAL |
| 5738 |
|
| |
| 5739 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Element |
| 5740 |
|
| |
| 5741 |
|
| SV* |
| 5742 |
|
| new(CLASS, name ) |
| 5743 |
|
| char * name |
| 5744 |
|
| PREINIT: |
| 5745 |
|
| xmlNodePtr newNode; |
| 5746 |
12 |
| ProxyNodePtr docfrag = NULL; |
| 5747 |
|
| CODE: |
| 5748 |
12 |
| docfrag = PmmNewFragment(NULL); |
| 5749 |
12 |
| newNode = xmlNewNode( NULL, (const xmlChar*)name ); |
| 5750 |
12 |
| newNode->doc = NULL; |
| 5751 |
12 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 5752 |
12 |
| RETVAL = PmmNodeToSv(newNode, docfrag ); |
| 5753 |
|
| OUTPUT: |
| 5754 |
|
| RETVAL |
| 5755 |
|
| |
| 5756 |
|
| int |
| 5757 |
|
| _setNamespace(self, namespaceURI, namespacePrefix = &PL_sv_undef, flag = 1 ) |
| 5758 |
|
| SV * self |
| 5759 |
|
| SV * namespaceURI |
| 5760 |
|
| SV * namespacePrefix |
| 5761 |
|
| int flag |
| 5762 |
|
| PREINIT: |
| 5763 |
33 |
| xmlNodePtr node = PmmSvNode(self); |
| 5764 |
33 |
| xmlChar * nsURI = nodeSv2C(namespaceURI,node); |
| 5765 |
33 |
| xmlChar * nsPrefix = NULL; |
| 5766 |
33 |
▶ | xmlNsPtr ns = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNsPtr ns = NULL; |
33 |
0 |
33 |
|
| 5767 |
|
| INIT: |
| 5768 |
33 |
▶ | if ( node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node == NULL ) { |
0 |
33 |
33 |
|
| 5769 |
0 |
▶ | if ( nsURI != NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI != NULL ) |
0 |
0 |
0 |
|
| 5770 |
0 |
| xmlFree( nsURI ); |
| 5771 |
0 |
| croak( "lost node" ); |
| 5772 |
|
| } |
| 5773 |
|
| CODE: |
| 5774 |
|
| /* if ( !nsURI ){ |
| 5775 |
|
| XSRETURN_UNDEF; |
| 5776 |
|
| } */ |
| 5777 |
|
| |
| 5778 |
33 |
| nsPrefix = nodeSv2C(namespacePrefix, node); |
| 5779 |
33 |
▶ | if ( xmlStrlen( nsPrefix ) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrlen( nsPrefix ) == 0 ) { |
1 |
32 |
33 |
|
| 5780 |
1 |
| xmlFree(nsPrefix); |
| 5781 |
1 |
| nsPrefix = NULL; |
| 5782 |
|
| } |
| 5783 |
33 |
▶ | if ( xmlStrlen( nsURI ) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrlen( nsURI ) == 0 ) { |
1 |
32 |
33 |
|
| 5784 |
1 |
| xmlFree(nsURI); |
| 5785 |
1 |
| nsURI = NULL; |
| 5786 |
|
| } |
| 5787 |
33 |
▶ | if ( nsPrefix == NULL && nsURI == NULL ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsPrefix == NULL && nsURI == NULL ) { |
1 |
32 |
33 |
| if ( nsPrefix == NULL && nsURI == NULL ) { |
1 |
0 |
1 |
|
| 5788 |
|
| /* special case: empty namespace */ |
| 5789 |
2 |
▶ | if ( (ns = xmlSearchNs(node->doc, node, NULL)) && |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (ns = xmlSearchNs(node->doc, node, NULL)) && |
0 |
1 |
1 |
|
| 5790 |
0 |
▶ | ( ns->href && xmlStrlen( ns->href ) != 0 ) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| ( ns->href && xmlStrlen( ns->href ) != 0 ) ) { |
0 |
0 |
0 |
| ( ns->href && xmlStrlen( ns->href ) != 0 ) ) { |
0 |
0 |
0 |
|
| 5791 |
|
| /* won't take it */ |
| 5792 |
0 |
| RETVAL = 0; |
| 5793 |
1 |
▶ | } else if ( flag ) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if ( flag ) { |
1 |
0 |
1 |
|
| 5794 |
|
| /* no namespace */ |
| 5795 |
1 |
| xmlSetNs(node, NULL); |
| 5796 |
1 |
| RETVAL = 1; |
| 5797 |
|
| } else { |
| 5798 |
0 |
| RETVAL = 0; |
| 5799 |
|
| } |
| 5800 |
|
| } |
| 5801 |
32 |
▶ | else if ( flag && (ns = xmlSearchNs(node->doc, node, nsPrefix)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if ( flag && (ns = xmlSearchNs(node->doc, node, nsPrefix)) ) { |
4 |
28 |
32 |
| else if ( flag && (ns = xmlSearchNs(node->doc, node, nsPrefix)) ) { |
1 |
3 |
4 |
|
| 5802 |
|
| /* user just wants to set the namespace for the node */ |
| 5803 |
|
| /* try to reuse an existing declaration for the prefix */ |
| 5804 |
2 |
▶ | if ( xmlStrEqual( ns->href, nsURI ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrEqual( ns->href, nsURI ) ) { |
1 |
0 |
1 |
|
| 5805 |
1 |
| RETVAL = 1; |
| 5806 |
|
| } |
| 5807 |
0 |
▶ | else if ( (ns = xmlNewNs( node, nsURI, nsPrefix )) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( (ns = xmlNewNs( node, nsURI, nsPrefix )) ) { |
0 |
0 |
0 |
|
| 5808 |
0 |
| RETVAL = 1; |
| 5809 |
|
| } |
| 5810 |
|
| else { |
| 5811 |
0 |
| RETVAL = 0; |
| 5812 |
|
| } |
| 5813 |
|
| } |
| 5814 |
31 |
▶ | else if ( (ns = xmlNewNs( node, nsURI, nsPrefix )) ) |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( (ns = xmlNewNs( node, nsURI, nsPrefix )) ) |
31 |
0 |
31 |
|
| 5815 |
31 |
| RETVAL = 1; |
| 5816 |
|
| else |
| 5817 |
0 |
| RETVAL = 0; |
| 5818 |
|
| |
| 5819 |
33 |
▶ | if ( flag && ns ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( flag && ns ) { |
5 |
28 |
33 |
| if ( flag && ns ) { |
4 |
1 |
5 |
|
| 5820 |
4 |
| xmlSetNs(node, ns); |
| 5821 |
|
| } |
| 5822 |
33 |
▶ | if ( nsPrefix ) xmlFree(nsPrefix); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsPrefix ) xmlFree(nsPrefix); |
32 |
1 |
33 |
|
| 5823 |
33 |
▶ | if ( nsURI ) xmlFree(nsURI); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) xmlFree(nsURI); |
32 |
1 |
33 |
|
| 5824 |
|
| OUTPUT: |
| 5825 |
|
| RETVAL |
| 5826 |
|
| |
| 5827 |
|
| int |
| 5828 |
|
| setNamespaceDeclURI( self, svprefix, newURI ) |
| 5829 |
|
| xmlNodePtr self |
| 5830 |
|
| SV * svprefix |
| 5831 |
|
| SV * newURI |
| 5832 |
|
| PREINIT: |
| 5833 |
15 |
| xmlChar * prefix = NULL; |
| 5834 |
15 |
▶ | xmlChar * nsURI = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlChar * nsURI = NULL; |
15 |
0 |
15 |
|
| 5835 |
|
| xmlNsPtr ns; |
| 5836 |
|
| CODE: |
| 5837 |
15 |
| RETVAL = 0; |
| 5838 |
15 |
| prefix = nodeSv2C( svprefix , self ); |
| 5839 |
15 |
| nsURI = nodeSv2C( newURI , self ); |
| 5840 |
|
| /* null empty values */ |
| 5841 |
15 |
▶ | if ( prefix && xmlStrlen(prefix) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( prefix && xmlStrlen(prefix) == 0) { |
15 |
0 |
15 |
| if ( prefix && xmlStrlen(prefix) == 0) { |
3 |
12 |
15 |
|
| 5842 |
3 |
| xmlFree( prefix ); |
| 5843 |
3 |
| prefix = NULL; |
| 5844 |
|
| } |
| 5845 |
15 |
▶ | if ( nsURI && xmlStrlen(nsURI) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) == 0) { |
12 |
3 |
15 |
| if ( nsURI && xmlStrlen(nsURI) == 0) { |
0 |
12 |
12 |
|
| 5846 |
0 |
| xmlFree( nsURI ); |
| 5847 |
0 |
| nsURI = NULL; |
| 5848 |
|
| } |
| 5849 |
15 |
| ns = self->nsDef; |
| 5850 |
28 |
▶ | while ( ns ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns ) { |
20 |
8 |
28 |
|
| 5851 |
39 |
▶ | if ((ns->prefix || ns->href ) && |
Branch: 1 branch
| Branch | True | False | Total |
| if ((ns->prefix || ns->href ) && |
11 |
9 |
20 |
|
| 5852 |
19 |
| ( xmlStrcmp( ns->prefix, prefix ) == 0 )) { |
| 5853 |
7 |
▶ | if (ns->href) xmlFree((char*)ns->href); |
Branch: 1 branch
| Branch | True | False | Total |
| if (ns->href) xmlFree((char*)ns->href); |
7 |
0 |
7 |
|
| 5854 |
7 |
| ns->href = nsURI; |
| 5855 |
7 |
▶ | if ( nsURI == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI == NULL ) { |
3 |
4 |
7 |
|
| 5856 |
3 |
| domRemoveNsRefs( self, ns ); |
| 5857 |
|
| } else |
| 5858 |
4 |
| nsURI = NULL; /* do not free it */ |
| 5859 |
7 |
| RETVAL = 1; |
| 5860 |
7 |
| break; |
| 5861 |
|
| } else { |
| 5862 |
13 |
| ns = ns->next; |
| 5863 |
|
| } |
| 5864 |
|
| } |
| 5865 |
15 |
▶ | if ( prefix ) xmlFree( prefix ); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix ) xmlFree( prefix ); |
12 |
3 |
15 |
|
| 5866 |
15 |
▶ | if ( nsURI ) xmlFree( nsURI ); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) xmlFree( nsURI ); |
8 |
7 |
15 |
|
| 5867 |
|
| OUTPUT: |
| 5868 |
|
| RETVAL |
| 5869 |
|
| |
| 5870 |
|
| int |
| 5871 |
|
| setNamespaceDeclPrefix( self, svprefix, newPrefix ) |
| 5872 |
|
| xmlNodePtr self |
| 5873 |
|
| SV * svprefix |
| 5874 |
|
| SV * newPrefix |
| 5875 |
|
| PREINIT: |
| 5876 |
6 |
| xmlChar * prefix = NULL; |
| 5877 |
6 |
▶ | xmlChar * nsPrefix = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlChar * nsPrefix = NULL; |
6 |
0 |
6 |
|
| 5878 |
|
| xmlNsPtr ns; |
| 5879 |
|
| CODE: |
| 5880 |
6 |
| RETVAL = 0; |
| 5881 |
6 |
| prefix = nodeSv2C( svprefix , self ); |
| 5882 |
6 |
| nsPrefix = nodeSv2C( newPrefix , self ); |
| 5883 |
|
| /* null empty values */ |
| 5884 |
6 |
▶ | if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
6 |
0 |
6 |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
1 |
5 |
6 |
|
| 5885 |
1 |
| xmlFree( prefix ); |
| 5886 |
1 |
| prefix = NULL; |
| 5887 |
|
| } |
| 5888 |
6 |
▶ | if ( nsPrefix != NULL && xmlStrlen(nsPrefix) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsPrefix != NULL && xmlStrlen(nsPrefix) == 0) { |
5 |
1 |
6 |
| if ( nsPrefix != NULL && xmlStrlen(nsPrefix) == 0) { |
2 |
3 |
5 |
|
| 5889 |
2 |
| xmlFree( nsPrefix ); |
| 5890 |
2 |
| nsPrefix = NULL; |
| 5891 |
|
| } |
| 5892 |
6 |
▶ | if ( xmlStrcmp( prefix, nsPrefix ) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrcmp( prefix, nsPrefix ) == 0 ) { |
0 |
6 |
6 |
|
| 5893 |
0 |
| RETVAL = 1; |
| 5894 |
|
| } else { |
| 5895 |
|
| /* check that new prefix is not in scope */ |
| 5896 |
6 |
| ns = xmlSearchNs( self->doc, self, nsPrefix ); |
| 5897 |
6 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
2 |
4 |
6 |
|
| 5898 |
2 |
▶ | if (nsPrefix != NULL) xmlFree( nsPrefix ); |
Branch: 1 branch
| Branch | True | False | Total |
| if (nsPrefix != NULL) xmlFree( nsPrefix ); |
1 |
1 |
2 |
|
| 5899 |
2 |
▶ | if (prefix != NULL) xmlFree( prefix ); |
Branch: 1 branch
| Branch | True | False | Total |
| if (prefix != NULL) xmlFree( prefix ); |
2 |
0 |
2 |
|
| 5900 |
2 |
| croak("setNamespaceDeclPrefix: prefix '%s' is in use", ns->prefix); |
| 5901 |
|
| } |
| 5902 |
|
| /* lookup the declaration */ |
| 5903 |
4 |
| ns = self->nsDef; |
| 5904 |
7 |
▶ | while ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns != NULL ) { |
7 |
0 |
7 |
|
| 5905 |
13 |
▶ | if ((ns->prefix != NULL || ns->href != NULL) && |
Branch: 1 branch
| Branch | True | False | Total |
| if ((ns->prefix != NULL || ns->href != NULL) && |
3 |
4 |
7 |
|
| 5906 |
6 |
| xmlStrcmp( ns->prefix, prefix ) == 0 ) { |
| 5907 |
4 |
▶ | if ( ns->href == NULL && nsPrefix != NULL ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ns->href == NULL && nsPrefix != NULL ) { |
1 |
3 |
4 |
| if ( ns->href == NULL && nsPrefix != NULL ) { |
0 |
1 |
1 |
|
| 5908 |
|
| /* xmlns:foo="" - no go */ |
| 5909 |
0 |
▶ | if ( prefix != NULL) xmlFree(prefix); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL) xmlFree(prefix); |
0 |
0 |
0 |
|
| 5910 |
0 |
| croak("setNamespaceDeclPrefix: cannot set non-empty prefix for empty namespace"); |
| 5911 |
|
| } |
| 5912 |
4 |
▶ | if ( ns->prefix != NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns->prefix != NULL ) |
3 |
1 |
4 |
|
| 5913 |
3 |
| xmlFree( (xmlChar*)ns->prefix ); |
| 5914 |
4 |
| ns->prefix = nsPrefix; |
| 5915 |
4 |
| nsPrefix = NULL; /* do not free it */ |
| 5916 |
4 |
| RETVAL = 1; |
| 5917 |
4 |
| break; |
| 5918 |
|
| } else { |
| 5919 |
3 |
| ns = ns->next; |
| 5920 |
|
| } |
| 5921 |
|
| } |
| 5922 |
|
| } |
| 5923 |
4 |
▶ | if ( nsPrefix != NULL ) xmlFree(nsPrefix); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsPrefix != NULL ) xmlFree(nsPrefix); |
0 |
4 |
4 |
|
| 5924 |
4 |
▶ | if ( prefix != NULL) xmlFree(prefix); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL) xmlFree(prefix); |
3 |
1 |
4 |
|
| 5925 |
|
| OUTPUT: |
| 5926 |
|
| RETVAL |
| 5927 |
|
| |
| 5928 |
|
| |
| 5929 |
|
| SV* |
| 5930 |
|
| _getNamespaceDeclURI( self, ns_prefix ) |
| 5931 |
|
| xmlNodePtr self |
| 5932 |
|
| SV * ns_prefix |
| 5933 |
|
| PREINIT: |
| 5934 |
|
| xmlChar * prefix; |
| 5935 |
|
| xmlNsPtr ns; |
| 5936 |
|
| CODE: |
| 5937 |
22 |
| prefix = nodeSv2C(ns_prefix, self ); |
| 5938 |
22 |
▶ | if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
21 |
1 |
22 |
| if ( prefix != NULL && xmlStrlen(prefix) == 0) { |
3 |
18 |
21 |
|
| 5939 |
3 |
| xmlFree( prefix ); |
| 5940 |
3 |
| prefix = NULL; |
| 5941 |
|
| } |
| 5942 |
22 |
| RETVAL = &PL_sv_undef; |
| 5943 |
22 |
| ns = self->nsDef; |
| 5944 |
33 |
▶ | while ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns != NULL ) { |
24 |
9 |
33 |
|
| 5945 |
48 |
▶ | if ( (ns->prefix != NULL || ns->href != NULL) && |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (ns->prefix != NULL || ns->href != NULL) && |
8 |
16 |
24 |
|
| 5946 |
24 |
| xmlStrcmp( ns->prefix, prefix ) == 0 ) { |
| 5947 |
13 |
| RETVAL = C2Sv(ns->href, NULL); |
| 5948 |
13 |
| break; |
| 5949 |
|
| } else { |
| 5950 |
11 |
| ns = ns->next; |
| 5951 |
|
| } |
| 5952 |
|
| } |
| 5953 |
22 |
▶ | if ( prefix != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL ) { |
18 |
4 |
22 |
|
| 5954 |
18 |
| xmlFree( prefix ); |
| 5955 |
|
| } |
| 5956 |
|
| |
| 5957 |
|
| OUTPUT: |
| 5958 |
|
| RETVAL |
| 5959 |
|
| |
| 5960 |
|
| int |
| 5961 |
|
| hasAttribute( self, attr_name ) |
| 5962 |
|
| xmlNodePtr self |
| 5963 |
|
| SV * attr_name |
| 5964 |
|
| PREINIT: |
| 5965 |
|
| xmlChar * name; |
| 5966 |
|
| CODE: |
| 5967 |
16 |
| name = nodeSv2C(attr_name, self ); |
| 5968 |
16 |
▶ | if ( ! name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ! name ) { |
0 |
16 |
16 |
|
| 5969 |
0 |
| XSRETURN_UNDEF; |
| 5970 |
|
| } |
| 5971 |
16 |
▶ | if ( domGetAttrNode( self, name ) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( domGetAttrNode( self, name ) ) { |
9 |
7 |
16 |
|
| 5972 |
9 |
| RETVAL = 1; |
| 5973 |
|
| } |
| 5974 |
|
| else { |
| 5975 |
7 |
| RETVAL = 0; |
| 5976 |
|
| } |
| 5977 |
16 |
| xmlFree(name); |
| 5978 |
|
| OUTPUT: |
| 5979 |
|
| RETVAL |
| 5980 |
|
| |
| 5981 |
|
| int |
| 5982 |
|
| hasAttributeNS( self, namespaceURI, attr_name ) |
| 5983 |
|
| xmlNodePtr self |
| 5984 |
|
| SV * namespaceURI |
| 5985 |
|
| SV * attr_name |
| 5986 |
|
| PREINIT: |
| 5987 |
|
| xmlChar * name; |
| 5988 |
|
| xmlChar * nsURI; |
| 5989 |
|
| xmlNodePtr attr; |
| 5990 |
|
| CODE: |
| 5991 |
16 |
| name = nodeSv2C(attr_name, self ); |
| 5992 |
16 |
| nsURI = nodeSv2C(namespaceURI, self ); |
| 5993 |
|
| |
| 5994 |
16 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
16 |
16 |
|
| 5995 |
0 |
▶ | if ( nsURI != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI != NULL ) { |
0 |
0 |
0 |
|
| 5996 |
0 |
| xmlFree(nsURI); |
| 5997 |
|
| } |
| 5998 |
0 |
| XSRETURN_UNDEF; |
| 5999 |
|
| } |
| 6000 |
16 |
▶ | if ( nsURI != NULL && xmlStrlen(nsURI) == 0 ){ |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI != NULL && xmlStrlen(nsURI) == 0 ){ |
14 |
2 |
16 |
| if ( nsURI != NULL && xmlStrlen(nsURI) == 0 ){ |
2 |
12 |
14 |
|
| 6001 |
2 |
| xmlFree(nsURI); |
| 6002 |
2 |
| nsURI = NULL; |
| 6003 |
|
| } |
| 6004 |
16 |
| attr = (xmlNodePtr) xmlHasNsProp( self, name, nsURI ); |
| 6005 |
16 |
▶ | if ( attr && attr->type == XML_ATTRIBUTE_NODE ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( attr && attr->type == XML_ATTRIBUTE_NODE ) { |
10 |
6 |
16 |
| if ( attr && attr->type == XML_ATTRIBUTE_NODE ) { |
8 |
2 |
10 |
|
| 6006 |
8 |
| RETVAL = 1; |
| 6007 |
|
| } |
| 6008 |
|
| else { |
| 6009 |
8 |
| RETVAL = 0; |
| 6010 |
|
| } |
| 6011 |
|
| |
| 6012 |
16 |
| xmlFree(name); |
| 6013 |
16 |
▶ | if ( nsURI != NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI != NULL ){ |
12 |
4 |
16 |
|
| 6014 |
12 |
| xmlFree(nsURI); |
| 6015 |
|
| } |
| 6016 |
|
| OUTPUT: |
| 6017 |
|
| RETVAL |
| 6018 |
|
| |
| 6019 |
|
| SV* |
| 6020 |
|
| _getAttribute( self, attr_name, useDomEncoding = 0 ) |
| 6021 |
|
| xmlNodePtr self |
| 6022 |
|
| SV * attr_name |
| 6023 |
|
| int useDomEncoding |
| 6024 |
|
| PREINIT: |
| 6025 |
|
| xmlChar * name; |
| 6026 |
46 |
| xmlChar * prefix = NULL; |
| 6027 |
46 |
| xmlChar * localname = NULL; |
| 6028 |
46 |
| xmlChar * ret = NULL; |
| 6029 |
46 |
| xmlNsPtr ns = NULL; |
| 6030 |
|
| CODE: |
| 6031 |
46 |
| name = nodeSv2C(attr_name, self ); |
| 6032 |
46 |
▶ | if( !name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( !name ) { |
0 |
46 |
46 |
|
| 6033 |
0 |
| XSRETURN_UNDEF; |
| 6034 |
|
| } |
| 6035 |
|
| |
| 6036 |
46 |
| ret = xmlGetNoNsProp(self, name); |
| 6037 |
46 |
▶ | if ( ret == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret == NULL ) { |
7 |
39 |
46 |
|
| 6038 |
7 |
| localname = xmlSplitQName2(name, &prefix); |
| 6039 |
7 |
▶ | if ( localname != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( localname != NULL ) { |
7 |
0 |
7 |
|
| 6040 |
7 |
| ns = xmlSearchNs( self->doc, self, prefix ); |
| 6041 |
7 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
7 |
0 |
7 |
|
| 6042 |
7 |
| ret = xmlGetNsProp(self, localname, ns->href); |
| 6043 |
|
| } |
| 6044 |
7 |
▶ | if ( prefix != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix != NULL) { |
7 |
0 |
7 |
|
| 6045 |
7 |
| xmlFree( prefix ); |
| 6046 |
|
| } |
| 6047 |
7 |
| xmlFree( localname ); |
| 6048 |
|
| } |
| 6049 |
|
| } |
| 6050 |
46 |
| xmlFree(name); |
| 6051 |
46 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
46 |
0 |
46 |
|
| 6052 |
46 |
▶ | if ( useDomEncoding ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( useDomEncoding ) { |
9 |
37 |
46 |
|
| 6053 |
9 |
| RETVAL = nodeC2Sv(ret, self); |
| 6054 |
|
| } |
| 6055 |
|
| else { |
| 6056 |
37 |
| RETVAL = C2Sv(ret, NULL); |
| 6057 |
|
| } |
| 6058 |
46 |
| xmlFree( ret ); |
| 6059 |
|
| } |
| 6060 |
|
| else { |
| 6061 |
0 |
| XSRETURN_UNDEF; |
| 6062 |
|
| } |
| 6063 |
|
| |
| 6064 |
|
| OUTPUT: |
| 6065 |
|
| RETVAL |
| 6066 |
|
| |
| 6067 |
|
| void |
| 6068 |
|
| _setAttribute( self, attr_name, attr_value ) |
| 6069 |
|
| xmlNodePtr self |
| 6070 |
|
| SV * attr_name |
| 6071 |
|
| SV * attr_value |
| 6072 |
|
| PREINIT: |
| 6073 |
28 |
| xmlChar * name = NULL; |
| 6074 |
28 |
| xmlChar * value = NULL; |
| 6075 |
|
| #if LIBXML_VERSION < 20621 |
| 6076 |
|
| xmlChar * prefix = NULL; |
| 6077 |
|
| xmlChar * localname = NULL; |
| 6078 |
|
| #endif |
| 6079 |
|
| CODE: |
| 6080 |
28 |
| name = nodeSv2C(attr_name, self ); |
| 6081 |
|
| |
| 6082 |
28 |
▶ | if ( !LibXML_test_node_name(name) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name(name) ) { |
4 |
24 |
28 |
|
| 6083 |
4 |
| xmlFree(name); |
| 6084 |
4 |
| croak( "bad name" ); |
| 6085 |
|
| } |
| 6086 |
24 |
| value = nodeSv2C(attr_value, self ); |
| 6087 |
|
| #if LIBXML_VERSION >= 20621 |
| 6088 |
|
| /* |
| 6089 |
|
| * For libxml2-2.6.21 and later we can use just xmlSetProp |
| 6090 |
|
| */ |
| 6091 |
24 |
| xmlSetProp(self,name,value); |
| 6092 |
|
| #else |
| 6093 |
|
| /* |
| 6094 |
|
| * but xmlSetProp does not work correctly for older libxml2 versions |
| 6095 |
|
| * The following is copied from libxml2 source |
| 6096 |
|
| * with xmlSplitQName3 replaced by xmlSplitQName2 for compatibility |
| 6097 |
|
| * with older libxml2 versions |
| 6098 |
|
| */ |
| 6099 |
|
| localname = xmlSplitQName2(name, &prefix); |
| 6100 |
|
| if (localname != NULL) { |
| 6101 |
|
| xmlNsPtr ns; |
| 6102 |
|
| ns = xmlSearchNs(self->doc, self, prefix); |
| 6103 |
|
| if (prefix != NULL) |
| 6104 |
|
| xmlFree(prefix); |
| 6105 |
|
| if (ns != NULL) |
| 6106 |
|
| xmlSetNsProp(self, ns, localname, value); |
| 6107 |
|
| else |
| 6108 |
|
| xmlSetNsProp(self, NULL, name, value); |
| 6109 |
|
| xmlFree(localname); |
| 6110 |
|
| } else { |
| 6111 |
|
| xmlSetNsProp(self, NULL, name, value); |
| 6112 |
|
| } |
| 6113 |
|
| #endif |
| 6114 |
24 |
| xmlFree(name); |
| 6115 |
24 |
| xmlFree(value); |
| 6116 |
|
| |
| 6117 |
|
| |
| 6118 |
|
| void |
| 6119 |
|
| removeAttribute( self, attr_name ) |
| 6120 |
|
| xmlNodePtr self |
| 6121 |
|
| SV * attr_name |
| 6122 |
|
| PREINIT: |
| 6123 |
|
| xmlChar * name; |
| 6124 |
4 |
| xmlAttrPtr xattr = NULL; |
| 6125 |
|
| CODE: |
| 6126 |
4 |
| name = nodeSv2C(attr_name, self ); |
| 6127 |
4 |
▶ | if ( name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name ) { |
4 |
0 |
4 |
|
| 6128 |
4 |
| xattr = domGetAttrNode( self, name ); |
| 6129 |
|
| |
| 6130 |
4 |
▶ | if ( xattr ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xattr ) { |
4 |
0 |
4 |
|
| 6131 |
4 |
| xmlUnlinkNode((xmlNodePtr)xattr); |
| 6132 |
4 |
▶ | if ( xattr->_private ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xattr->_private ) { |
1 |
3 |
4 |
|
| 6133 |
1 |
| PmmFixOwner((ProxyNodePtr)xattr->_private, NULL); |
| 6134 |
|
| } |
| 6135 |
|
| else { |
| 6136 |
3 |
| xmlFreeProp(xattr); |
| 6137 |
|
| } |
| 6138 |
|
| } |
| 6139 |
4 |
| xmlFree(name); |
| 6140 |
|
| } |
| 6141 |
|
| |
| 6142 |
|
| SV* |
| 6143 |
|
| getAttributeNode( self, attr_name ) |
| 6144 |
|
| xmlNodePtr self |
| 6145 |
|
| SV * attr_name |
| 6146 |
|
| PREINIT: |
| 6147 |
|
| xmlChar * name; |
| 6148 |
45 |
| xmlAttrPtr ret = NULL; |
| 6149 |
|
| CODE: |
| 6150 |
45 |
| name = nodeSv2C(attr_name, self ); |
| 6151 |
45 |
▶ | if ( !name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !name ) { |
0 |
45 |
45 |
|
| 6152 |
0 |
| XSRETURN_UNDEF; |
| 6153 |
|
| } |
| 6154 |
|
| |
| 6155 |
45 |
| ret = domGetAttrNode( self, name ); |
| 6156 |
45 |
| xmlFree(name); |
| 6157 |
45 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
30 |
15 |
45 |
|
| 6158 |
30 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)ret, |
| 6159 |
30 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
30 |
0 |
30 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
30 |
0 |
30 |
|
| 6160 |
|
| } |
| 6161 |
|
| else { |
| 6162 |
15 |
| XSRETURN_UNDEF; |
| 6163 |
|
| } |
| 6164 |
|
| OUTPUT: |
| 6165 |
|
| RETVAL |
| 6166 |
|
| |
| 6167 |
|
| SV * |
| 6168 |
|
| setAttributeNode( self, attr_node ) |
| 6169 |
|
| xmlNodePtr self |
| 6170 |
|
| SV * attr_node |
| 6171 |
|
| PREINIT: |
| 6172 |
1 |
| xmlAttrPtr attr = (xmlAttrPtr)PmmSvNode( attr_node ); |
| 6173 |
1 |
| xmlAttrPtr ret = NULL; |
| 6174 |
|
| INIT: |
| 6175 |
1 |
▶ | if ( attr == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr == NULL ) { |
0 |
1 |
1 |
|
| 6176 |
0 |
| croak( "lost attribute" ); |
| 6177 |
|
| } |
| 6178 |
|
| CODE: |
| 6179 |
1 |
▶ | if ( attr != NULL && attr->type != XML_ATTRIBUTE_NODE ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( attr != NULL && attr->type != XML_ATTRIBUTE_NODE ) { |
1 |
0 |
1 |
| if ( attr != NULL && attr->type != XML_ATTRIBUTE_NODE ) { |
0 |
1 |
1 |
|
| 6180 |
0 |
| XSRETURN_UNDEF; |
| 6181 |
|
| } |
| 6182 |
1 |
▶ | if ( attr->doc != self->doc ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->doc != self->doc ) { |
0 |
1 |
1 |
|
| 6183 |
0 |
| domImportNode( self->doc, (xmlNodePtr)attr, 1, 1); |
| 6184 |
|
| } |
| 6185 |
1 |
| ret = domGetAttrNode( self, attr->name ); |
| 6186 |
1 |
▶ | if ( ret != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != NULL ) { |
0 |
1 |
1 |
|
| 6187 |
0 |
▶ | if ( ret != attr ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != attr ) { |
0 |
0 |
0 |
|
| 6188 |
0 |
| xmlReplaceNode( (xmlNodePtr)ret, (xmlNodePtr)attr ); |
| 6189 |
|
| } |
| 6190 |
|
| else { |
| 6191 |
0 |
| XSRETURN_UNDEF; |
| 6192 |
|
| } |
| 6193 |
|
| } |
| 6194 |
|
| else { |
| 6195 |
1 |
| xmlAddChild( self, (xmlNodePtr)attr ); |
| 6196 |
|
| } |
| 6197 |
|
| |
| 6198 |
1 |
▶ | if ( attr->_private != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->_private != NULL ) { |
1 |
0 |
1 |
|
| 6199 |
1 |
| PmmFixOwner( SvPROXYNODE(attr_node), PmmPROXYNODE(self) ); |
| 6200 |
|
| } |
| 6201 |
|
| |
| 6202 |
1 |
▶ | if ( ret == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret == NULL ) { |
1 |
0 |
1 |
|
| 6203 |
1 |
| XSRETURN_UNDEF; |
| 6204 |
|
| } |
| 6205 |
|
| |
| 6206 |
0 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)ret, NULL ); |
| 6207 |
0 |
| PmmFixOwner( SvPROXYNODE(RETVAL), NULL ); |
| 6208 |
|
| OUTPUT: |
| 6209 |
|
| RETVAL |
| 6210 |
|
| |
| 6211 |
|
| SV * |
| 6212 |
|
| _getAttributeNS( self, namespaceURI, attr_name, useDomEncoding = 0 ) |
| 6213 |
|
| xmlNodePtr self |
| 6214 |
|
| SV * namespaceURI |
| 6215 |
|
| SV * attr_name |
| 6216 |
|
| int useDomEncoding |
| 6217 |
|
| PREINIT: |
| 6218 |
|
| xmlChar * name; |
| 6219 |
|
| xmlChar * nsURI; |
| 6220 |
23 |
| xmlChar * ret = NULL; |
| 6221 |
|
| CODE: |
| 6222 |
23 |
| name = nodeSv2C( attr_name, self ); |
| 6223 |
23 |
| nsURI = nodeSv2C( namespaceURI, self ); |
| 6224 |
23 |
▶ | if ( !name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !name ) { |
0 |
23 |
23 |
|
| 6225 |
0 |
| xmlFree(nsURI); |
| 6226 |
0 |
| XSRETURN_UNDEF; |
| 6227 |
|
| } |
| 6228 |
23 |
▶ | if ( nsURI && xmlStrlen(nsURI) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) ) { |
22 |
1 |
23 |
| if ( nsURI && xmlStrlen(nsURI) ) { |
21 |
1 |
22 |
|
| 6229 |
21 |
| ret = xmlGetNsProp( self, name, nsURI ); |
| 6230 |
|
| } |
| 6231 |
|
| else { |
| 6232 |
2 |
| ret = xmlGetProp( self, name ); |
| 6233 |
|
| } |
| 6234 |
|
| |
| 6235 |
23 |
| xmlFree( name ); |
| 6236 |
23 |
▶ | if ( nsURI ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) { |
22 |
1 |
23 |
|
| 6237 |
22 |
| xmlFree( nsURI ); |
| 6238 |
|
| } |
| 6239 |
23 |
▶ | if ( ret ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret ) { |
23 |
0 |
23 |
|
| 6240 |
23 |
▶ | if (useDomEncoding) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (useDomEncoding) { |
0 |
23 |
23 |
|
| 6241 |
0 |
| RETVAL = nodeC2Sv( ret, self ); |
| 6242 |
|
| } else { |
| 6243 |
23 |
| RETVAL = C2Sv( ret, NULL ); |
| 6244 |
|
| } |
| 6245 |
23 |
| xmlFree( ret ); |
| 6246 |
|
| } |
| 6247 |
|
| else { |
| 6248 |
0 |
| XSRETURN_UNDEF; |
| 6249 |
|
| } |
| 6250 |
|
| OUTPUT: |
| 6251 |
|
| RETVAL |
| 6252 |
|
| |
| 6253 |
|
| void |
| 6254 |
|
| _setAttributeNS( self, namespaceURI, attr_name, attr_value ) |
| 6255 |
|
| xmlNodePtr self |
| 6256 |
|
| SV * namespaceURI |
| 6257 |
|
| SV * attr_name |
| 6258 |
|
| SV * attr_value |
| 6259 |
|
| PREINIT: |
| 6260 |
|
| xmlChar * nsURI; |
| 6261 |
48 |
| xmlChar * name = NULL; |
| 6262 |
48 |
| xmlChar * value = NULL; |
| 6263 |
48 |
| xmlNsPtr ns = NULL; |
| 6264 |
48 |
| xmlChar * localname = NULL; |
| 6265 |
48 |
| xmlChar * prefix = NULL; |
| 6266 |
48 |
| xmlNsPtr * all_ns = NULL; |
| 6267 |
|
| int i; |
| 6268 |
|
| INIT: |
| 6269 |
48 |
| name = nodeSv2C( attr_name, self ); |
| 6270 |
|
| |
| 6271 |
48 |
▶ | if ( !LibXML_test_node_name(name) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !LibXML_test_node_name(name) ) { |
3 |
45 |
48 |
|
| 6272 |
3 |
| xmlFree(name); |
| 6273 |
3 |
| croak( "bad name" ); |
| 6274 |
|
| } |
| 6275 |
|
| |
| 6276 |
45 |
| nsURI = nodeSv2C( namespaceURI, self ); |
| 6277 |
45 |
| localname = xmlSplitQName2(name, &prefix); |
| 6278 |
45 |
▶ | if ( localname ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( localname ) { |
21 |
24 |
45 |
|
| 6279 |
21 |
| xmlFree( name ); |
| 6280 |
21 |
| name = localname; |
| 6281 |
|
| } |
| 6282 |
|
| CODE: |
| 6283 |
45 |
| value = nodeSv2C( attr_value, self ); |
| 6284 |
|
| |
| 6285 |
45 |
▶ | if ( nsURI && xmlStrlen(nsURI) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) ) { |
44 |
1 |
45 |
| if ( nsURI && xmlStrlen(nsURI) ) { |
24 |
20 |
44 |
|
| 6286 |
|
| xs_warn( "found uri" ); |
| 6287 |
|
| |
| 6288 |
24 |
| ns = xmlSearchNsByHref( self->doc, self, nsURI ); |
| 6289 |
|
| |
| 6290 |
|
| /* |
| 6291 |
|
| * check for any prefixed namespaces occluded by a default namespace |
| 6292 |
|
| * because xmlSearchNsByHref will return default namespaces unless |
| 6293 |
|
| * you are searching on an attribute node, which may not exist yet |
| 6294 |
|
| */ |
| 6295 |
24 |
▶ | if ( ns && !ns->prefix ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ns && !ns->prefix ) |
20 |
4 |
24 |
| if ( ns && !ns->prefix ) |
4 |
16 |
20 |
|
| 6296 |
|
| { |
| 6297 |
4 |
| all_ns = xmlGetNsList(self->doc, self); |
| 6298 |
4 |
▶ | if ( all_ns ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( all_ns ) |
4 |
0 |
4 |
|
| 6299 |
|
| { |
| 6300 |
4 |
| i = 0; |
| 6301 |
4 |
| ns = all_ns[i]; |
| 6302 |
14 |
▶ | while ( ns ) |
Branch: 1 branch
| Branch | True | False | Total |
| while ( ns ) |
13 |
1 |
14 |
|
| 6303 |
|
| { |
| 6304 |
13 |
▶ | if ( ns->prefix && xmlStrEqual(ns->href, nsURI) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ns->prefix && xmlStrEqual(ns->href, nsURI) ) |
5 |
8 |
13 |
| if ( ns->prefix && xmlStrEqual(ns->href, nsURI) ) |
3 |
2 |
5 |
|
| 6305 |
|
| { |
| 6306 |
3 |
| break; |
| 6307 |
|
| } |
| 6308 |
10 |
| ns = all_ns[i++]; |
| 6309 |
|
| } |
| 6310 |
4 |
| xmlFree(all_ns); |
| 6311 |
|
| } |
| 6312 |
|
| } |
| 6313 |
|
| |
| 6314 |
24 |
▶ | if ( !ns ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !ns ) { |
5 |
19 |
24 |
|
| 6315 |
|
| /* create new ns */ |
| 6316 |
5 |
▶ | if ( prefix && xmlStrlen( prefix ) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( prefix && xmlStrlen( prefix ) ) { |
5 |
0 |
5 |
| if ( prefix && xmlStrlen( prefix ) ) { |
5 |
0 |
5 |
|
| 6317 |
5 |
| ns = xmlNewNs(self, nsURI , prefix); |
| 6318 |
|
| } |
| 6319 |
|
| else { |
| 6320 |
0 |
| ns = NULL; |
| 6321 |
|
| } |
| 6322 |
|
| } |
| 6323 |
|
| } |
| 6324 |
|
| |
| 6325 |
45 |
▶ | if ( nsURI && xmlStrlen(nsURI) && !ns ) { |
Branch: 3 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) && !ns ) { |
44 |
1 |
45 |
| if ( nsURI && xmlStrlen(nsURI) && !ns ) { |
24 |
20 |
44 |
| if ( nsURI && xmlStrlen(nsURI) && !ns ) { |
0 |
24 |
24 |
|
| 6326 |
0 |
▶ | if ( prefix ) xmlFree( prefix ); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix ) xmlFree( prefix ); |
0 |
0 |
0 |
|
| 6327 |
0 |
▶ | if ( nsURI ) xmlFree( nsURI ); |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) xmlFree( nsURI ); |
0 |
0 |
0 |
|
| 6328 |
0 |
| xmlFree( name ); |
| 6329 |
0 |
| xmlFree( value ); |
| 6330 |
0 |
| croak( "bad ns attribute!" ); |
| 6331 |
|
| } |
| 6332 |
|
| else { |
| 6333 |
|
| /* warn( "set attribute %s->%s", name, value ); */ |
| 6334 |
45 |
| xmlSetNsProp( self, ns, name, value ); |
| 6335 |
|
| } |
| 6336 |
|
| |
| 6337 |
45 |
▶ | if ( prefix ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( prefix ) { |
21 |
24 |
45 |
|
| 6338 |
21 |
| xmlFree( prefix ); |
| 6339 |
|
| } |
| 6340 |
45 |
▶ | if ( nsURI ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) { |
44 |
1 |
45 |
|
| 6341 |
44 |
| xmlFree( nsURI ); |
| 6342 |
|
| } |
| 6343 |
45 |
| xmlFree( name ); |
| 6344 |
45 |
| xmlFree( value ); |
| 6345 |
|
| |
| 6346 |
|
| void |
| 6347 |
|
| removeAttributeNS( self, namespaceURI, attr_name ) |
| 6348 |
|
| xmlNodePtr self |
| 6349 |
|
| SV * namespaceURI |
| 6350 |
|
| SV * attr_name |
| 6351 |
|
| PREINIT: |
| 6352 |
|
| xmlChar * nsURI; |
| 6353 |
3 |
| xmlChar * name = NULL; |
| 6354 |
3 |
| xmlAttrPtr xattr = NULL; |
| 6355 |
|
| CODE: |
| 6356 |
3 |
| nsURI = nodeSv2C( namespaceURI, self ); |
| 6357 |
3 |
| name = nodeSv2C( attr_name, self ); |
| 6358 |
3 |
▶ | if ( ! name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ! name ) { |
0 |
3 |
3 |
|
| 6359 |
0 |
| xmlFree(nsURI); |
| 6360 |
0 |
| XSRETURN_UNDEF; |
| 6361 |
|
| } |
| 6362 |
|
| |
| 6363 |
3 |
▶ | if ( nsURI && xmlStrlen(nsURI) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) ) { |
3 |
0 |
3 |
| if ( nsURI && xmlStrlen(nsURI) ) { |
2 |
1 |
3 |
|
| 6364 |
2 |
| xattr = xmlHasNsProp( self, name, nsURI ); |
| 6365 |
|
| } |
| 6366 |
|
| else { |
| 6367 |
1 |
| xattr = xmlHasNsProp( self, name, NULL ); |
| 6368 |
|
| } |
| 6369 |
3 |
▶ | if ( xattr && xattr->type == XML_ATTRIBUTE_NODE ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( xattr && xattr->type == XML_ATTRIBUTE_NODE ) { |
3 |
0 |
3 |
| if ( xattr && xattr->type == XML_ATTRIBUTE_NODE ) { |
3 |
0 |
3 |
|
| 6370 |
3 |
| xmlUnlinkNode((xmlNodePtr)xattr); |
| 6371 |
3 |
▶ | if ( xattr->_private ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xattr->_private ) { |
2 |
1 |
3 |
|
| 6372 |
2 |
| PmmFixOwner((ProxyNodePtr)xattr->_private, NULL); |
| 6373 |
|
| } |
| 6374 |
|
| else { |
| 6375 |
1 |
| xmlFreeProp(xattr); |
| 6376 |
|
| } |
| 6377 |
|
| } |
| 6378 |
3 |
| xmlFree(nsURI); |
| 6379 |
3 |
| xmlFree( name ); |
| 6380 |
|
| |
| 6381 |
|
| |
| 6382 |
|
| SV* |
| 6383 |
|
| getAttributeNodeNS( self,namespaceURI, attr_name ) |
| 6384 |
|
| xmlNodePtr self |
| 6385 |
|
| SV * namespaceURI |
| 6386 |
|
| SV * attr_name |
| 6387 |
|
| PREINIT: |
| 6388 |
|
| xmlChar * nsURI; |
| 6389 |
|
| xmlChar * name; |
| 6390 |
33 |
| xmlAttrPtr ret = NULL; |
| 6391 |
|
| CODE: |
| 6392 |
33 |
| nsURI = nodeSv2C(namespaceURI, self ); |
| 6393 |
33 |
| name = nodeSv2C(attr_name, self ); |
| 6394 |
33 |
▶ | if ( !name ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !name ) { |
0 |
33 |
33 |
|
| 6395 |
0 |
| xmlFree(nsURI); |
| 6396 |
0 |
| XSRETURN_UNDEF; |
| 6397 |
|
| } |
| 6398 |
33 |
▶ | if ( nsURI && xmlStrlen(nsURI) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen(nsURI) ) { |
20 |
13 |
33 |
| if ( nsURI && xmlStrlen(nsURI) ) { |
20 |
0 |
20 |
|
| 6399 |
20 |
| ret = xmlHasNsProp( self, name, nsURI ); |
| 6400 |
|
| } |
| 6401 |
|
| else { |
| 6402 |
13 |
| ret = xmlHasNsProp( self, name, NULL ); |
| 6403 |
|
| } |
| 6404 |
33 |
| xmlFree(name); |
| 6405 |
33 |
▶ | if ( nsURI ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI ) { |
20 |
13 |
33 |
|
| 6406 |
20 |
| xmlFree(nsURI); |
| 6407 |
|
| } |
| 6408 |
33 |
▶ | if ( ret && |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret && |
18 |
15 |
33 |
|
| 6409 |
18 |
▶ | ret->type == XML_ATTRIBUTE_NODE /* we don't want fixed attribute decls */ |
Branch: 1 branch
| Branch | True | False | Total |
| ret->type == XML_ATTRIBUTE_NODE /* we don't want fixed attribute decls */ |
12 |
6 |
18 |
|
| 6410 |
|
| ) { |
| 6411 |
12 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)ret, |
| 6412 |
12 |
▶ | PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
12 |
0 |
12 |
| PmmOWNERPO(PmmPROXYNODE(self)) ); |
12 |
0 |
12 |
|
| 6413 |
|
| } |
| 6414 |
|
| else { |
| 6415 |
|
| /* warn("no prop\n"); */ |
| 6416 |
21 |
| XSRETURN_UNDEF; |
| 6417 |
|
| } |
| 6418 |
|
| OUTPUT: |
| 6419 |
|
| RETVAL |
| 6420 |
|
| |
| 6421 |
|
| SV * |
| 6422 |
|
| setAttributeNodeNS( self, attr_node ) |
| 6423 |
|
| xmlNodePtr self |
| 6424 |
|
| SV * attr_node |
| 6425 |
|
| PREINIT: |
| 6426 |
4 |
| xmlAttrPtr attr = (xmlAttrPtr)PmmSvNode( attr_node ); |
| 6427 |
4 |
| xmlNsPtr ns = NULL; |
| 6428 |
4 |
| xmlAttrPtr ret = NULL; |
| 6429 |
|
| INIT: |
| 6430 |
4 |
▶ | if ( attr == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr == NULL ) { |
0 |
4 |
4 |
|
| 6431 |
0 |
| croak( "lost attribute node" ); |
| 6432 |
|
| } |
| 6433 |
|
| CODE: |
| 6434 |
4 |
▶ | if ( attr->type != XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->type != XML_ATTRIBUTE_NODE ) { |
0 |
4 |
4 |
|
| 6435 |
0 |
| XSRETURN_UNDEF; |
| 6436 |
|
| } |
| 6437 |
|
| |
| 6438 |
4 |
▶ | if ( attr->doc != self->doc ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->doc != self->doc ) { |
1 |
3 |
4 |
|
| 6439 |
1 |
| domImportNode( self->doc, (xmlNodePtr)attr, 1,1); |
| 6440 |
|
| } |
| 6441 |
|
| |
| 6442 |
|
| |
| 6443 |
4 |
| ns = attr->ns; |
| 6444 |
4 |
▶ | if ( ns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns != NULL ) { |
4 |
0 |
4 |
|
| 6445 |
4 |
| ret = xmlHasNsProp( self, ns->href, attr->name ); |
| 6446 |
|
| } |
| 6447 |
|
| else { |
| 6448 |
0 |
| ret = xmlHasNsProp( self, NULL, attr->name ); |
| 6449 |
|
| } |
| 6450 |
|
| |
| 6451 |
4 |
▶ | if ( ret && ret->type == XML_ATTRIBUTE_NODE ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ret && ret->type == XML_ATTRIBUTE_NODE ) { |
0 |
4 |
4 |
| if ( ret && ret->type == XML_ATTRIBUTE_NODE ) { |
0 |
0 |
0 |
|
| 6452 |
0 |
▶ | if ( ret != attr ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != attr ) { |
0 |
0 |
0 |
|
| 6453 |
0 |
| xmlReplaceNode( (xmlNodePtr)ret, (xmlNodePtr)attr ); |
| 6454 |
|
| } |
| 6455 |
|
| else { |
| 6456 |
0 |
| XSRETURN_UNDEF; |
| 6457 |
|
| } |
| 6458 |
|
| } |
| 6459 |
|
| else { |
| 6460 |
4 |
| xmlAddChild( self, (xmlNodePtr)attr ); |
| 6461 |
4 |
| xmlReconciliateNs(self->doc, self); |
| 6462 |
|
| } |
| 6463 |
4 |
▶ | if ( attr->_private != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->_private != NULL ) { |
4 |
0 |
4 |
|
| 6464 |
4 |
| PmmFixOwner( SvPROXYNODE(attr_node), PmmPROXYNODE(self) ); |
| 6465 |
|
| } |
| 6466 |
4 |
▶ | if ( ret != NULL && ret->type == XML_ATTRIBUTE_NODE ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( ret != NULL && ret->type == XML_ATTRIBUTE_NODE ) { |
0 |
4 |
4 |
| if ( ret != NULL && ret->type == XML_ATTRIBUTE_NODE ) { |
0 |
0 |
0 |
|
| 6467 |
0 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)ret, NULL ); |
| 6468 |
0 |
| PmmFixOwner( SvPROXYNODE(RETVAL), NULL ); |
| 6469 |
|
| } else { |
| 6470 |
4 |
| XSRETURN_UNDEF; |
| 6471 |
|
| } |
| 6472 |
|
| OUTPUT: |
| 6473 |
|
| RETVAL |
| 6474 |
|
| |
| 6475 |
|
| SV * |
| 6476 |
|
| removeAttributeNode( self, attr_node ) |
| 6477 |
|
| xmlNodePtr self |
| 6478 |
|
| SV * attr_node |
| 6479 |
|
| PREINIT: |
| 6480 |
3 |
| xmlAttrPtr attr = (xmlAttrPtr)PmmSvNode( attr_node ); |
| 6481 |
|
| xmlAttrPtr ret; |
| 6482 |
|
| INIT: |
| 6483 |
3 |
▶ | if ( attr == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr == NULL ) { |
0 |
3 |
3 |
|
| 6484 |
0 |
| croak( "lost attribute node" ); |
| 6485 |
|
| } |
| 6486 |
|
| CODE: |
| 6487 |
3 |
▶ | if ( attr->type != XML_ATTRIBUTE_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->type != XML_ATTRIBUTE_NODE ) { |
0 |
3 |
3 |
|
| 6488 |
0 |
| XSRETURN_UNDEF; |
| 6489 |
|
| } |
| 6490 |
3 |
▶ | if ( attr->parent != self ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr->parent != self ) { |
0 |
3 |
3 |
|
| 6491 |
0 |
| XSRETURN_UNDEF; |
| 6492 |
|
| } |
| 6493 |
3 |
| ret = attr; |
| 6494 |
3 |
| xmlUnlinkNode( (xmlNodePtr)attr ); |
| 6495 |
3 |
| RETVAL = PmmNodeToSv( (xmlNodePtr)ret, NULL ); |
| 6496 |
3 |
| PmmFixOwner( SvPROXYNODE(RETVAL), NULL ); |
| 6497 |
|
| OUTPUT: |
| 6498 |
|
| RETVAL |
| 6499 |
|
| |
| 6500 |
|
| void |
| 6501 |
|
| appendText( self, string ) |
| 6502 |
|
| xmlNodePtr self |
| 6503 |
|
| SV * string |
| 6504 |
|
| ALIAS: |
| 6505 |
|
| appendTextNode = 1 |
| 6506 |
|
| XML::LibXML::DocumentFragment::appendText = 2 |
| 6507 |
|
| XML::LibXML::DocumentFragment::appendTextNode = 3 |
| 6508 |
|
| PREINIT: |
| 6509 |
88 |
| xmlChar * content = NULL; |
| 6510 |
|
| INIT: |
| 6511 |
|
| PERL_UNUSED_VAR(ix); |
| 6512 |
88 |
| content = nodeSv2C( string, self ); |
| 6513 |
88 |
▶ | if ( content == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( content == NULL ) { |
0 |
88 |
88 |
|
| 6514 |
0 |
| XSRETURN_UNDEF; |
| 6515 |
|
| } |
| 6516 |
88 |
▶ | if ( xmlStrlen(content) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrlen(content) == 0 ) { |
0 |
88 |
88 |
|
| 6517 |
0 |
| xmlFree( content ); |
| 6518 |
0 |
| XSRETURN_UNDEF; |
| 6519 |
|
| } |
| 6520 |
|
| CODE: |
| 6521 |
88 |
| xmlNodeAddContent( self, content ); |
| 6522 |
88 |
| xmlFree(content); |
| 6523 |
|
| |
| 6524 |
|
| |
| 6525 |
|
| void |
| 6526 |
|
| appendTextChild( self, strname, strcontent=&PL_sv_undef, nsURI=&PL_sv_undef ) |
| 6527 |
|
| xmlNodePtr self |
| 6528 |
|
| SV * strname |
| 6529 |
|
| SV * strcontent |
| 6530 |
|
| SV * nsURI |
| 6531 |
|
| PREINIT: |
| 6532 |
|
| xmlChar * name; |
| 6533 |
3 |
| xmlChar * content = NULL; |
| 6534 |
3 |
| xmlChar * encstr = NULL; |
| 6535 |
|
| INIT: |
| 6536 |
3 |
| name = nodeSv2C( strname, self ); |
| 6537 |
3 |
▶ | if ( xmlStrlen(name) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlStrlen(name) == 0 ) { |
0 |
3 |
3 |
|
| 6538 |
0 |
| xmlFree(name); |
| 6539 |
0 |
| XSRETURN_UNDEF; |
| 6540 |
|
| } |
| 6541 |
|
| CODE: |
| 6542 |
3 |
| content = nodeSv2C(strcontent, self); |
| 6543 |
3 |
▶ | if ( content && xmlStrlen( content ) == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( content && xmlStrlen( content ) == 0 ) { |
2 |
1 |
3 |
| if ( content && xmlStrlen( content ) == 0 ) { |
0 |
2 |
2 |
|
| 6544 |
0 |
| xmlFree(content); |
| 6545 |
0 |
| content=NULL; |
| 6546 |
|
| } |
| 6547 |
3 |
▶ | else if ( content ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( content ) { |
2 |
1 |
3 |
|
| 6548 |
2 |
| encstr = xmlEncodeEntitiesReentrant( self->doc, content ); |
| 6549 |
2 |
| xmlFree(content); |
| 6550 |
|
| } |
| 6551 |
|
| |
| 6552 |
3 |
| xmlNewChild( self, NULL, name, encstr ); |
| 6553 |
|
| |
| 6554 |
3 |
▶ | if ( encstr ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( encstr ) |
2 |
1 |
3 |
|
| 6555 |
2 |
| xmlFree(encstr); |
| 6556 |
3 |
| xmlFree(name); |
| 6557 |
|
| |
| 6558 |
|
| SV * |
| 6559 |
|
| addNewChild( self, namespaceURI, nodename ) |
| 6560 |
|
| xmlNodePtr self |
| 6561 |
|
| SV * namespaceURI |
| 6562 |
|
| SV * nodename |
| 6563 |
|
| ALIAS: |
| 6564 |
|
| XML::LibXML::DocumentFragment::addNewChild = 1 |
| 6565 |
|
| PREINIT: |
| 6566 |
72 |
| xmlChar * nsURI = NULL; |
| 6567 |
72 |
| xmlChar * name = NULL; |
| 6568 |
72 |
| xmlChar * localname = NULL; |
| 6569 |
72 |
| xmlChar * prefix = NULL; |
| 6570 |
72 |
| xmlNodePtr newNode = NULL; |
| 6571 |
72 |
| xmlNodePtr prev = NULL; |
| 6572 |
72 |
| xmlNsPtr ns = NULL; |
| 6573 |
|
| CODE: |
| 6574 |
|
| PERL_UNUSED_VAR(ix); |
| 6575 |
72 |
| name = nodeSv2C(nodename, self); |
| 6576 |
72 |
▶ | if ( name && xmlStrlen( name ) == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( name && xmlStrlen( name ) == 0 ) { |
72 |
0 |
72 |
| if ( name && xmlStrlen( name ) == 0 ) { |
0 |
72 |
72 |
|
| 6577 |
0 |
| xmlFree(name); |
| 6578 |
0 |
| XSRETURN_UNDEF; |
| 6579 |
|
| } |
| 6580 |
|
| |
| 6581 |
72 |
| nsURI = nodeSv2C(namespaceURI, self); |
| 6582 |
72 |
▶ | if ( nsURI && xmlStrlen( nsURI ) == 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( nsURI && xmlStrlen( nsURI ) == 0 ) { |
72 |
0 |
72 |
| if ( nsURI && xmlStrlen( nsURI ) == 0 ) { |
50 |
22 |
72 |
|
| 6583 |
50 |
| xmlFree(nsURI); |
| 6584 |
50 |
| nsURI=NULL; |
| 6585 |
|
| } |
| 6586 |
|
| |
| 6587 |
72 |
▶ | if ( nsURI != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsURI != NULL ) { |
22 |
50 |
72 |
|
| 6588 |
22 |
| localname = xmlSplitQName2(name, &prefix); |
| 6589 |
22 |
| ns = xmlSearchNsByHref(self->doc, self, nsURI); |
| 6590 |
|
| |
| 6591 |
22 |
▶ | newNode = xmlNewDocNode(self->doc, |
Branch: 1 branch
| Branch | True | False | Total |
| newNode = xmlNewDocNode(self->doc, |
20 |
2 |
22 |
|
| 6592 |
|
| ns, |
| 6593 |
|
| localname?localname:name, |
| 6594 |
|
| NULL); |
| 6595 |
22 |
▶ | if ( ns == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == NULL ) { |
4 |
18 |
22 |
|
| 6596 |
4 |
| xmlSetNs(newNode,xmlNewNs(newNode, nsURI, prefix)); |
| 6597 |
|
| } |
| 6598 |
|
| |
| 6599 |
22 |
| xmlFree(localname); |
| 6600 |
22 |
| xmlFree(prefix); |
| 6601 |
22 |
| xmlFree(nsURI); |
| 6602 |
|
| } |
| 6603 |
|
| else { |
| 6604 |
50 |
| newNode = xmlNewDocNode(self->doc, |
| 6605 |
|
| NULL, |
| 6606 |
|
| name, |
| 6607 |
|
| NULL); |
| 6608 |
|
| } |
| 6609 |
72 |
| xmlFree(name); |
| 6610 |
|
| /* add the node to the parent node */ |
| 6611 |
72 |
| newNode->type = XML_ELEMENT_NODE; |
| 6612 |
72 |
| newNode->parent = self; |
| 6613 |
72 |
| newNode->doc = self->doc; |
| 6614 |
|
| |
| 6615 |
72 |
▶ | if (self->children == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->children == NULL) { |
31 |
41 |
72 |
|
| 6616 |
31 |
| self->children = newNode; |
| 6617 |
31 |
| self->last = newNode; |
| 6618 |
|
| } else { |
| 6619 |
41 |
| prev = self->last; |
| 6620 |
41 |
| prev->next = newNode; |
| 6621 |
41 |
| newNode->prev = prev; |
| 6622 |
41 |
| self->last = newNode; |
| 6623 |
|
| } |
| 6624 |
72 |
▶ | RETVAL = PmmNodeToSv(newNode, PmmOWNERPO(PmmPROXYNODE(self)) ); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = PmmNodeToSv(newNode, PmmOWNERPO(PmmPROXYNODE(self)) ); |
72 |
0 |
72 |
| RETVAL = PmmNodeToSv(newNode, PmmOWNERPO(PmmPROXYNODE(self)) ); |
40 |
32 |
72 |
|
| 6625 |
|
| OUTPUT: |
| 6626 |
|
| RETVAL |
| 6627 |
|
| |
| 6628 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Text |
| 6629 |
|
| |
| 6630 |
|
| SV * |
| 6631 |
|
| new( CLASS, content ) |
| 6632 |
|
| SV * content |
| 6633 |
|
| PREINIT: |
| 6634 |
|
| xmlChar * data; |
| 6635 |
|
| xmlNodePtr newNode; |
| 6636 |
18 |
| ProxyNodePtr docfrag = NULL; |
| 6637 |
|
| CODE: |
| 6638 |
18 |
| data = Sv2C(content, NULL); |
| 6639 |
18 |
| newNode = xmlNewText( data ); |
| 6640 |
18 |
| xmlFree(data); |
| 6641 |
18 |
▶ | if( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( newNode != NULL ) { |
18 |
0 |
18 |
|
| 6642 |
18 |
| docfrag = PmmNewFragment( NULL ); |
| 6643 |
18 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 6644 |
18 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 6645 |
|
| } |
| 6646 |
|
| else { |
| 6647 |
0 |
| XSRETURN_UNDEF; |
| 6648 |
|
| } |
| 6649 |
|
| OUTPUT: |
| 6650 |
|
| RETVAL |
| 6651 |
|
| |
| 6652 |
|
| SV * |
| 6653 |
|
| substringData( self, offset, length ) |
| 6654 |
|
| xmlNodePtr self |
| 6655 |
|
| int offset |
| 6656 |
|
| int length |
| 6657 |
|
| PREINIT: |
| 6658 |
4 |
| xmlChar * data = NULL; |
| 6659 |
4 |
| xmlChar * substr = NULL; |
| 6660 |
|
| CODE: |
| 6661 |
4 |
▶ | if ( offset >= 0 && length >= 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( offset >= 0 && length >= 0 ) { |
4 |
0 |
4 |
| if ( offset >= 0 && length >= 0 ) { |
4 |
0 |
4 |
|
| 6662 |
4 |
| data = domGetNodeValue( self ); |
| 6663 |
4 |
▶ | if ( data != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data != NULL ) { |
4 |
0 |
4 |
|
| 6664 |
4 |
| substr = xmlUTF8Strsub( data, offset, length ); |
| 6665 |
4 |
| RETVAL = C2Sv( (const xmlChar*)substr, NULL ); |
| 6666 |
4 |
| xmlFree( substr ); |
| 6667 |
|
| } |
| 6668 |
|
| else { |
| 6669 |
0 |
| XSRETURN_UNDEF; |
| 6670 |
|
| } |
| 6671 |
|
| } |
| 6672 |
|
| else { |
| 6673 |
0 |
| XSRETURN_UNDEF; |
| 6674 |
|
| } |
| 6675 |
|
| OUTPUT: |
| 6676 |
|
| RETVAL |
| 6677 |
|
| |
| 6678 |
|
| void |
| 6679 |
|
| setData( self, value ) |
| 6680 |
|
| xmlNodePtr self |
| 6681 |
|
| SV * value |
| 6682 |
|
| ALIAS: |
| 6683 |
|
| XML::LibXML::Attr::setValue = 1 |
| 6684 |
|
| XML::LibXML::PI::_setData = 2 |
| 6685 |
|
| PREINIT: |
| 6686 |
45 |
| xmlChar * encstr = NULL; |
| 6687 |
|
| CODE: |
| 6688 |
|
| PERL_UNUSED_VAR(ix); |
| 6689 |
45 |
| encstr = nodeSv2C(value,self); |
| 6690 |
45 |
| domSetNodeValue( self, encstr ); |
| 6691 |
45 |
| xmlFree(encstr); |
| 6692 |
|
| |
| 6693 |
|
| void |
| 6694 |
|
| appendData( self, value ) |
| 6695 |
|
| xmlNodePtr self |
| 6696 |
|
| SV * value |
| 6697 |
|
| PREINIT: |
| 6698 |
2 |
| xmlChar * encstring = NULL; |
| 6699 |
2 |
| int strlen = 0; |
| 6700 |
|
| CODE: |
| 6701 |
2 |
| encstring = Sv2C( value, |
| 6702 |
2 |
▶ | self->doc!=NULL ? self->doc->encoding : NULL ); |
Branch: 1 branch
| Branch | True | False | Total |
| self->doc!=NULL ? self->doc->encoding : NULL ); |
2 |
0 |
2 |
|
| 6703 |
|
| |
| 6704 |
2 |
▶ | if ( encstring != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( encstring != NULL ) { |
2 |
0 |
2 |
|
| 6705 |
2 |
| strlen = xmlStrlen( encstring ); |
| 6706 |
2 |
| xmlTextConcat( self, encstring, strlen ); |
| 6707 |
2 |
| xmlFree( encstring ); |
| 6708 |
|
| } |
| 6709 |
|
| |
| 6710 |
|
| void |
| 6711 |
|
| insertData( self, offset, value ) |
| 6712 |
|
| xmlNodePtr self |
| 6713 |
|
| int offset |
| 6714 |
|
| SV * value |
| 6715 |
|
| PREINIT: |
| 6716 |
5 |
| xmlChar * after= NULL; |
| 6717 |
5 |
| xmlChar * data = NULL; |
| 6718 |
5 |
| xmlChar * new = NULL; |
| 6719 |
5 |
| xmlChar * encstring = NULL; |
| 6720 |
5 |
| int dl = 0; |
| 6721 |
|
| CODE: |
| 6722 |
5 |
▶ | if ( offset >= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset >= 0 ) { |
5 |
0 |
5 |
|
| 6723 |
5 |
| encstring = Sv2C( value, |
| 6724 |
5 |
▶ | self->doc!=NULL ? self->doc->encoding : NULL ); |
Branch: 1 branch
| Branch | True | False | Total |
| self->doc!=NULL ? self->doc->encoding : NULL ); |
5 |
0 |
5 |
|
| 6725 |
5 |
▶ | if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
5 |
0 |
5 |
| if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
4 |
1 |
5 |
|
| 6726 |
4 |
| data = domGetNodeValue(self); |
| 6727 |
4 |
▶ | if ( data != NULL && xmlStrlen( data ) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( data != NULL && xmlStrlen( data ) > 0 ) { |
4 |
0 |
4 |
| if ( data != NULL && xmlStrlen( data ) > 0 ) { |
4 |
0 |
4 |
|
| 6728 |
4 |
▶ | if ( xmlUTF8Strlen( data ) < offset ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlUTF8Strlen( data ) < offset ) { |
0 |
4 |
4 |
|
| 6729 |
0 |
| data = xmlStrcat( data, encstring ); |
| 6730 |
0 |
| domSetNodeValue( self, data ); |
| 6731 |
|
| } |
| 6732 |
|
| else { |
| 6733 |
4 |
| dl = xmlUTF8Strlen( data ) - offset; |
| 6734 |
|
| |
| 6735 |
4 |
▶ | if ( offset > 0 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset > 0 ) |
4 |
0 |
4 |
|
| 6736 |
4 |
| new = xmlUTF8Strsub(data, 0, offset ); |
| 6737 |
|
| |
| 6738 |
4 |
| after = xmlUTF8Strsub(data, offset, dl ); |
| 6739 |
|
| |
| 6740 |
4 |
▶ | if ( new != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( new != NULL ) { |
4 |
0 |
4 |
|
| 6741 |
4 |
| new = xmlStrcat(new, encstring ); |
| 6742 |
|
| } |
| 6743 |
|
| else { |
| 6744 |
0 |
| new = xmlStrdup( encstring ); |
| 6745 |
|
| } |
| 6746 |
|
| |
| 6747 |
4 |
▶ | if ( after != NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( after != NULL ) |
4 |
0 |
4 |
|
| 6748 |
4 |
| new = xmlStrcat(new, after ); |
| 6749 |
|
| |
| 6750 |
4 |
| domSetNodeValue( self, new ); |
| 6751 |
|
| |
| 6752 |
4 |
| xmlFree( new ); |
| 6753 |
4 |
| xmlFree( after ); |
| 6754 |
|
| } |
| 6755 |
4 |
| xmlFree( data ); |
| 6756 |
|
| } |
| 6757 |
|
| else { |
| 6758 |
0 |
| domSetNodeValue( self, encstring ); |
| 6759 |
|
| } |
| 6760 |
4 |
| xmlFree(encstring); |
| 6761 |
|
| } |
| 6762 |
|
| } |
| 6763 |
|
| |
| 6764 |
|
| void |
| 6765 |
|
| deleteData( self, offset, length ) |
| 6766 |
|
| xmlNodePtr self |
| 6767 |
|
| int offset |
| 6768 |
|
| int length |
| 6769 |
|
| PREINIT: |
| 6770 |
9 |
| xmlChar * data = NULL; |
| 6771 |
9 |
| xmlChar * after = NULL; |
| 6772 |
9 |
| xmlChar * new = NULL; |
| 6773 |
9 |
| int len = 0; |
| 6774 |
9 |
| int dl1 = 0; |
| 6775 |
9 |
| int dl2 = 0; |
| 6776 |
|
| CODE: |
| 6777 |
9 |
▶ | if ( length > 0 && offset >= 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( length > 0 && offset >= 0 ) { |
7 |
2 |
9 |
| if ( length > 0 && offset >= 0 ) { |
7 |
0 |
7 |
|
| 6778 |
7 |
| data = domGetNodeValue(self); |
| 6779 |
7 |
| len = xmlUTF8Strlen( data ); |
| 6780 |
7 |
▶ | if ( data != NULL |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data != NULL |
7 |
0 |
7 |
|
| 6781 |
7 |
▶ | && len > 0 |
Branch: 1 branch
| Branch | True | False | Total |
| && len > 0 |
7 |
0 |
7 |
|
| 6782 |
7 |
▶ | && len > offset ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && len > offset ) { |
5 |
2 |
7 |
|
| 6783 |
5 |
| dl1 = offset + length; |
| 6784 |
5 |
▶ | if ( offset > 0 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset > 0 ) |
4 |
1 |
5 |
|
| 6785 |
4 |
| new = xmlUTF8Strsub( data, 0, offset ); |
| 6786 |
|
| |
| 6787 |
5 |
▶ | if ( len > dl1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( len > dl1 ) { |
3 |
2 |
5 |
|
| 6788 |
3 |
| dl2 = len - dl1; |
| 6789 |
3 |
| after = xmlUTF8Strsub( data, dl1, dl2 ); |
| 6790 |
3 |
▶ | if ( new != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( new != NULL ) { |
2 |
1 |
3 |
|
| 6791 |
2 |
| new = xmlStrcat( new, after ); |
| 6792 |
2 |
| xmlFree(after); |
| 6793 |
|
| } |
| 6794 |
|
| else { |
| 6795 |
1 |
| new = after; |
| 6796 |
|
| } |
| 6797 |
|
| } |
| 6798 |
|
| |
| 6799 |
5 |
| domSetNodeValue( self, new ); |
| 6800 |
5 |
| xmlFree(new); |
| 6801 |
|
| } |
| 6802 |
|
| } |
| 6803 |
|
| |
| 6804 |
|
| void |
| 6805 |
|
| replaceData( self, offset,length, value ) |
| 6806 |
|
| xmlNodePtr self |
| 6807 |
|
| int offset |
| 6808 |
|
| int length |
| 6809 |
|
| SV * value |
| 6810 |
|
| PREINIT: |
| 6811 |
6 |
| xmlChar * after= NULL; |
| 6812 |
6 |
| xmlChar * data = NULL; |
| 6813 |
6 |
| xmlChar * new = NULL; |
| 6814 |
6 |
| xmlChar * encstring = NULL; |
| 6815 |
6 |
| int len = 0; |
| 6816 |
6 |
| int dl1 = 0; |
| 6817 |
6 |
| int dl2 = 0; |
| 6818 |
|
| CODE: |
| 6819 |
6 |
▶ | if ( offset >= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset >= 0 ) { |
6 |
0 |
6 |
|
| 6820 |
6 |
| encstring = Sv2C( value, |
| 6821 |
6 |
▶ | self->doc!=NULL ? self->doc->encoding : NULL ); |
Branch: 1 branch
| Branch | True | False | Total |
| self->doc!=NULL ? self->doc->encoding : NULL ); |
6 |
0 |
6 |
|
| 6822 |
|
| |
| 6823 |
6 |
▶ | if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
6 |
0 |
6 |
| if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) { |
6 |
0 |
6 |
|
| 6824 |
6 |
| data = domGetNodeValue(self); |
| 6825 |
6 |
| len = xmlUTF8Strlen( data ); |
| 6826 |
|
| |
| 6827 |
6 |
▶ | if ( data != NULL |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data != NULL |
6 |
0 |
6 |
|
| 6828 |
6 |
▶ | && len > 0 |
Branch: 1 branch
| Branch | True | False | Total |
| && len > 0 |
6 |
0 |
6 |
|
| 6829 |
6 |
▶ | && len > offset ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && len > offset ) { |
6 |
0 |
6 |
|
| 6830 |
|
| |
| 6831 |
6 |
| dl1 = offset + length; |
| 6832 |
6 |
▶ | if ( dl1 < len ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dl1 < len ) { |
4 |
2 |
6 |
|
| 6833 |
4 |
| dl2 = xmlUTF8Strlen( data ) - dl1; |
| 6834 |
4 |
▶ | if ( offset > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset > 0 ) { |
4 |
0 |
4 |
|
| 6835 |
4 |
| new = xmlUTF8Strsub(data, 0, offset ); |
| 6836 |
4 |
| new = xmlStrcat(new, encstring ); |
| 6837 |
|
| } |
| 6838 |
|
| else { |
| 6839 |
0 |
| new = xmlStrdup( encstring ); |
| 6840 |
|
| } |
| 6841 |
|
| |
| 6842 |
4 |
| after = xmlUTF8Strsub(data, dl1, dl2 ); |
| 6843 |
4 |
| new = xmlStrcat(new, after ); |
| 6844 |
|
| |
| 6845 |
4 |
| domSetNodeValue( self, new ); |
| 6846 |
|
| |
| 6847 |
4 |
| xmlFree( new ); |
| 6848 |
4 |
| xmlFree( after ); |
| 6849 |
|
| } |
| 6850 |
|
| else { |
| 6851 |
|
| /* replace until end! */ |
| 6852 |
2 |
▶ | if ( offset > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( offset > 0 ) { |
2 |
0 |
2 |
|
| 6853 |
2 |
| new = xmlUTF8Strsub(data, 0, offset ); |
| 6854 |
2 |
| new = xmlStrcat(new, encstring ); |
| 6855 |
|
| } |
| 6856 |
|
| else { |
| 6857 |
0 |
| new = xmlStrdup( encstring ); |
| 6858 |
|
| } |
| 6859 |
2 |
| domSetNodeValue( self, new ); |
| 6860 |
2 |
| xmlFree( new ); |
| 6861 |
|
| } |
| 6862 |
6 |
| xmlFree( data ); |
| 6863 |
|
| } |
| 6864 |
|
| |
| 6865 |
6 |
| xmlFree(encstring); |
| 6866 |
|
| } |
| 6867 |
|
| } |
| 6868 |
|
| |
| 6869 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Comment |
| 6870 |
|
| |
| 6871 |
|
| SV * |
| 6872 |
|
| new( CLASS, content ) |
| 6873 |
|
| SV * content |
| 6874 |
|
| PREINIT: |
| 6875 |
|
| xmlChar * encstring; |
| 6876 |
|
| xmlNodePtr newNode; |
| 6877 |
7 |
| ProxyNodePtr docfrag = NULL; |
| 6878 |
|
| CODE: |
| 6879 |
7 |
| encstring = Sv2C(content, NULL); |
| 6880 |
7 |
| newNode = xmlNewComment( encstring ); |
| 6881 |
7 |
| xmlFree(encstring); |
| 6882 |
7 |
▶ | if( newNode != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if( newNode != NULL ) { |
7 |
0 |
7 |
|
| 6883 |
7 |
| docfrag = PmmNewFragment( NULL ); |
| 6884 |
7 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 6885 |
7 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 6886 |
|
| } |
| 6887 |
|
| else { |
| 6888 |
0 |
| XSRETURN_UNDEF; |
| 6889 |
|
| } |
| 6890 |
|
| OUTPUT: |
| 6891 |
|
| RETVAL |
| 6892 |
|
| |
| 6893 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::CDATASection |
| 6894 |
|
| |
| 6895 |
|
| SV * |
| 6896 |
|
| new( CLASS , content ) |
| 6897 |
|
| SV * content |
| 6898 |
|
| PREINIT: |
| 6899 |
|
| xmlChar * encstring; |
| 6900 |
|
| xmlNodePtr newNode; |
| 6901 |
7 |
| ProxyNodePtr docfrag = NULL; |
| 6902 |
|
| CODE: |
| 6903 |
7 |
| encstring = Sv2C(content, NULL); |
| 6904 |
7 |
| newNode = xmlNewCDataBlock( NULL , encstring, xmlStrlen( encstring ) ); |
| 6905 |
7 |
| xmlFree(encstring); |
| 6906 |
7 |
▶ | if ( newNode != NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newNode != NULL ){ |
7 |
0 |
7 |
|
| 6907 |
7 |
| docfrag = PmmNewFragment( NULL ); |
| 6908 |
7 |
| xmlAddChild(PmmNODE(docfrag), newNode); |
| 6909 |
7 |
| RETVAL = PmmNodeToSv(newNode,docfrag); |
| 6910 |
|
| } |
| 6911 |
|
| else { |
| 6912 |
0 |
| XSRETURN_UNDEF; |
| 6913 |
|
| } |
| 6914 |
|
| OUTPUT: |
| 6915 |
|
| RETVAL |
| 6916 |
|
| |
| 6917 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::DocumentFragment |
| 6918 |
|
| |
| 6919 |
|
| SV* |
| 6920 |
|
| new( CLASS ) |
| 6921 |
|
| PREINIT: |
| 6922 |
29 |
| xmlNodePtr real_doc=NULL; |
| 6923 |
|
| CODE: |
| 6924 |
29 |
| real_doc = xmlNewDocFragment( NULL ); |
| 6925 |
29 |
| RETVAL = PmmNodeToSv( real_doc, NULL ); |
| 6926 |
|
| OUTPUT: |
| 6927 |
|
| RETVAL |
| 6928 |
|
| |
| 6929 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Attr |
| 6930 |
|
| |
| 6931 |
|
| SV* |
| 6932 |
|
| new( CLASS, pname, pvalue ) |
| 6933 |
|
| SV * pname |
| 6934 |
|
| SV * pvalue |
| 6935 |
|
| PREINIT: |
| 6936 |
0 |
| xmlNodePtr attr = NULL; |
| 6937 |
|
| xmlChar * name; |
| 6938 |
|
| xmlChar * value; |
| 6939 |
|
| CODE: |
| 6940 |
0 |
| name = Sv2C(pname,NULL); |
| 6941 |
0 |
| value = Sv2C(pvalue,NULL); |
| 6942 |
0 |
▶ | if ( name == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( name == NULL ) { |
0 |
0 |
0 |
|
| 6943 |
0 |
| XSRETURN_UNDEF; |
| 6944 |
|
| } |
| 6945 |
0 |
| attr = (xmlNodePtr)xmlNewProp( NULL, name, value ); |
| 6946 |
0 |
| attr->doc = NULL; |
| 6947 |
0 |
| RETVAL = PmmNodeToSv(attr,NULL); |
| 6948 |
|
| OUTPUT: |
| 6949 |
|
| RETVAL |
| 6950 |
|
| |
| 6951 |
|
| |
| 6952 |
|
| SV* |
| 6953 |
|
| parentElement( self ) |
| 6954 |
|
| ALIAS: |
| 6955 |
|
| XML::LibXML::Attr::getParentNode = 1 |
| 6956 |
|
| XML::LibXML::Attr::getNextSibling = 2 |
| 6957 |
|
| XML::LibXML::Attr::getPreviousSibling = 3 |
| 6958 |
|
| XML::LibXML::Attr::nextSibling = 4 |
| 6959 |
|
| XML::LibXML::Attr::previousSibling = 5 |
| 6960 |
|
| CODE: |
| 6961 |
|
| /* override the original parentElement(), since this an attribute is |
| 6962 |
|
| * not part of the main tree |
| 6963 |
|
| */ |
| 6964 |
|
| |
| 6965 |
|
| PERL_UNUSED_VAR(ix); |
| 6966 |
0 |
| XSRETURN_UNDEF; |
| 6967 |
|
| OUTPUT: |
| 6968 |
|
| RETVAL |
| 6969 |
|
| |
| 6970 |
|
| SV* |
| 6971 |
|
| serializeContent( self, useDomEncoding = &PL_sv_undef ) |
| 6972 |
|
| SV * self |
| 6973 |
|
| SV * useDomEncoding |
| 6974 |
|
| PREINIT: |
| 6975 |
|
| xmlBufferPtr buffer; |
| 6976 |
4 |
| const xmlChar *ret = NULL; |
| 6977 |
4 |
| xmlAttrPtr node = (xmlAttrPtr)PmmSvNode(self); |
| 6978 |
|
| CODE: |
| 6979 |
4 |
| buffer = xmlBufferCreate(); |
| 6980 |
4 |
| domAttrSerializeContent(buffer, node); |
| 6981 |
4 |
▶ | if ( xmlBufferLength(buffer) > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlBufferLength(buffer) > 0 ) { |
4 |
0 |
4 |
|
| 6982 |
4 |
| ret = xmlBufferContent( buffer ); |
| 6983 |
|
| } |
| 6984 |
4 |
▶ | if ( ret != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != NULL ) { |
4 |
0 |
4 |
|
| 6985 |
4 |
▶ | if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
0 |
4 |
4 |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
0 |
0 |
0 |
|
| 6986 |
0 |
| RETVAL = nodeC2Sv((xmlChar*)ret, PmmNODE(PmmPROXYNODE(node))) ; |
| 6987 |
|
| } |
| 6988 |
|
| else { |
| 6989 |
4 |
| RETVAL = C2Sv((xmlChar*)ret, NULL) ; |
| 6990 |
|
| } |
| 6991 |
4 |
| xmlBufferFree( buffer ); |
| 6992 |
|
| } |
| 6993 |
|
| else { |
| 6994 |
0 |
| xmlBufferFree( buffer ); |
| 6995 |
|
| xs_warn("Failed to convert attribute to string"); |
| 6996 |
0 |
| XSRETURN_UNDEF; |
| 6997 |
|
| } |
| 6998 |
|
| OUTPUT: |
| 6999 |
|
| RETVAL |
| 7000 |
|
| |
| 7001 |
|
| SV* |
| 7002 |
|
| toString(self , format=0, useDomEncoding = &PL_sv_undef ) |
| 7003 |
|
| SV * self |
| 7004 |
|
| SV * useDomEncoding |
| 7005 |
|
| int format |
| 7006 |
|
| ALIAS: |
| 7007 |
|
| XML::LibXML::Attr::serialize = 1 |
| 7008 |
|
| PREINIT: |
| 7009 |
10 |
| xmlAttrPtr node = (xmlAttrPtr)PmmSvNode(self); |
| 7010 |
|
| xmlBufferPtr buffer; |
| 7011 |
10 |
▶ | const xmlChar *ret = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const xmlChar *ret = NULL; |
10 |
0 |
10 |
|
| 7012 |
|
| CODE: |
| 7013 |
|
| /* we add an extra method for serializing attributes since |
| 7014 |
|
| XML::LibXML::Node::toString causes segmentation fault inside |
| 7015 |
|
| libxml2 |
| 7016 |
|
| */ |
| 7017 |
|
| PERL_UNUSED_VAR(ix); |
| 7018 |
10 |
| buffer = xmlBufferCreate(); |
| 7019 |
10 |
| xmlBufferAdd(buffer, BAD_CAST " ", 1); |
| 7020 |
10 |
▶ | if ((node->ns != NULL) && (node->ns->prefix != NULL)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ((node->ns != NULL) && (node->ns->prefix != NULL)) { |
2 |
8 |
10 |
| if ((node->ns != NULL) && (node->ns->prefix != NULL)) { |
2 |
0 |
2 |
|
| 7021 |
2 |
| xmlBufferAdd(buffer, node->ns->prefix, xmlStrlen(node->ns->prefix)); |
| 7022 |
2 |
| xmlBufferAdd(buffer, BAD_CAST ":", 1); |
| 7023 |
|
| } |
| 7024 |
10 |
| xmlBufferAdd(buffer, node->name, xmlStrlen(node->name)); |
| 7025 |
10 |
| xmlBufferAdd(buffer, BAD_CAST "=\"", 2); |
| 7026 |
10 |
| domAttrSerializeContent(buffer, node); |
| 7027 |
10 |
| xmlBufferAdd(buffer, BAD_CAST "\"", 1); |
| 7028 |
|
| |
| 7029 |
10 |
▶ | if ( xmlBufferLength(buffer) > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlBufferLength(buffer) > 0 ) { |
10 |
0 |
10 |
|
| 7030 |
10 |
| ret = xmlBufferContent( buffer ); |
| 7031 |
|
| } |
| 7032 |
10 |
▶ | if ( ret != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ret != NULL ) { |
10 |
0 |
10 |
|
| 7033 |
10 |
▶ | if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
0 |
10 |
10 |
| if ( useDomEncoding != &PL_sv_undef && SvTRUE(useDomEncoding) ) { |
0 |
0 |
0 |
|
| 7034 |
0 |
| RETVAL = nodeC2Sv((xmlChar*)ret, PmmNODE(PmmPROXYNODE(node))) ; |
| 7035 |
|
| } |
| 7036 |
|
| else { |
| 7037 |
10 |
| RETVAL = C2Sv((xmlChar*)ret, NULL) ; |
| 7038 |
|
| } |
| 7039 |
10 |
| xmlBufferFree( buffer ); |
| 7040 |
|
| } |
| 7041 |
|
| else { |
| 7042 |
0 |
| xmlBufferFree( buffer ); |
| 7043 |
|
| xs_warn("Failed to convert attribute to string"); |
| 7044 |
0 |
| XSRETURN_UNDEF; |
| 7045 |
|
| } |
| 7046 |
|
| OUTPUT: |
| 7047 |
|
| RETVAL |
| 7048 |
|
| |
| 7049 |
|
| |
| 7050 |
|
| int |
| 7051 |
|
| _setNamespace(self, namespaceURI, namespacePrefix = &PL_sv_undef ) |
| 7052 |
|
| SV * self |
| 7053 |
|
| SV * namespaceURI |
| 7054 |
|
| SV * namespacePrefix |
| 7055 |
|
| PREINIT: |
| 7056 |
2 |
| xmlAttrPtr node = (xmlAttrPtr)PmmSvNode(self); |
| 7057 |
2 |
| xmlChar * nsURI = nodeSv2C(namespaceURI,(xmlNodePtr)node); |
| 7058 |
2 |
| xmlChar * nsPrefix = NULL; |
| 7059 |
2 |
▶ | xmlNsPtr ns = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNsPtr ns = NULL; |
2 |
0 |
2 |
|
| 7060 |
|
| INIT: |
| 7061 |
2 |
▶ | if ( node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node == NULL ) { |
0 |
2 |
2 |
|
| 7062 |
0 |
| croak( "lost node" ); |
| 7063 |
|
| } |
| 7064 |
|
| CODE: |
| 7065 |
2 |
▶ | if ( !nsURI || xmlStrlen(nsURI)==0 ){ |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !nsURI || xmlStrlen(nsURI)==0 ){ |
2 |
0 |
2 |
| if ( !nsURI || xmlStrlen(nsURI)==0 ){ |
1 |
1 |
2 |
|
| 7066 |
1 |
| xmlSetNs((xmlNodePtr)node, NULL); |
| 7067 |
1 |
| RETVAL = 1; |
| 7068 |
|
| } |
| 7069 |
2 |
▶ | if ( !node->parent ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !node->parent ) { |
0 |
2 |
2 |
|
| 7070 |
0 |
| XSRETURN_UNDEF; |
| 7071 |
|
| } |
| 7072 |
2 |
| nsPrefix = nodeSv2C(namespacePrefix, (xmlNodePtr)node); |
| 7073 |
3 |
| if ( (ns = xmlSearchNs(node->doc, node->parent, nsPrefix)) && |
| 7074 |
1 |
| xmlStrEqual( ns->href, nsURI) ) { |
| 7075 |
|
| /* same uri and prefix */ |
| 7076 |
1 |
| RETVAL = 1; |
| 7077 |
|
| } |
| 7078 |
1 |
▶ | else if ( (ns = xmlSearchNsByHref(node->doc, node->parent, nsURI)) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( (ns = xmlSearchNsByHref(node->doc, node->parent, nsURI)) ) { |
0 |
1 |
1 |
|
| 7079 |
|
| /* set uri, but with a different prefix */ |
| 7080 |
0 |
| RETVAL = 1; |
| 7081 |
|
| } |
| 7082 |
1 |
▶ | else if (! RETVAL) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (! RETVAL) |
0 |
1 |
1 |
|
| 7083 |
0 |
| RETVAL = 0; |
| 7084 |
|
| |
| 7085 |
2 |
▶ | if ( ns ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns ) { |
1 |
1 |
2 |
|
| 7086 |
1 |
▶ | if ( ns->prefix ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns->prefix ) { |
1 |
0 |
1 |
|
| 7087 |
1 |
| xmlSetNs((xmlNodePtr)node, ns); |
| 7088 |
|
| } else { |
| 7089 |
0 |
| RETVAL = 0; |
| 7090 |
|
| } |
| 7091 |
|
| } |
| 7092 |
2 |
| xmlFree(nsPrefix); |
| 7093 |
2 |
| xmlFree(nsURI); |
| 7094 |
|
| OUTPUT: |
| 7095 |
|
| RETVAL |
| 7096 |
|
| |
| 7097 |
|
| int |
| 7098 |
|
| isId( self ) |
| 7099 |
|
| SV * self |
| 7100 |
|
| PREINIT: |
| 7101 |
10 |
| xmlAttrPtr attr = (xmlAttrPtr)PmmSvNode(self); |
| 7102 |
|
| xmlNodePtr elem; |
| 7103 |
|
| CODE: |
| 7104 |
10 |
▶ | if ( attr == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( attr == NULL ) { |
0 |
10 |
10 |
|
| 7105 |
0 |
| XSRETURN_UNDEF; |
| 7106 |
|
| } |
| 7107 |
10 |
| elem = attr->parent; |
| 7108 |
10 |
▶ | if ( elem == NULL || elem->doc == NULL ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( elem == NULL || elem->doc == NULL ) { |
10 |
0 |
10 |
| if ( elem == NULL || elem->doc == NULL ) { |
0 |
10 |
10 |
|
| 7109 |
0 |
| XSRETURN_UNDEF; |
| 7110 |
|
| } |
| 7111 |
10 |
| RETVAL = xmlIsID( elem->doc, elem, attr ); |
| 7112 |
|
| OUTPUT: |
| 7113 |
|
| RETVAL |
| 7114 |
|
| |
| 7115 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Namespace |
| 7116 |
|
| |
| 7117 |
|
| SV* |
| 7118 |
|
| new(CLASS, namespaceURI, namespacePrefix=&PL_sv_undef) |
| 7119 |
|
| const char * CLASS |
| 7120 |
|
| SV * namespaceURI |
| 7121 |
|
| SV * namespacePrefix |
| 7122 |
|
| PREINIT: |
| 7123 |
14 |
▶ | xmlNsPtr ns = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNsPtr ns = NULL; |
5 |
9 |
14 |
|
| 7124 |
|
| xmlChar* nsURI; |
| 7125 |
|
| xmlChar* nsPrefix; |
| 7126 |
|
| CODE: |
| 7127 |
14 |
| RETVAL = &PL_sv_undef; |
| 7128 |
|
| |
| 7129 |
14 |
| nsURI = Sv2C(namespaceURI,NULL); |
| 7130 |
14 |
▶ | if ( !nsURI ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !nsURI ) { |
0 |
14 |
14 |
|
| 7131 |
0 |
| XSRETURN_UNDEF; |
| 7132 |
|
| } |
| 7133 |
14 |
| nsPrefix = Sv2C(namespacePrefix, NULL); |
| 7134 |
14 |
| ns = xmlNewNs(NULL, nsURI, nsPrefix); |
| 7135 |
14 |
▶ | if ( ns ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns ) { |
14 |
0 |
14 |
|
| 7136 |
14 |
| RETVAL = NEWSV(0,0); |
| 7137 |
14 |
| RETVAL = sv_setref_pv( RETVAL, |
| 7138 |
|
| CLASS, |
| 7139 |
|
| (void*)ns); |
| 7140 |
|
| } |
| 7141 |
14 |
| xmlFree(nsURI); |
| 7142 |
14 |
▶ | if ( nsPrefix ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nsPrefix ) |
9 |
5 |
14 |
|
| 7143 |
9 |
| xmlFree(nsPrefix); |
| 7144 |
|
| OUTPUT: |
| 7145 |
|
| RETVAL |
| 7146 |
|
| |
| 7147 |
|
| void |
| 7148 |
|
| DESTROY(self) |
| 7149 |
|
| SV * self |
| 7150 |
|
| PREINIT: |
| 7151 |
37 |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
| 7152 |
|
| CODE: |
| 7153 |
|
| xs_warn( "DESTROY NS" ); |
| 7154 |
37 |
▶ | if (ns) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ns) { |
37 |
0 |
37 |
|
| 7155 |
37 |
| xmlFreeNs(ns); |
| 7156 |
|
| } |
| 7157 |
|
| |
| 7158 |
|
| int |
| 7159 |
|
| nodeType(self) |
| 7160 |
|
| SV * self |
| 7161 |
|
| ALIAS: |
| 7162 |
|
| getType = 1 |
| 7163 |
|
| PREINIT: |
| 7164 |
3 |
▶ | xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
3 |
0 |
3 |
|
| 7165 |
|
| CODE: |
| 7166 |
|
| PERL_UNUSED_VAR(ix); |
| 7167 |
3 |
▶ | RETVAL = ns->type; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ns->type; |
0 |
3 |
3 |
|
| 7168 |
|
| OUTPUT: |
| 7169 |
|
| RETVAL |
| 7170 |
|
| |
| 7171 |
|
| SV* |
| 7172 |
|
| declaredURI(self) |
| 7173 |
|
| SV * self |
| 7174 |
|
| ALIAS: |
| 7175 |
|
| value = 1 |
| 7176 |
|
| nodeValue = 2 |
| 7177 |
|
| getData = 3 |
| 7178 |
|
| getValue = 4 |
| 7179 |
|
| value2 = 5 |
| 7180 |
|
| href = 6 |
| 7181 |
|
| PREINIT: |
| 7182 |
12 |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
| 7183 |
|
| xmlChar * href; |
| 7184 |
|
| CODE: |
| 7185 |
|
| PERL_UNUSED_VAR(ix); |
| 7186 |
12 |
| href = xmlStrdup(ns->href); |
| 7187 |
12 |
| RETVAL = C2Sv(href, NULL); |
| 7188 |
12 |
| xmlFree(href); |
| 7189 |
|
| OUTPUT: |
| 7190 |
|
| RETVAL |
| 7191 |
|
| |
| 7192 |
|
| SV* |
| 7193 |
|
| declaredPrefix(self) |
| 7194 |
|
| SV * self |
| 7195 |
|
| ALIAS: |
| 7196 |
|
| localname = 1 |
| 7197 |
|
| getLocalName = 2 |
| 7198 |
|
| PREINIT: |
| 7199 |
20 |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
| 7200 |
|
| xmlChar * prefix; |
| 7201 |
|
| CODE: |
| 7202 |
|
| PERL_UNUSED_VAR(ix); |
| 7203 |
20 |
| prefix = xmlStrdup(ns->prefix); |
| 7204 |
20 |
| RETVAL = C2Sv(prefix, NULL); |
| 7205 |
20 |
| xmlFree(prefix); |
| 7206 |
|
| OUTPUT: |
| 7207 |
|
| RETVAL |
| 7208 |
|
| |
| 7209 |
|
| SV* |
| 7210 |
|
| unique_key( self ) |
| 7211 |
|
| SV * self |
| 7212 |
|
| PREINIT: |
| 7213 |
10 |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
| 7214 |
|
| xmlChar* key; |
| 7215 |
|
| CODE: |
| 7216 |
|
| /* Concatenate prefix and URI with vertical bar dividing*/ |
| 7217 |
10 |
| key = xmlStrdup(ns->prefix); |
| 7218 |
10 |
| key = xmlStrcat(key, (const xmlChar*)"|"); |
| 7219 |
10 |
| key = xmlStrcat(key, ns->href); |
| 7220 |
10 |
| RETVAL = C2Sv(key, NULL); |
| 7221 |
|
| OUTPUT: |
| 7222 |
|
| RETVAL |
| 7223 |
|
| |
| 7224 |
|
| int |
| 7225 |
|
| _isEqual(self, ref_node) |
| 7226 |
|
| SV * self |
| 7227 |
|
| SV * ref_node |
| 7228 |
|
| PREINIT: |
| 7229 |
0 |
| xmlNsPtr ns = INT2PTR(xmlNsPtr,SvIV(SvRV(self))); |
| 7230 |
0 |
▶ | xmlNsPtr ons = INT2PTR(xmlNsPtr,SvIV(SvRV(ref_node))); |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNsPtr ons = INT2PTR(xmlNsPtr,SvIV(SvRV(ref_node))); |
0 |
0 |
0 |
|
| 7231 |
|
| CODE: |
| 7232 |
0 |
| RETVAL = 0; |
| 7233 |
0 |
▶ | if ( ns == ons ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ns == ons ) { |
0 |
0 |
0 |
|
| 7234 |
0 |
| RETVAL = 1; |
| 7235 |
|
| } |
| 7236 |
0 |
▶ | else if ( xmlStrEqual(ns->href, ons->href) |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( xmlStrEqual(ns->href, ons->href) |
0 |
0 |
0 |
|
| 7237 |
0 |
▶ | && xmlStrEqual(ns->prefix, ons->prefix) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| && xmlStrEqual(ns->prefix, ons->prefix) ) { |
0 |
0 |
0 |
|
| 7238 |
0 |
| RETVAL = 1; |
| 7239 |
|
| } |
| 7240 |
|
| OUTPUT: |
| 7241 |
|
| RETVAL |
| 7242 |
|
| |
| 7243 |
|
| |
| 7244 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Dtd |
| 7245 |
|
| |
| 7246 |
|
| SV * |
| 7247 |
|
| new(CLASS, external, system) |
| 7248 |
|
| char * external |
| 7249 |
|
| char * system |
| 7250 |
|
| ALIAS: |
| 7251 |
|
| parse_uri = 1 |
| 7252 |
|
| PREINIT: |
| 7253 |
4 |
| xmlDtdPtr dtd = NULL; |
| 7254 |
4 |
| PREINIT_SAVED_ERROR |
| 7255 |
|
| CODE: |
| 7256 |
|
| PERL_UNUSED_VAR(ix); |
| 7257 |
4 |
| INIT_ERROR_HANDLER; |
| 7258 |
4 |
| dtd = xmlParseDTD((const xmlChar*)external, (const xmlChar*)system); |
| 7259 |
4 |
▶ | if ( dtd == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( dtd == NULL ) { |
2 |
2 |
4 |
|
| 7260 |
2 |
| CLEANUP_ERROR_HANDLER; |
| 7261 |
2 |
| REPORT_ERROR(0); |
| 7262 |
1 |
| XSRETURN_UNDEF; |
| 7263 |
|
| } else { |
| 7264 |
2 |
| xmlSetTreeDoc((xmlNodePtr)dtd, NULL); |
| 7265 |
2 |
| RETVAL = PmmNodeToSv( (xmlNodePtr) dtd, NULL ); |
| 7266 |
2 |
| CLEANUP_ERROR_HANDLER; |
| 7267 |
2 |
| REPORT_ERROR(0); |
| 7268 |
|
| } |
| 7269 |
|
| OUTPUT: |
| 7270 |
|
| RETVAL |
| 7271 |
|
| |
| 7272 |
|
| SV* |
| 7273 |
|
| systemId( self ) |
| 7274 |
|
| xmlDtdPtr self |
| 7275 |
|
| ALIAS: |
| 7276 |
|
| getSystemId = 1 |
| 7277 |
|
| CODE: |
| 7278 |
|
| PERL_UNUSED_VAR(ix); |
| 7279 |
3 |
▶ | if ( self->SystemID == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->SystemID == NULL ) { |
1 |
2 |
3 |
|
| 7280 |
1 |
| XSRETURN_UNDEF; |
| 7281 |
|
| } else { |
| 7282 |
2 |
| RETVAL = C2Sv(self->SystemID,NULL); |
| 7283 |
|
| } |
| 7284 |
|
| OUTPUT: |
| 7285 |
|
| RETVAL |
| 7286 |
|
| |
| 7287 |
|
| SV* |
| 7288 |
|
| publicId( self ) |
| 7289 |
|
| xmlDtdPtr self |
| 7290 |
|
| ALIAS: |
| 7291 |
|
| getPublicId = 1 |
| 7292 |
|
| CODE: |
| 7293 |
|
| PERL_UNUSED_VAR(ix); |
| 7294 |
3 |
▶ | if ( self->ExternalID == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( self->ExternalID == NULL ) { |
1 |
2 |
3 |
|
| 7295 |
1 |
| XSRETURN_UNDEF; |
| 7296 |
|
| } else { |
| 7297 |
2 |
| RETVAL = C2Sv(self->ExternalID,NULL); |
| 7298 |
|
| } |
| 7299 |
|
| OUTPUT: |
| 7300 |
|
| RETVAL |
| 7301 |
|
| |
| 7302 |
|
| SV * |
| 7303 |
|
| parse_string(CLASS, str, ...) |
| 7304 |
|
| char * str |
| 7305 |
|
| PREINIT: |
| 7306 |
|
| xmlDtdPtr res; |
| 7307 |
|
| SV * encoding_sv; |
| 7308 |
|
| xmlParserInputBufferPtr buffer; |
| 7309 |
4 |
| xmlCharEncoding enc = XML_CHAR_ENCODING_NONE; |
| 7310 |
|
| xmlChar * new_string; |
| 7311 |
4 |
| PREINIT_SAVED_ERROR |
| 7312 |
|
| CODE: |
| 7313 |
4 |
| INIT_ERROR_HANDLER; |
| 7314 |
4 |
▶ | if (items > 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 2) { |
0 |
4 |
4 |
|
| 7315 |
0 |
| encoding_sv = ST(2); |
| 7316 |
0 |
▶ | if (items > 3) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 3) { |
0 |
0 |
0 |
|
| 7317 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7318 |
0 |
| croak("parse_string: too many parameters"); |
| 7319 |
|
| } |
| 7320 |
|
| /* warn("getting encoding...\n"); */ |
| 7321 |
0 |
| enc = xmlParseCharEncoding(SvPV_nolen(encoding_sv)); |
| 7322 |
0 |
▶ | if (enc == XML_CHAR_ENCODING_ERROR) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (enc == XML_CHAR_ENCODING_ERROR) { |
0 |
0 |
0 |
|
| 7323 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7324 |
0 |
| REPORT_ERROR(1); |
| 7325 |
0 |
| croak("Parse of encoding %s failed", SvPV_nolen(encoding_sv)); |
| 7326 |
|
| } |
| 7327 |
|
| } |
| 7328 |
4 |
| buffer = xmlAllocParserInputBuffer(enc); |
| 7329 |
|
| /* buffer = xmlParserInputBufferCreateMem(str, xmlStrlen(str), enc); */ |
| 7330 |
4 |
▶ | if ( !buffer) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !buffer) { |
0 |
4 |
4 |
|
| 7331 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7332 |
0 |
| REPORT_ERROR(1); |
| 7333 |
0 |
| croak("cannot create buffer!\n" ); |
| 7334 |
|
| } |
| 7335 |
4 |
| new_string = xmlStrdup((const xmlChar*)str); |
| 7336 |
4 |
| xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string); |
| 7337 |
|
| |
| 7338 |
4 |
| res = xmlIOParseDTD(NULL, buffer, enc); |
| 7339 |
|
| |
| 7340 |
|
| /* NOTE: xmlIOParseDTD is documented to free its InputBuffer */ |
| 7341 |
4 |
| xmlFree(new_string); |
| 7342 |
4 |
▶ | if ( res && LibXML_will_die_ctx(saved_error, 0) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( res && LibXML_will_die_ctx(saved_error, 0) ) |
3 |
1 |
4 |
| if ( res && LibXML_will_die_ctx(saved_error, 0) ) |
0 |
3 |
3 |
|
| 7343 |
0 |
| xmlFreeDtd( res ); |
| 7344 |
4 |
| CLEANUP_ERROR_HANDLER; |
| 7345 |
4 |
| REPORT_ERROR(0); |
| 7346 |
3 |
▶ | if (res == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (res == NULL) { |
0 |
3 |
3 |
|
| 7347 |
0 |
| croak("no DTD parsed!"); |
| 7348 |
|
| } |
| 7349 |
3 |
| RETVAL = PmmNodeToSv((xmlNodePtr)res, NULL); |
| 7350 |
|
| OUTPUT: |
| 7351 |
|
| RETVAL |
| 7352 |
|
| |
| 7353 |
|
| |
| 7354 |
|
| #ifdef HAVE_SCHEMAS |
| 7355 |
|
| |
| 7356 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::RelaxNG |
| 7357 |
|
| |
| 7358 |
|
| void |
| 7359 |
|
| DESTROY( self ) |
| 7360 |
|
| xmlRelaxNGPtr self |
| 7361 |
|
| CODE: |
| 7362 |
8 |
| xmlRelaxNGFree( self ); |
| 7363 |
|
| |
| 7364 |
|
| |
| 7365 |
|
| xmlRelaxNGPtr |
| 7366 |
|
| parse_location( self, url, parser_options = 0, recover = FALSE ) |
| 7367 |
|
| char * url |
| 7368 |
|
| int parser_options |
| 7369 |
|
| bool recover |
| 7370 |
|
| PREINIT: |
| 7371 |
6 |
| const char * CLASS = "XML::LibXML::RelaxNG"; |
| 7372 |
6 |
| xmlRelaxNGParserCtxtPtr rngctxt = NULL; |
| 7373 |
6 |
| xmlExternalEntityLoader old_ext_ent_loader = NULL; |
| 7374 |
6 |
| PREINIT_SAVED_ERROR |
| 7375 |
|
| CODE: |
| 7376 |
6 |
| INIT_ERROR_HANDLER; |
| 7377 |
|
| |
| 7378 |
6 |
| rngctxt = xmlRelaxNGNewParserCtxt( url ); |
| 7379 |
6 |
▶ | if ( rngctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rngctxt == NULL ) { |
0 |
6 |
6 |
|
| 7380 |
0 |
| croak( "failed to initialize RelaxNG parser" ); |
| 7381 |
|
| } |
| 7382 |
|
| #ifndef WITH_SERRORS |
| 7383 |
|
| /* Register Error callbacks */ |
| 7384 |
|
| xmlRelaxNGSetParserErrors( rngctxt, |
| 7385 |
|
| (xmlRelaxNGValidityErrorFunc)LibXML_error_handler_ctx, |
| 7386 |
|
| (xmlRelaxNGValidityWarningFunc)LibXML_error_handler_ctx, |
| 7387 |
|
| saved_error ); |
| 7388 |
|
| #endif |
| 7389 |
|
| |
| 7390 |
|
| /* EXTERNAL_ENTITY_LOADER_FUNC == NULL guard preserves a user-installed |
| 7391 |
|
| * global loader. See CLAUDE.md "Entity loaders" and GH #168. */ |
| 7392 |
6 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
6 |
0 |
6 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
1 |
5 |
6 |
|
| 7393 |
1 |
| old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 7394 |
1 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 7395 |
|
| } |
| 7396 |
|
| |
| 7397 |
6 |
| RETVAL = xmlRelaxNGParse( rngctxt ); |
| 7398 |
|
| |
| 7399 |
6 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
6 |
0 |
6 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
1 |
5 |
6 |
|
| 7400 |
1 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)old_ext_ent_loader ); |
| 7401 |
|
| |
| 7402 |
6 |
| xmlRelaxNGFreeParserCtxt( rngctxt ); |
| 7403 |
6 |
| CLEANUP_ERROR_HANDLER; |
| 7404 |
6 |
▶ | REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
4 |
2 |
6 |
|
| 7405 |
|
| OUTPUT: |
| 7406 |
|
| RETVAL |
| 7407 |
|
| |
| 7408 |
|
| |
| 7409 |
|
| xmlRelaxNGPtr |
| 7410 |
|
| parse_buffer( self, perlstring, parser_options = 0, recover = FALSE ) |
| 7411 |
|
| SV * perlstring |
| 7412 |
|
| int parser_options |
| 7413 |
|
| bool recover |
| 7414 |
|
| PREINIT: |
| 7415 |
7 |
| const char * CLASS = "XML::LibXML::RelaxNG"; |
| 7416 |
7 |
| xmlRelaxNGParserCtxtPtr rngctxt = NULL; |
| 7417 |
7 |
| xmlExternalEntityLoader old_ext_ent_loader = NULL; |
| 7418 |
7 |
| char * string = NULL; |
| 7419 |
7 |
| STRLEN len = 0; |
| 7420 |
7 |
| PREINIT_SAVED_ERROR |
| 7421 |
|
| INIT: |
| 7422 |
7 |
| string = SvPV( perlstring, len ); |
| 7423 |
7 |
▶ | if ( string == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( string == NULL ) { |
0 |
7 |
7 |
|
| 7424 |
0 |
| croak( "cannot parse empty string" ); |
| 7425 |
|
| } |
| 7426 |
|
| CODE: |
| 7427 |
7 |
| INIT_ERROR_HANDLER; |
| 7428 |
|
| |
| 7429 |
7 |
| rngctxt = xmlRelaxNGNewMemParserCtxt( string,len ); |
| 7430 |
7 |
▶ | if ( rngctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rngctxt == NULL ) { |
0 |
7 |
7 |
|
| 7431 |
0 |
| croak( "failed to initialize RelaxNG parser" ); |
| 7432 |
|
| } |
| 7433 |
|
| #ifndef WITH_SERRORS |
| 7434 |
|
| /* Register Error callbacks */ |
| 7435 |
|
| xmlRelaxNGSetParserErrors( rngctxt, |
| 7436 |
|
| (xmlRelaxNGValidityErrorFunc)LibXML_error_handler_ctx, |
| 7437 |
|
| (xmlRelaxNGValidityWarningFunc)LibXML_error_handler_ctx, |
| 7438 |
|
| saved_error ); |
| 7439 |
|
| #endif |
| 7440 |
|
| |
| 7441 |
|
| /* EXTERNAL_ENTITY_LOADER_FUNC == NULL guard preserves a user-installed |
| 7442 |
|
| * global loader. See CLAUDE.md "Entity loaders" and GH #168. */ |
| 7443 |
7 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
5 |
2 |
7 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
3 |
2 |
5 |
|
| 7444 |
3 |
| old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 7445 |
3 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 7446 |
|
| } |
| 7447 |
|
| |
| 7448 |
7 |
| RETVAL = xmlRelaxNGParse( rngctxt ); |
| 7449 |
|
| |
| 7450 |
7 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
5 |
2 |
7 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
3 |
2 |
5 |
|
| 7451 |
3 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)old_ext_ent_loader ); |
| 7452 |
|
| |
| 7453 |
7 |
| xmlRelaxNGFreeParserCtxt( rngctxt ); |
| 7454 |
7 |
| CLEANUP_ERROR_HANDLER; |
| 7455 |
7 |
▶ | REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
3 |
4 |
7 |
|
| 7456 |
|
| OUTPUT: |
| 7457 |
|
| RETVAL |
| 7458 |
|
| |
| 7459 |
|
| |
| 7460 |
|
| xmlRelaxNGPtr |
| 7461 |
|
| parse_document( self, doc, parser_options = 0, recover = FALSE ) |
| 7462 |
|
| xmlDocPtr doc |
| 7463 |
|
| int parser_options |
| 7464 |
|
| bool recover |
| 7465 |
|
| PREINIT: |
| 7466 |
2 |
| const char * CLASS = "XML::LibXML::RelaxNG"; |
| 7467 |
2 |
| xmlRelaxNGParserCtxtPtr rngctxt = NULL; |
| 7468 |
2 |
| xmlExternalEntityLoader old_ext_ent_loader = NULL; |
| 7469 |
2 |
| PREINIT_SAVED_ERROR |
| 7470 |
|
| CODE: |
| 7471 |
2 |
| INIT_ERROR_HANDLER; |
| 7472 |
|
| |
| 7473 |
2 |
| rngctxt = xmlRelaxNGNewDocParserCtxt( doc ); |
| 7474 |
2 |
▶ | if ( rngctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rngctxt == NULL ) { |
0 |
2 |
2 |
|
| 7475 |
0 |
| croak( "failed to initialize RelaxNG parser" ); |
| 7476 |
|
| } |
| 7477 |
|
| #ifndef WITH_SERRORS |
| 7478 |
|
| /* Register Error callbacks */ |
| 7479 |
|
| xmlRelaxNGSetParserErrors( rngctxt, |
| 7480 |
|
| (xmlRelaxNGValidityErrorFunc) LibXML_error_handler_ctx, |
| 7481 |
|
| (xmlRelaxNGValidityWarningFunc)LibXML_error_handler_ctx, |
| 7482 |
|
| saved_error ); |
| 7483 |
|
| #endif |
| 7484 |
|
| |
| 7485 |
|
| /* EXTERNAL_ENTITY_LOADER_FUNC == NULL guard preserves a user-installed |
| 7486 |
|
| * global loader. See CLAUDE.md "Entity loaders" and GH #168. */ |
| 7487 |
2 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
2 |
0 |
2 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
0 |
2 |
2 |
|
| 7488 |
0 |
| old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 7489 |
0 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 7490 |
|
| } |
| 7491 |
|
| |
| 7492 |
2 |
| RETVAL = xmlRelaxNGParse( rngctxt ); |
| 7493 |
|
| |
| 7494 |
2 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
2 |
0 |
2 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
0 |
2 |
2 |
|
| 7495 |
0 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)old_ext_ent_loader ); |
| 7496 |
|
| |
| 7497 |
2 |
| xmlRelaxNGFreeParserCtxt( rngctxt ); |
| 7498 |
2 |
| CLEANUP_ERROR_HANDLER; |
| 7499 |
2 |
▶ | REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
1 |
1 |
2 |
|
| 7500 |
|
| OUTPUT: |
| 7501 |
|
| RETVAL |
| 7502 |
|
| |
| 7503 |
|
| int |
| 7504 |
|
| validate( self, doc ) |
| 7505 |
|
| xmlRelaxNGPtr self |
| 7506 |
|
| xmlDocPtr doc |
| 7507 |
|
| PREINIT: |
| 7508 |
7 |
| xmlRelaxNGValidCtxtPtr vctxt = NULL; |
| 7509 |
7 |
| PREINIT_SAVED_ERROR |
| 7510 |
|
| CODE: |
| 7511 |
7 |
| INIT_ERROR_HANDLER; |
| 7512 |
|
| |
| 7513 |
7 |
▶ | if (doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (doc) { |
7 |
0 |
7 |
|
| 7514 |
7 |
▶ | PmmClearPSVI(doc); |
Branch: 4 branches
| Branch | True | False | Total |
| PmmClearPSVI(doc); |
7 |
0 |
7 |
| PmmClearPSVI(doc); |
7 |
0 |
7 |
| PmmClearPSVI(doc); |
7 |
0 |
7 |
| PmmClearPSVI(doc); |
4 |
3 |
7 |
|
| 7515 |
7 |
▶ | PmmInvalidatePSVI(doc); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI(doc); |
7 |
0 |
7 |
| PmmInvalidatePSVI(doc); |
7 |
0 |
7 |
|
| 7516 |
|
| } |
| 7517 |
7 |
| vctxt = xmlRelaxNGNewValidCtxt( self ); |
| 7518 |
7 |
▶ | if ( vctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( vctxt == NULL ) { |
0 |
7 |
7 |
|
| 7519 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7520 |
0 |
| REPORT_ERROR(0); |
| 7521 |
0 |
| croak( "cannot initialize the validation context" ); |
| 7522 |
|
| } |
| 7523 |
|
| #ifndef WITH_SERRORS |
| 7524 |
|
| /* Register Error callbacks */ |
| 7525 |
|
| xmlRelaxNGSetValidErrors( vctxt, |
| 7526 |
|
| (xmlRelaxNGValidityErrorFunc)LibXML_error_handler_ctx, |
| 7527 |
|
| (xmlRelaxNGValidityWarningFunc)LibXML_error_handler_ctx, |
| 7528 |
|
| saved_error ); |
| 7529 |
|
| #endif /* WITH_SERRORS */ |
| 7530 |
|
| /* ** test only ** |
| 7531 |
|
| xmlRelaxNGSetValidErrors( vctxt, |
| 7532 |
|
| (xmlRelaxNGValidityErrorFunc)fprintf, |
| 7533 |
|
| (xmlRelaxNGValidityWarningFunc)fprintf, |
| 7534 |
|
| stderr ); |
| 7535 |
|
| */ |
| 7536 |
7 |
| RETVAL = xmlRelaxNGValidateDoc( vctxt, doc ); |
| 7537 |
7 |
| xmlRelaxNGFreeValidCtxt( vctxt ); |
| 7538 |
7 |
| CLEANUP_ERROR_HANDLER; |
| 7539 |
7 |
| REPORT_ERROR(0); |
| 7540 |
3 |
▶ | if ( RETVAL == 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == 1 ) { |
0 |
3 |
3 |
|
| 7541 |
0 |
| XSRETURN_UNDEF; |
| 7542 |
|
| } |
| 7543 |
3 |
▶ | if ( RETVAL == -1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == -1 ) { |
0 |
3 |
3 |
|
| 7544 |
0 |
| croak( "API Error" ); |
| 7545 |
|
| XSRETURN_UNDEF; |
| 7546 |
|
| } |
| 7547 |
|
| OUTPUT: |
| 7548 |
|
| RETVAL |
| 7549 |
|
| |
| 7550 |
|
| |
| 7551 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Schema |
| 7552 |
|
| |
| 7553 |
|
| void |
| 7554 |
|
| DESTROY( self ) |
| 7555 |
|
| xmlSchemaPtr self |
| 7556 |
|
| CODE: |
| 7557 |
7 |
| xmlSchemaFree( self ); |
| 7558 |
|
| |
| 7559 |
|
| |
| 7560 |
|
| xmlSchemaPtr |
| 7561 |
|
| parse_location( self, url, parser_options = 0, recover = FALSE ) |
| 7562 |
|
| char * url |
| 7563 |
|
| int parser_options |
| 7564 |
|
| bool recover |
| 7565 |
|
| PREINIT: |
| 7566 |
5 |
| const char * CLASS = "XML::LibXML::Schema"; |
| 7567 |
5 |
| xmlSchemaParserCtxtPtr rngctxt = NULL; |
| 7568 |
5 |
| xmlExternalEntityLoader old_ext_ent_loader = NULL; |
| 7569 |
5 |
| PREINIT_SAVED_ERROR |
| 7570 |
|
| CODE: |
| 7571 |
5 |
| INIT_ERROR_HANDLER; |
| 7572 |
|
| |
| 7573 |
5 |
| rngctxt = xmlSchemaNewParserCtxt( url ); |
| 7574 |
5 |
▶ | if ( rngctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rngctxt == NULL ) { |
0 |
5 |
5 |
|
| 7575 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7576 |
0 |
| REPORT_ERROR(0); |
| 7577 |
0 |
| croak( "failed to initialize Schema parser" ); |
| 7578 |
|
| } |
| 7579 |
|
| |
| 7580 |
|
| /* Register Error callbacks */ |
| 7581 |
5 |
| xmlSchemaSetParserErrors( rngctxt, |
| 7582 |
|
| (xmlSchemaValidityErrorFunc)LibXML_error_handler_ctx, |
| 7583 |
|
| (xmlSchemaValidityWarningFunc)LibXML_error_handler_ctx, |
| 7584 |
|
| saved_error ); |
| 7585 |
|
| |
| 7586 |
|
| /* EXTERNAL_ENTITY_LOADER_FUNC == NULL guard preserves a user-installed |
| 7587 |
|
| * global loader. See CLAUDE.md "Entity loaders" and GH #168. */ |
| 7588 |
5 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
5 |
0 |
5 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
1 |
4 |
5 |
|
| 7589 |
1 |
| old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 7590 |
1 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 7591 |
|
| } |
| 7592 |
|
| |
| 7593 |
5 |
| RETVAL = xmlSchemaParse( rngctxt ); |
| 7594 |
|
| |
| 7595 |
5 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
5 |
0 |
5 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
1 |
4 |
5 |
|
| 7596 |
1 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)old_ext_ent_loader ); |
| 7597 |
|
| |
| 7598 |
5 |
| xmlSchemaFreeParserCtxt( rngctxt ); |
| 7599 |
5 |
| CLEANUP_ERROR_HANDLER; |
| 7600 |
5 |
▶ | REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
4 |
1 |
5 |
|
| 7601 |
|
| OUTPUT: |
| 7602 |
|
| RETVAL |
| 7603 |
|
| |
| 7604 |
|
| |
| 7605 |
|
| xmlSchemaPtr |
| 7606 |
|
| parse_buffer( self, perlstring, parser_options = 0, recover = FALSE ) |
| 7607 |
|
| SV * perlstring |
| 7608 |
|
| int parser_options |
| 7609 |
|
| bool recover |
| 7610 |
|
| PREINIT: |
| 7611 |
8 |
| const char * CLASS = "XML::LibXML::Schema"; |
| 7612 |
8 |
| xmlSchemaParserCtxtPtr rngctxt = NULL; |
| 7613 |
8 |
| xmlExternalEntityLoader old_ext_ent_loader = NULL; |
| 7614 |
8 |
| char * string = NULL; |
| 7615 |
8 |
| STRLEN len = 0; |
| 7616 |
8 |
| PREINIT_SAVED_ERROR |
| 7617 |
|
| INIT: |
| 7618 |
8 |
| string = SvPV( perlstring, len ); |
| 7619 |
8 |
▶ | if ( string == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( string == NULL ) { |
0 |
8 |
8 |
|
| 7620 |
0 |
| croak( "cannot parse empty string" ); |
| 7621 |
|
| } |
| 7622 |
|
| CODE: |
| 7623 |
8 |
| INIT_ERROR_HANDLER; |
| 7624 |
|
| |
| 7625 |
8 |
| rngctxt = xmlSchemaNewMemParserCtxt( string,len ); |
| 7626 |
8 |
▶ | if ( rngctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( rngctxt == NULL ) { |
0 |
8 |
8 |
|
| 7627 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7628 |
0 |
| REPORT_ERROR(0); |
| 7629 |
0 |
| croak( "failed to initialize Schema parser" ); |
| 7630 |
|
| } |
| 7631 |
|
| |
| 7632 |
|
| /* Register Error callbacks */ |
| 7633 |
8 |
| xmlSchemaSetParserErrors( rngctxt, |
| 7634 |
|
| (xmlSchemaValidityErrorFunc)LibXML_error_handler_ctx, |
| 7635 |
|
| (xmlSchemaValidityWarningFunc)LibXML_error_handler_ctx, |
| 7636 |
|
| saved_error ); |
| 7637 |
|
| |
| 7638 |
|
| /* EXTERNAL_ENTITY_LOADER_FUNC == NULL guard preserves a user-installed |
| 7639 |
|
| * global loader. See CLAUDE.md "Entity loaders" and GH #168. */ |
| 7640 |
8 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
6 |
2 |
8 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) { |
3 |
3 |
6 |
|
| 7641 |
3 |
| old_ext_ent_loader = xmlGetExternalEntityLoader(); |
| 7642 |
3 |
| xmlSetExternalEntityLoader( xmlNoNetExternalEntityLoader ); |
| 7643 |
|
| } |
| 7644 |
|
| |
| 7645 |
8 |
| RETVAL = xmlSchemaParse( rngctxt ); |
| 7646 |
|
| |
| 7647 |
8 |
▶ | if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
6 |
2 |
8 |
| if ( EXTERNAL_ENTITY_LOADER_FUNC == NULL && (parser_options & XML_PARSE_NONET) ) |
3 |
3 |
6 |
|
| 7648 |
3 |
| xmlSetExternalEntityLoader( (xmlExternalEntityLoader)old_ext_ent_loader ); |
| 7649 |
|
| |
| 7650 |
8 |
| xmlSchemaFreeParserCtxt( rngctxt ); |
| 7651 |
8 |
| CLEANUP_ERROR_HANDLER; |
| 7652 |
8 |
▶ | REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
Branch: 1 branch
| Branch | True | False | Total |
| REPORT_ERROR((RETVAL == NULL) ? 0 : recover); |
7 |
1 |
8 |
|
| 7653 |
|
| OUTPUT: |
| 7654 |
|
| RETVAL |
| 7655 |
|
| |
| 7656 |
|
| |
| 7657 |
|
| int |
| 7658 |
|
| validate( self, node ) |
| 7659 |
|
| xmlSchemaPtr self |
| 7660 |
|
| xmlNodePtr node |
| 7661 |
|
| PREINIT: |
| 7662 |
3 |
| xmlSchemaValidCtxtPtr vctxt = NULL; |
| 7663 |
3 |
| PREINIT_SAVED_ERROR |
| 7664 |
|
| CODE: |
| 7665 |
3 |
| INIT_ERROR_HANDLER; |
| 7666 |
|
| |
| 7667 |
3 |
▶ | if (node->type == XML_DOCUMENT_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_DOCUMENT_NODE) { |
2 |
1 |
3 |
|
| 7668 |
2 |
▶ | PmmClearPSVI((xmlDocPtr)node); |
Branch: 4 branches
| Branch | True | False | Total |
| PmmClearPSVI((xmlDocPtr)node); |
2 |
0 |
2 |
| PmmClearPSVI((xmlDocPtr)node); |
2 |
0 |
2 |
| PmmClearPSVI((xmlDocPtr)node); |
2 |
0 |
2 |
| PmmClearPSVI((xmlDocPtr)node); |
0 |
2 |
2 |
|
| 7669 |
2 |
▶ | PmmInvalidatePSVI((xmlDocPtr)node); |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI((xmlDocPtr)node); |
2 |
0 |
2 |
| PmmInvalidatePSVI((xmlDocPtr)node); |
2 |
0 |
2 |
|
| 7670 |
|
| } |
| 7671 |
3 |
| vctxt = xmlSchemaNewValidCtxt( self ); |
| 7672 |
3 |
▶ | if ( vctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( vctxt == NULL ) { |
0 |
3 |
3 |
|
| 7673 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 7674 |
0 |
| REPORT_ERROR(0); |
| 7675 |
0 |
| croak( "cannot initialize the validation context" ); |
| 7676 |
|
| } |
| 7677 |
|
| |
| 7678 |
|
| /* Register Error callbacks */ |
| 7679 |
3 |
| xmlSchemaSetValidErrors( vctxt, |
| 7680 |
|
| (xmlSchemaValidityErrorFunc)LibXML_error_handler_ctx, |
| 7681 |
|
| (xmlSchemaValidityWarningFunc)LibXML_error_handler_ctx, |
| 7682 |
|
| saved_error ); |
| 7683 |
|
| |
| 7684 |
3 |
▶ | if (node->type == XML_DOCUMENT_NODE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node->type == XML_DOCUMENT_NODE) { |
2 |
1 |
3 |
|
| 7685 |
2 |
| RETVAL = xmlSchemaValidateDoc(vctxt, (xmlDocPtr)node); |
| 7686 |
|
| } |
| 7687 |
|
| else { |
| 7688 |
1 |
| RETVAL = xmlSchemaValidateOneElement(vctxt, node); |
| 7689 |
|
| } |
| 7690 |
|
| |
| 7691 |
3 |
| xmlSchemaFreeValidCtxt( vctxt ); |
| 7692 |
|
| |
| 7693 |
3 |
| CLEANUP_ERROR_HANDLER; |
| 7694 |
3 |
| REPORT_ERROR(0); |
| 7695 |
2 |
▶ | if ( RETVAL > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL > 0 ) { |
0 |
2 |
2 |
|
| 7696 |
0 |
| XSRETURN_UNDEF; |
| 7697 |
|
| } |
| 7698 |
2 |
▶ | if ( RETVAL == -1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == -1 ) { |
0 |
2 |
2 |
|
| 7699 |
0 |
| croak( "API Error" ); |
| 7700 |
|
| XSRETURN_UNDEF; |
| 7701 |
|
| } |
| 7702 |
|
| OUTPUT: |
| 7703 |
|
| RETVAL |
| 7704 |
|
| |
| 7705 |
|
| #endif /* HAVE_SCHEMAS */ |
| 7706 |
|
| |
| 7707 |
|
| MODULE = XML::LibXML::XPathContext PACKAGE = XML::LibXML::XPathContext |
| 7708 |
|
| |
| 7709 |
|
| # PROTOTYPES: DISABLE |
| 7710 |
|
| |
| 7711 |
|
| SV* |
| 7712 |
|
| new( CLASS, ... ) |
| 7713 |
|
| const char * CLASS |
| 7714 |
|
| PREINIT: |
| 7715 |
32 |
| SV * pnode = &PL_sv_undef; |
| 7716 |
|
| INIT: |
| 7717 |
|
| xmlXPathContextPtr ctxt; |
| 7718 |
|
| CODE: |
| 7719 |
32 |
▶ | if( items > 1 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if( items > 1 ) |
26 |
6 |
32 |
|
| 7720 |
26 |
| pnode = ST(1); |
| 7721 |
|
| |
| 7722 |
32 |
| ctxt = xmlXPathNewContext( NULL ); |
| 7723 |
32 |
| ctxt->namespaces = NULL; |
| 7724 |
|
| |
| 7725 |
32 |
| New(0, ctxt->user, sizeof(XPathContextData), XPathContextData); |
| 7726 |
32 |
▶ | if (ctxt->user == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->user == NULL) { |
0 |
32 |
32 |
|
| 7727 |
0 |
| croak("XPathContext: failed to allocate proxy object\n"); |
| 7728 |
|
| } |
| 7729 |
|
| |
| 7730 |
32 |
▶ | if (SvOK(pnode)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(pnode)) { |
26 |
6 |
32 |
|
| 7731 |
26 |
| XPathContextDATA(ctxt)->node = newSVsv(pnode); |
| 7732 |
|
| } else { |
| 7733 |
6 |
| XPathContextDATA(ctxt)->node = &PL_sv_undef; |
| 7734 |
|
| } |
| 7735 |
|
| |
| 7736 |
32 |
| XPathContextDATA(ctxt)->pool = NULL; |
| 7737 |
32 |
| XPathContextDATA(ctxt)->varLookup = NULL; |
| 7738 |
32 |
| XPathContextDATA(ctxt)->varData = NULL; |
| 7739 |
|
| |
| 7740 |
32 |
| xmlXPathRegisterFunc(ctxt, |
| 7741 |
|
| (const xmlChar *) "document", |
| 7742 |
|
| perlDocumentFunction); |
| 7743 |
|
| |
| 7744 |
32 |
| RETVAL = NEWSV(0,0), |
| 7745 |
32 |
| RETVAL = sv_setref_pv( RETVAL, |
| 7746 |
|
| CLASS, |
| 7747 |
|
| (void*)ctxt ); |
| 7748 |
|
| OUTPUT: |
| 7749 |
|
| RETVAL |
| 7750 |
|
| |
| 7751 |
|
| void |
| 7752 |
|
| DESTROY( self ) |
| 7753 |
|
| SV * self |
| 7754 |
|
| INIT: |
| 7755 |
32 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7756 |
|
| CODE: |
| 7757 |
|
| xs_warn( "DESTROY XPATH CONTEXT" ); |
| 7758 |
32 |
▶ | if (ctxt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt) { |
32 |
0 |
32 |
|
| 7759 |
32 |
▶ | if (XPathContextDATA(ctxt) != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt) != NULL) { |
32 |
0 |
32 |
|
| 7760 |
32 |
▶ | if (XPathContextDATA(ctxt)->node != NULL && |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->node != NULL && |
30 |
2 |
32 |
|
| 7761 |
30 |
▶ | SvOK(XPathContextDATA(ctxt)->node)) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvOK(XPathContextDATA(ctxt)->node)) { |
27 |
3 |
30 |
|
| 7762 |
27 |
| SvREFCNT_dec(XPathContextDATA(ctxt)->node); |
| 7763 |
|
| } |
| 7764 |
32 |
▶ | if (XPathContextDATA(ctxt)->varLookup != NULL && |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->varLookup != NULL && |
2 |
30 |
32 |
|
| 7765 |
2 |
▶ | SvOK(XPathContextDATA(ctxt)->varLookup)) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvOK(XPathContextDATA(ctxt)->varLookup)) { |
2 |
0 |
2 |
|
| 7766 |
2 |
| SvREFCNT_dec(XPathContextDATA(ctxt)->varLookup); |
| 7767 |
|
| } |
| 7768 |
32 |
▶ | if (XPathContextDATA(ctxt)->varData != NULL && |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->varData != NULL && |
1 |
31 |
32 |
|
| 7769 |
1 |
▶ | SvOK(XPathContextDATA(ctxt)->varData)) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvOK(XPathContextDATA(ctxt)->varData)) { |
1 |
0 |
1 |
|
| 7770 |
1 |
| SvREFCNT_dec(XPathContextDATA(ctxt)->varData); |
| 7771 |
|
| } |
| 7772 |
32 |
▶ | if (XPathContextDATA(ctxt)->pool != NULL && |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->pool != NULL && |
0 |
32 |
32 |
|
| 7773 |
0 |
▶ | SvOK(XPathContextDATA(ctxt)->pool)) { |
Branch: 1 branch
| Branch | True | False | Total |
| SvOK(XPathContextDATA(ctxt)->pool)) { |
0 |
0 |
0 |
|
| 7774 |
0 |
| SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); |
| 7775 |
|
| } |
| 7776 |
32 |
| Safefree(XPathContextDATA(ctxt)); |
| 7777 |
|
| } |
| 7778 |
|
| |
| 7779 |
32 |
▶ | if (ctxt->namespaces != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->namespaces != NULL) { |
4 |
28 |
32 |
|
| 7780 |
4 |
| xmlFree( ctxt->namespaces ); |
| 7781 |
|
| } |
| 7782 |
32 |
▶ | if (ctxt->funcLookupData != NULL && SvROK((SV*)ctxt->funcLookupData) |
Branch: 2 branches
| Branch | True | False | Total |
| if (ctxt->funcLookupData != NULL && SvROK((SV*)ctxt->funcLookupData) |
3 |
29 |
32 |
| if (ctxt->funcLookupData != NULL && SvROK((SV*)ctxt->funcLookupData) |
3 |
0 |
3 |
|
| 7783 |
3 |
▶ | && SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) { |
Branch: 1 branch
| Branch | True | False | Total |
| && SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) { |
3 |
0 |
3 |
|
| 7784 |
3 |
| SvREFCNT_dec((SV *)ctxt->funcLookupData); |
| 7785 |
|
| } |
| 7786 |
|
| |
| 7787 |
32 |
| xmlXPathFreeContext(ctxt); |
| 7788 |
|
| } |
| 7789 |
|
| |
| 7790 |
|
| SV* |
| 7791 |
|
| getContextNode( self ) |
| 7792 |
|
| SV * self |
| 7793 |
|
| INIT: |
| 7794 |
27 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7795 |
27 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
27 |
27 |
|
| 7796 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7797 |
|
| } |
| 7798 |
|
| CODE: |
| 7799 |
27 |
▶ | if(XPathContextDATA(ctxt)->node != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(XPathContextDATA(ctxt)->node != NULL) { |
14 |
13 |
27 |
|
| 7800 |
14 |
| RETVAL = newSVsv(XPathContextDATA(ctxt)->node); |
| 7801 |
|
| } else { |
| 7802 |
13 |
| RETVAL = &PL_sv_undef; |
| 7803 |
|
| } |
| 7804 |
|
| OUTPUT: |
| 7805 |
|
| RETVAL |
| 7806 |
|
| |
| 7807 |
|
| int |
| 7808 |
|
| getContextPosition( self ) |
| 7809 |
|
| SV * self |
| 7810 |
|
| INIT: |
| 7811 |
4 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7812 |
4 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
4 |
4 |
|
| 7813 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7814 |
|
| } |
| 7815 |
|
| CODE: |
| 7816 |
4 |
▶ | RETVAL = ctxt->proximityPosition; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ctxt->proximityPosition; |
0 |
4 |
4 |
|
| 7817 |
|
| OUTPUT: |
| 7818 |
|
| RETVAL |
| 7819 |
|
| |
| 7820 |
|
| int |
| 7821 |
|
| getContextSize( self ) |
| 7822 |
|
| SV * self |
| 7823 |
|
| INIT: |
| 7824 |
5 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7825 |
5 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
5 |
5 |
|
| 7826 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7827 |
|
| } |
| 7828 |
|
| CODE: |
| 7829 |
5 |
▶ | RETVAL = ctxt->contextSize; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ctxt->contextSize; |
0 |
5 |
5 |
|
| 7830 |
|
| OUTPUT: |
| 7831 |
|
| RETVAL |
| 7832 |
|
| |
| 7833 |
|
| void |
| 7834 |
|
| setContextNode( self , pnode ) |
| 7835 |
|
| SV * self |
| 7836 |
|
| SV * pnode |
| 7837 |
|
| INIT: |
| 7838 |
40 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7839 |
40 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
40 |
40 |
|
| 7840 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7841 |
|
| } |
| 7842 |
|
| PPCODE: |
| 7843 |
40 |
▶ | if (XPathContextDATA(ctxt)->node != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->node != NULL) { |
27 |
13 |
40 |
|
| 7844 |
27 |
| SvREFCNT_dec(XPathContextDATA(ctxt)->node); |
| 7845 |
|
| } |
| 7846 |
40 |
▶ | if (SvOK(pnode)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(pnode)) { |
25 |
15 |
40 |
|
| 7847 |
25 |
| XPathContextDATA(ctxt)->node = newSVsv(pnode); |
| 7848 |
|
| } else { |
| 7849 |
15 |
| XPathContextDATA(ctxt)->node = NULL; |
| 7850 |
|
| } |
| 7851 |
|
| |
| 7852 |
|
| void |
| 7853 |
|
| setContextPosition( self , position ) |
| 7854 |
|
| SV * self |
| 7855 |
|
| int position |
| 7856 |
|
| INIT: |
| 7857 |
4 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7858 |
4 |
▶ | if ( ctxt == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) |
0 |
4 |
4 |
|
| 7859 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7860 |
4 |
▶ | if ( position < -1 || position > ctxt->contextSize ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( position < -1 || position > ctxt->contextSize ) |
3 |
1 |
4 |
| if ( position < -1 || position > ctxt->contextSize ) |
2 |
1 |
3 |
|
| 7861 |
3 |
| croak("XPathContext: invalid position\n"); |
| 7862 |
|
| PPCODE: |
| 7863 |
1 |
| ctxt->proximityPosition = position; |
| 7864 |
|
| |
| 7865 |
|
| void |
| 7866 |
|
| setContextSize( self , size ) |
| 7867 |
|
| SV * self |
| 7868 |
|
| int size |
| 7869 |
|
| INIT: |
| 7870 |
4 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7871 |
4 |
▶ | if ( ctxt == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) |
0 |
4 |
4 |
|
| 7872 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7873 |
4 |
▶ | if ( size < -1 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( size < -1 ) |
1 |
3 |
4 |
|
| 7874 |
1 |
| croak("XPathContext: invalid size\n"); |
| 7875 |
|
| PPCODE: |
| 7876 |
3 |
| ctxt->contextSize = size; |
| 7877 |
3 |
▶ | if ( size == 0 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( size == 0 ) |
1 |
2 |
3 |
|
| 7878 |
1 |
| ctxt->proximityPosition = 0; |
| 7879 |
2 |
▶ | else if ( size > 0 ) |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( size > 0 ) |
1 |
1 |
2 |
|
| 7880 |
1 |
| ctxt->proximityPosition = 1; |
| 7881 |
|
| else |
| 7882 |
1 |
| ctxt->proximityPosition = -1; |
| 7883 |
|
| |
| 7884 |
|
| void |
| 7885 |
|
| registerNs( pxpath_context, prefix, ns_uri ) |
| 7886 |
|
| SV * pxpath_context |
| 7887 |
|
| SV * prefix |
| 7888 |
|
| SV * ns_uri |
| 7889 |
|
| PREINIT: |
| 7890 |
11 |
| xmlXPathContextPtr ctxt = NULL; |
| 7891 |
|
| INIT: |
| 7892 |
11 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 7893 |
11 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
11 |
11 |
|
| 7894 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7895 |
|
| } |
| 7896 |
11 |
| LibXML_configure_xpathcontext(ctxt); |
| 7897 |
|
| PPCODE: |
| 7898 |
11 |
▶ | if(SvOK(ns_uri)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(SvOK(ns_uri)) { |
8 |
3 |
11 |
|
| 7899 |
8 |
▶ | if(xmlXPathRegisterNs(ctxt, (xmlChar *) SvPV_nolen(prefix), |
Branch: 1 branch
| Branch | True | False | Total |
| if(xmlXPathRegisterNs(ctxt, (xmlChar *) SvPV_nolen(prefix), |
0 |
8 |
8 |
|
| 7900 |
8 |
▶ | (xmlChar *) SvPV_nolen(ns_uri)) == -1) { |
Branch: 1 branch
| Branch | True | False | Total |
| (xmlChar *) SvPV_nolen(ns_uri)) == -1) { |
8 |
0 |
8 |
|
| 7901 |
0 |
| croak("XPathContext: cannot register namespace\n"); |
| 7902 |
|
| } |
| 7903 |
|
| } else { |
| 7904 |
3 |
▶ | if(xmlXPathRegisterNs(ctxt, (xmlChar *) SvPV_nolen(prefix), NULL) == -1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(xmlXPathRegisterNs(ctxt, (xmlChar *) SvPV_nolen(prefix), NULL) == -1) { |
0 |
3 |
3 |
|
| 7905 |
0 |
| croak("XPathContext: cannot unregister namespace\n"); |
| 7906 |
|
| } |
| 7907 |
|
| } |
| 7908 |
|
| |
| 7909 |
|
| SV* |
| 7910 |
|
| lookupNs( pxpath_context, prefix ) |
| 7911 |
|
| SV * pxpath_context |
| 7912 |
|
| SV * prefix |
| 7913 |
|
| PREINIT: |
| 7914 |
3 |
| xmlXPathContextPtr ctxt = NULL; |
| 7915 |
|
| INIT: |
| 7916 |
3 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 7917 |
3 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
3 |
3 |
|
| 7918 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7919 |
|
| } |
| 7920 |
3 |
| LibXML_configure_xpathcontext(ctxt); |
| 7921 |
|
| CODE: |
| 7922 |
3 |
| RETVAL = C2Sv(xmlXPathNsLookup(ctxt, (xmlChar *) SvPV_nolen(prefix)), NULL); |
| 7923 |
|
| OUTPUT: |
| 7924 |
|
| RETVAL |
| 7925 |
|
| |
| 7926 |
|
| SV* |
| 7927 |
|
| getVarLookupData( self ) |
| 7928 |
|
| SV * self |
| 7929 |
|
| INIT: |
| 7930 |
6 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7931 |
6 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
6 |
6 |
|
| 7932 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7933 |
|
| } |
| 7934 |
|
| CODE: |
| 7935 |
6 |
▶ | if(XPathContextDATA(ctxt)->varData != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(XPathContextDATA(ctxt)->varData != NULL) { |
5 |
1 |
6 |
|
| 7936 |
5 |
| RETVAL = newSVsv(XPathContextDATA(ctxt)->varData); |
| 7937 |
|
| } else { |
| 7938 |
1 |
| RETVAL = &PL_sv_undef; |
| 7939 |
|
| } |
| 7940 |
|
| OUTPUT: |
| 7941 |
|
| RETVAL |
| 7942 |
|
| |
| 7943 |
|
| SV* |
| 7944 |
|
| getVarLookupFunc( self ) |
| 7945 |
|
| SV * self |
| 7946 |
|
| INIT: |
| 7947 |
2 |
| xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); |
| 7948 |
2 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
2 |
2 |
|
| 7949 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7950 |
|
| } |
| 7951 |
|
| CODE: |
| 7952 |
2 |
▶ | if(XPathContextDATA(ctxt)->varData != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(XPathContextDATA(ctxt)->varData != NULL) { |
1 |
1 |
2 |
|
| 7953 |
1 |
| RETVAL = newSVsv(XPathContextDATA(ctxt)->varLookup); |
| 7954 |
|
| } else { |
| 7955 |
1 |
| RETVAL = &PL_sv_undef; |
| 7956 |
|
| } |
| 7957 |
|
| OUTPUT: |
| 7958 |
|
| RETVAL |
| 7959 |
|
| |
| 7960 |
|
| void |
| 7961 |
|
| registerVarLookupFunc( pxpath_context, lookup_func, lookup_data ) |
| 7962 |
|
| SV * pxpath_context |
| 7963 |
|
| SV * lookup_func |
| 7964 |
|
| SV * lookup_data |
| 7965 |
|
| PREINIT: |
| 7966 |
4 |
| xmlXPathContextPtr ctxt = NULL; |
| 7967 |
4 |
| XPathContextDataPtr data = NULL; |
| 7968 |
|
| INIT: |
| 7969 |
4 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 7970 |
4 |
▶ | if ( ctxt == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) |
0 |
4 |
4 |
|
| 7971 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 7972 |
4 |
| data = XPathContextDATA(ctxt); |
| 7973 |
4 |
▶ | if ( data == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( data == NULL ) |
0 |
4 |
4 |
|
| 7974 |
0 |
| croak("XPathContext: missing xpath context private data\n"); |
| 7975 |
4 |
| LibXML_configure_xpathcontext(ctxt); |
| 7976 |
|
| /* free previous lookup function and data */ |
| 7977 |
4 |
▶ | if (data->varLookup && SvOK(data->varLookup)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (data->varLookup && SvOK(data->varLookup)) |
1 |
3 |
4 |
| if (data->varLookup && SvOK(data->varLookup)) |
1 |
0 |
1 |
|
| 7978 |
1 |
| SvREFCNT_dec(data->varLookup); |
| 7979 |
4 |
▶ | if (data->varData && SvOK(data->varData)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (data->varData && SvOK(data->varData)) |
1 |
3 |
4 |
| if (data->varData && SvOK(data->varData)) |
1 |
0 |
1 |
|
| 7980 |
1 |
| SvREFCNT_dec(data->varData); |
| 7981 |
4 |
| data->varLookup=NULL; |
| 7982 |
4 |
| data->varData=NULL; |
| 7983 |
|
| PPCODE: |
| 7984 |
4 |
▶ | if (SvOK(lookup_func)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(lookup_func)) { |
3 |
1 |
4 |
|
| 7985 |
3 |
▶ | if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) { |
3 |
0 |
3 |
| if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) { |
3 |
0 |
3 |
|
| 7986 |
3 |
| data->varLookup = newSVsv(lookup_func); |
| 7987 |
3 |
▶ | if (SvOK(lookup_data)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(lookup_data)) |
2 |
1 |
3 |
|
| 7988 |
2 |
| data->varData = newSVsv(lookup_data); |
| 7989 |
3 |
| xmlXPathRegisterVariableLookup(ctxt, |
| 7990 |
|
| LibXML_generic_variable_lookup, ctxt); |
| 7991 |
3 |
▶ | if (ctxt->varLookupData==NULL || ctxt->varLookupData != ctxt) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ctxt->varLookupData==NULL || ctxt->varLookupData != ctxt) { |
3 |
0 |
3 |
| if (ctxt->varLookupData==NULL || ctxt->varLookupData != ctxt) { |
0 |
3 |
3 |
|
| 7992 |
0 |
| croak( "XPathContext: registration failure\n" ); |
| 7993 |
|
| } |
| 7994 |
|
| } else { |
| 7995 |
0 |
| croak("XPathContext: 1st argument is not a CODE reference\n"); |
| 7996 |
|
| } |
| 7997 |
|
| } else { |
| 7998 |
|
| /* unregister */ |
| 7999 |
1 |
| xmlXPathRegisterVariableLookup(ctxt, NULL, NULL); |
| 8000 |
|
| } |
| 8001 |
|
| |
| 8002 |
|
| void |
| 8003 |
|
| registerFunctionNS( pxpath_context, name, uri, func) |
| 8004 |
|
| SV * pxpath_context |
| 8005 |
|
| char * name |
| 8006 |
|
| SV * uri |
| 8007 |
|
| SV * func |
| 8008 |
|
| PREINIT: |
| 8009 |
18 |
| xmlXPathContextPtr ctxt = NULL; |
| 8010 |
|
| SV * pfdr; |
| 8011 |
|
| SV * key; |
| 8012 |
|
| STRLEN len; |
| 8013 |
|
| char *strkey; |
| 8014 |
|
| |
| 8015 |
|
| INIT: |
| 8016 |
18 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 8017 |
18 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
18 |
18 |
|
| 8018 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 8019 |
|
| } |
| 8020 |
18 |
| LibXML_configure_xpathcontext(ctxt); |
| 8021 |
18 |
▶ | if ( !SvOK(func) || |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !SvOK(func) || |
13 |
5 |
18 |
|
| 8022 |
13 |
▶ | (SvOK(func) && ((SvROK(func) && SvTYPE(SvRV(func)) == SVt_PVCV ) |
Branch: 3 branches
| Branch | True | False | Total |
| (SvOK(func) && ((SvROK(func) && SvTYPE(SvRV(func)) == SVt_PVCV ) |
13 |
0 |
13 |
| (SvOK(func) && ((SvROK(func) && SvTYPE(SvRV(func)) == SVt_PVCV ) |
12 |
1 |
13 |
| (SvOK(func) && ((SvROK(func) && SvTYPE(SvRV(func)) == SVt_PVCV ) |
0 |
12 |
12 |
|
| 8023 |
1 |
▶ | || SvPOK(func)))) { |
Branch: 1 branch
| Branch | True | False | Total |
| || SvPOK(func)))) { |
1 |
0 |
1 |
|
| 8024 |
18 |
▶ | if (ctxt->funcLookupData == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt->funcLookupData == NULL) { |
3 |
15 |
18 |
|
| 8025 |
3 |
▶ | if (SvOK(func)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(func)) { |
3 |
0 |
3 |
|
| 8026 |
3 |
| pfdr = newRV_noinc((SV*) newHV()); |
| 8027 |
3 |
| ctxt->funcLookupData = pfdr; |
| 8028 |
|
| } else { |
| 8029 |
|
| /* looks like no perl function was never registered, */ |
| 8030 |
|
| /* nothing to unregister */ |
| 8031 |
0 |
| warn("XPathContext: nothing to unregister\n"); |
| 8032 |
0 |
| return; |
| 8033 |
|
| } |
| 8034 |
|
| } else { |
| 8035 |
15 |
▶ | if (SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) { |
15 |
0 |
15 |
|
| 8036 |
|
| /* good, it's a HV */ |
| 8037 |
15 |
| pfdr = (SV *)ctxt->funcLookupData; |
| 8038 |
|
| } else { |
| 8039 |
0 |
| croak ("XPathContext: cannot register: funcLookupData structure occupied\n"); |
| 8040 |
|
| } |
| 8041 |
|
| } |
| 8042 |
18 |
| key = newSVpvn("",0); |
| 8043 |
18 |
▶ | if (SvOK(uri)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(uri)) { |
2 |
16 |
18 |
|
| 8044 |
2 |
| sv_catpv(key, "{"); |
| 8045 |
2 |
| sv_catsv(key, uri); |
| 8046 |
2 |
| sv_catpv(key, "}"); |
| 8047 |
|
| } |
| 8048 |
18 |
| sv_catpv(key, (const char*)name); |
| 8049 |
18 |
| strkey = SvPV(key, len); |
| 8050 |
|
| /* warn("Trying to store function '%s' in %d\n", strkey, pfdr); */ |
| 8051 |
18 |
▶ | if (SvOK(func)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(func)) { |
13 |
5 |
18 |
|
| 8052 |
13 |
| (void) hv_store((HV *)SvRV(pfdr),strkey, len, newSVsv(func), 0); |
| 8053 |
|
| } else { |
| 8054 |
|
| /* unregister */ |
| 8055 |
5 |
| (void) hv_delete((HV *)SvRV(pfdr),strkey, len, G_DISCARD); |
| 8056 |
|
| } |
| 8057 |
18 |
| SvREFCNT_dec(key); |
| 8058 |
|
| } else { |
| 8059 |
0 |
| croak("XPathContext: 3rd argument is not a CODE reference or function name\n"); |
| 8060 |
|
| } |
| 8061 |
|
| PPCODE: |
| 8062 |
18 |
▶ | if (SvOK(uri)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(uri)) { |
2 |
16 |
18 |
|
| 8063 |
2 |
| xmlXPathRegisterFuncNS(ctxt, (xmlChar *) name, |
| 8064 |
2 |
| (xmlChar *) SvPV(uri, len), |
| 8065 |
2 |
▶ | (SvOK(func) ? |
Branch: 1 branch
| Branch | True | False | Total |
| (SvOK(func) ? |
1 |
1 |
2 |
|
| 8066 |
|
| LibXML_generic_extension_function : NULL)); |
| 8067 |
|
| } else { |
| 8068 |
16 |
| xmlXPathRegisterFunc(ctxt, (xmlChar *) name, |
| 8069 |
16 |
▶ | (SvOK(func) ? |
Branch: 1 branch
| Branch | True | False | Total |
| (SvOK(func) ? |
12 |
4 |
16 |
|
| 8070 |
|
| LibXML_generic_extension_function : NULL)); |
| 8071 |
|
| } |
| 8072 |
|
| |
| 8073 |
|
| void |
| 8074 |
|
| _free_node_pool( pxpath_context ) |
| 8075 |
|
| SV * pxpath_context |
| 8076 |
|
| PREINIT: |
| 8077 |
130 |
| xmlXPathContextPtr ctxt = NULL; |
| 8078 |
|
| INIT: |
| 8079 |
130 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 8080 |
130 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
130 |
130 |
|
| 8081 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 8082 |
|
| } |
| 8083 |
|
| PPCODE: |
| 8084 |
130 |
▶ | if (XPathContextDATA(ctxt)->pool != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (XPathContextDATA(ctxt)->pool != NULL) { |
20 |
110 |
130 |
|
| 8085 |
20 |
| SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); |
| 8086 |
20 |
| XPathContextDATA(ctxt)->pool = NULL; |
| 8087 |
|
| } |
| 8088 |
|
| |
| 8089 |
|
| void |
| 8090 |
|
| _findnodes( pxpath_context, perl_xpath ) |
| 8091 |
|
| SV * pxpath_context |
| 8092 |
|
| SV * perl_xpath |
| 8093 |
|
| PREINIT: |
| 8094 |
61 |
| xmlXPathContextPtr ctxt = NULL; |
| 8095 |
61 |
| ProxyNodePtr owner = NULL; |
| 8096 |
61 |
| xmlXPathObjectPtr found = NULL; |
| 8097 |
61 |
| xmlNodeSetPtr nodelist = NULL; |
| 8098 |
61 |
| SV * element = NULL ; |
| 8099 |
61 |
| xmlChar * xpath = NULL; |
| 8100 |
61 |
| xmlXPathCompExprPtr comp = NULL; |
| 8101 |
61 |
| PREINIT_SAVED_ERROR |
| 8102 |
|
| INIT: |
| 8103 |
61 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 8104 |
61 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
61 |
61 |
|
| 8105 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 8106 |
|
| } |
| 8107 |
61 |
| LibXML_configure_xpathcontext(ctxt); |
| 8108 |
61 |
▶ | if ( ctxt->node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt->node == NULL ) { |
0 |
61 |
61 |
|
| 8109 |
0 |
| croak("XPathContext: lost current node\n"); |
| 8110 |
|
| } |
| 8111 |
61 |
▶ | if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
4 |
57 |
61 |
| if (sv_isobject(perl_xpath) && sv_isa(perl_xpath,"XML::LibXML::XPathExpression")) { |
4 |
0 |
4 |
|
| 8112 |
4 |
| comp = INT2PTR(xmlXPathCompExprPtr,SvIV((SV*)SvRV( perl_xpath ))); |
| 8113 |
4 |
▶ | if (!comp) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!comp) XSRETURN_UNDEF; |
0 |
4 |
4 |
|
| 8114 |
|
| } else { |
| 8115 |
57 |
| xpath = nodeSv2C(perl_xpath, ctxt->node); |
| 8116 |
57 |
▶ | if ( !(xpath && xmlStrlen(xpath)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
57 |
0 |
57 |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
0 |
57 |
57 |
|
| 8117 |
0 |
▶ | if ( xpath ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath ) |
0 |
0 |
0 |
|
| 8118 |
0 |
| xmlFree(xpath); |
| 8119 |
0 |
| croak("XPathContext: empty XPath found\n"); |
| 8120 |
|
| XSRETURN_UNDEF; |
| 8121 |
|
| } |
| 8122 |
|
| } |
| 8123 |
|
| PPCODE: |
| 8124 |
61 |
| INIT_ERROR_HANDLER; |
| 8125 |
|
| |
| 8126 |
61 |
| PUTBACK ; |
| 8127 |
61 |
▶ | if (comp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (comp) { |
4 |
57 |
61 |
|
| 8128 |
4 |
| found = domXPathCompFindCtxt( ctxt, comp, 0 ); |
| 8129 |
|
| } else { |
| 8130 |
57 |
| found = domXPathFindCtxt( ctxt, xpath, 0 ); |
| 8131 |
57 |
| xmlFree(xpath); |
| 8132 |
|
| } |
| 8133 |
61 |
| SPAGAIN ; |
| 8134 |
|
| |
| 8135 |
61 |
▶ | if (found != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (found != NULL) { |
59 |
2 |
61 |
|
| 8136 |
59 |
| nodelist = found->nodesetval; |
| 8137 |
|
| } else { |
| 8138 |
2 |
| nodelist = NULL; |
| 8139 |
|
| } |
| 8140 |
61 |
| CLEANUP_ERROR_HANDLER; |
| 8141 |
61 |
▶ | if ( nodelist ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist ) { |
59 |
2 |
61 |
|
| 8142 |
59 |
| REPORT_ERROR(1); |
| 8143 |
59 |
▶ | if ( nodelist->nodeNr > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist->nodeNr > 0 ) { |
59 |
0 |
59 |
|
| 8144 |
|
| int i; |
| 8145 |
59 |
| const char * cls = "XML::LibXML::Node"; |
| 8146 |
|
| xmlNodePtr tnode; |
| 8147 |
59 |
| int l = nodelist->nodeNr; |
| 8148 |
3135 |
▶ | for( i = 0 ; i < l; i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( i = 0 ; i < l; i++){ |
3076 |
59 |
3135 |
|
| 8149 |
|
| /* we have to create a new instance of an objectptr. |
| 8150 |
|
| * and then place the current node into the new object. |
| 8151 |
|
| * afterwards we can push the object to the array! |
| 8152 |
|
| */ |
| 8153 |
3076 |
| element = NULL; |
| 8154 |
3076 |
| tnode = nodelist->nodeTab[i]; |
| 8155 |
3076 |
▶ | if (tnode->type == XML_NAMESPACE_DECL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->type == XML_NAMESPACE_DECL) { |
0 |
3076 |
3076 |
|
| 8156 |
0 |
| xmlNsPtr newns = xmlCopyNamespace((xmlNsPtr)tnode); |
| 8157 |
0 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
0 |
0 |
0 |
|
| 8158 |
0 |
| element = NEWSV(0,0); |
| 8159 |
0 |
| cls = PmmNodeTypeName( tnode ); |
| 8160 |
0 |
| element = sv_setref_pv( element, |
| 8161 |
|
| (const char *)cls, |
| 8162 |
|
| newns |
| 8163 |
|
| ); |
| 8164 |
|
| } |
| 8165 |
|
| else { |
| 8166 |
0 |
| continue; |
| 8167 |
|
| } |
| 8168 |
|
| } |
| 8169 |
|
| else { |
| 8170 |
3076 |
▶ | if (tnode->doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->doc) { |
3073 |
3 |
3076 |
|
| 8171 |
3073 |
▶ | owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
3073 |
0 |
3073 |
| owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
0 |
3073 |
3073 |
|
| 8172 |
|
| } else { |
| 8173 |
|
| /* we try to find a known node on the ancestor axis */ |
| 8174 |
3 |
| xmlNodePtr n = tnode; |
| 8175 |
5 |
▶ | while (n && n->_private == NULL) n = n->parent; |
Branch: 2 branches
| Branch | True | False | Total |
| while (n && n->_private == NULL) n = n->parent; |
5 |
0 |
5 |
| while (n && n->_private == NULL) n = n->parent; |
2 |
3 |
5 |
|
| 8176 |
3 |
▶ | if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
Branch: 3 branches
| Branch | True | False | Total |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
3 |
0 |
3 |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
3 |
0 |
3 |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
3 |
0 |
3 |
|
| 8177 |
0 |
| else owner = NULL; /* self contained node */ |
| 8178 |
|
| } |
| 8179 |
3076 |
| element = PmmNodeToSv(tnode, owner); |
| 8180 |
|
| } |
| 8181 |
3076 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
3076 |
3076 |
|
| 8182 |
|
| } |
| 8183 |
|
| } |
| 8184 |
|
| /* prevent libxml2 from freeing the actual nodes */ |
| 8185 |
59 |
▶ | if (found->boolval) found->boolval=0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (found->boolval) found->boolval=0; |
0 |
59 |
59 |
|
| 8186 |
59 |
| xmlXPathFreeObject(found); |
| 8187 |
|
| } |
| 8188 |
|
| else { |
| 8189 |
2 |
| xmlXPathFreeObject(found); |
| 8190 |
2 |
| REPORT_ERROR(0); |
| 8191 |
|
| } |
| 8192 |
|
| |
| 8193 |
|
| void |
| 8194 |
|
| _find( pxpath_context, pxpath, to_bool ) |
| 8195 |
|
| SV * pxpath_context |
| 8196 |
|
| SV * pxpath |
| 8197 |
|
| int to_bool |
| 8198 |
|
| PREINIT: |
| 8199 |
69 |
| xmlXPathContextPtr ctxt = NULL; |
| 8200 |
69 |
| ProxyNodePtr owner = NULL; |
| 8201 |
69 |
| xmlXPathObjectPtr found = NULL; |
| 8202 |
69 |
| xmlNodeSetPtr nodelist = NULL; |
| 8203 |
69 |
| xmlChar * xpath = NULL; |
| 8204 |
69 |
| xmlXPathCompExprPtr comp = NULL; |
| 8205 |
69 |
| PREINIT_SAVED_ERROR |
| 8206 |
|
| INIT: |
| 8207 |
69 |
| ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(pxpath_context))); |
| 8208 |
69 |
▶ | if ( ctxt == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt == NULL ) { |
0 |
69 |
69 |
|
| 8209 |
0 |
| croak("XPathContext: missing xpath context\n"); |
| 8210 |
|
| } |
| 8211 |
69 |
| LibXML_configure_xpathcontext(ctxt); |
| 8212 |
69 |
▶ | if ( ctxt->node == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ctxt->node == NULL ) { |
1 |
68 |
69 |
|
| 8213 |
1 |
| croak("XPathContext: lost current node\n"); |
| 8214 |
|
| } |
| 8215 |
68 |
▶ | if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
3 |
65 |
68 |
| if (sv_isobject(pxpath) && sv_isa(pxpath,"XML::LibXML::XPathExpression")) { |
3 |
0 |
3 |
|
| 8216 |
3 |
| comp = INT2PTR(xmlXPathCompExprPtr,SvIV((SV*)SvRV( pxpath ))); |
| 8217 |
3 |
▶ | if (!comp) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!comp) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 8218 |
|
| } else { |
| 8219 |
65 |
| xpath = nodeSv2C(pxpath, ctxt->node); |
| 8220 |
65 |
▶ | if ( !(xpath && xmlStrlen(xpath)) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
65 |
0 |
65 |
| if ( !(xpath && xmlStrlen(xpath)) ) { |
0 |
65 |
65 |
|
| 8221 |
0 |
▶ | if ( xpath ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xpath ) |
0 |
0 |
0 |
|
| 8222 |
0 |
| xmlFree(xpath); |
| 8223 |
0 |
| croak("XPathContext: empty XPath found\n"); |
| 8224 |
|
| XSRETURN_UNDEF; |
| 8225 |
|
| } |
| 8226 |
|
| } |
| 8227 |
|
| PPCODE: |
| 8228 |
68 |
| INIT_ERROR_HANDLER; |
| 8229 |
68 |
| PUTBACK ; |
| 8230 |
68 |
▶ | if (comp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (comp) { |
3 |
65 |
68 |
|
| 8231 |
3 |
| found = domXPathCompFindCtxt( ctxt, comp, to_bool ); |
| 8232 |
|
| } else { |
| 8233 |
65 |
| found = domXPathFindCtxt( ctxt, xpath, to_bool ); |
| 8234 |
64 |
| xmlFree(xpath); |
| 8235 |
|
| } |
| 8236 |
67 |
| SPAGAIN ; |
| 8237 |
67 |
| CLEANUP_ERROR_HANDLER; |
| 8238 |
67 |
▶ | if (found) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (found) { |
59 |
8 |
67 |
|
| 8239 |
59 |
| REPORT_ERROR(1); |
| 8240 |
59 |
| switch (found->type) { |
| 8241 |
10 |
| case XPATH_NODESET: |
| 8242 |
|
| /* return as a NodeList */ |
| 8243 |
|
| /* access ->nodesetval */ |
| 8244 |
10 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0))); |
0 |
10 |
10 |
|
| 8245 |
10 |
| nodelist = found->nodesetval; |
| 8246 |
10 |
▶ | if ( nodelist ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist ) { |
10 |
0 |
10 |
|
| 8247 |
10 |
▶ | if ( nodelist->nodeNr > 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( nodelist->nodeNr > 0 ) { |
10 |
0 |
10 |
|
| 8248 |
|
| int i; |
| 8249 |
10 |
| const char * cls = "XML::LibXML::Node"; |
| 8250 |
|
| xmlNodePtr tnode; |
| 8251 |
|
| SV * element; |
| 8252 |
10 |
| int l = nodelist->nodeNr; |
| 8253 |
|
| |
| 8254 |
6021 |
▶ | for( i = 0 ; i < l; i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( i = 0 ; i < l; i++){ |
6011 |
10 |
6021 |
|
| 8255 |
|
| /* we have to create a new instance of an |
| 8256 |
|
| * objectptr. and then |
| 8257 |
|
| * place the current node into the new |
| 8258 |
|
| * object. afterwards we can |
| 8259 |
|
| * push the object to the array! |
| 8260 |
|
| */ |
| 8261 |
6011 |
| tnode = nodelist->nodeTab[i]; |
| 8262 |
|
| |
| 8263 |
|
| /* let's be paranoid */ |
| 8264 |
6011 |
▶ | if (tnode->type == XML_NAMESPACE_DECL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->type == XML_NAMESPACE_DECL) { |
0 |
6011 |
6011 |
|
| 8265 |
0 |
| xmlNsPtr newns = xmlCopyNamespace((xmlNsPtr)tnode); |
| 8266 |
0 |
▶ | if ( newns != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( newns != NULL ) { |
0 |
0 |
0 |
|
| 8267 |
0 |
| element = NEWSV(0,0); |
| 8268 |
0 |
| cls = PmmNodeTypeName( tnode ); |
| 8269 |
0 |
| element = sv_setref_pv( element, |
| 8270 |
|
| (const char *)cls, |
| 8271 |
|
| (void*)newns |
| 8272 |
|
| ); |
| 8273 |
|
| } |
| 8274 |
|
| else { |
| 8275 |
0 |
| continue; |
| 8276 |
|
| } |
| 8277 |
|
| } |
| 8278 |
|
| else { |
| 8279 |
6011 |
▶ | if (tnode->doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (tnode->doc) { |
6011 |
0 |
6011 |
|
| 8280 |
6011 |
▶ | owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
Branch: 2 branches
| Branch | True | False | Total |
| owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
6011 |
0 |
6011 |
| owner = PmmOWNERPO(PmmNewNode((xmlNodePtr) tnode->doc)); |
0 |
6011 |
6011 |
|
| 8281 |
|
| } else { |
| 8282 |
|
| /* we try to find a known node on the ancestor axis */ |
| 8283 |
0 |
| xmlNodePtr n = tnode; |
| 8284 |
0 |
▶ | while (n && n->_private == NULL) n = n->parent; |
Branch: 2 branches
| Branch | True | False | Total |
| while (n && n->_private == NULL) n = n->parent; |
0 |
0 |
0 |
| while (n && n->_private == NULL) n = n->parent; |
0 |
0 |
0 |
|
| 8285 |
0 |
▶ | if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
Branch: 3 branches
| Branch | True | False | Total |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
0 |
0 |
0 |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
0 |
0 |
0 |
| if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); |
0 |
0 |
0 |
|
| 8286 |
0 |
| else owner = NULL; /* self contained node */ |
| 8287 |
|
| } |
| 8288 |
6011 |
| element = PmmNodeToSv(tnode, owner); |
| 8289 |
|
| } |
| 8290 |
6011 |
▶ | XPUSHs( sv_2mortal(element) ); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs( sv_2mortal(element) ); |
0 |
6011 |
6011 |
|
| 8291 |
|
| } |
| 8292 |
|
| } |
| 8293 |
|
| } |
| 8294 |
|
| /* prevent libxml2 from freeing the actual nodes */ |
| 8295 |
10 |
▶ | if (found->boolval) found->boolval=0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (found->boolval) found->boolval=0; |
0 |
10 |
10 |
|
| 8296 |
10 |
| break; |
| 8297 |
14 |
| case XPATH_BOOLEAN: |
| 8298 |
|
| /* return as a Boolean */ |
| 8299 |
|
| /* access ->boolval */ |
| 8300 |
14 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Boolean", 0))); |
0 |
14 |
14 |
|
| 8301 |
14 |
▶ | XPUSHs(sv_2mortal(newSViv(found->boolval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSViv(found->boolval))); |
0 |
14 |
14 |
|
| 8302 |
14 |
| break; |
| 8303 |
24 |
| case XPATH_NUMBER: |
| 8304 |
|
| /* return as a Number */ |
| 8305 |
|
| /* access ->floatval */ |
| 8306 |
24 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Number", 0))); |
0 |
24 |
24 |
|
| 8307 |
24 |
▶ | XPUSHs(sv_2mortal(newSVnv(found->floatval))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVnv(found->floatval))); |
0 |
24 |
24 |
|
| 8308 |
24 |
| break; |
| 8309 |
11 |
| case XPATH_STRING: |
| 8310 |
|
| /* access ->stringval */ |
| 8311 |
|
| /* return as a Literal */ |
| 8312 |
11 |
▶ | XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv("XML::LibXML::Literal", 0))); |
0 |
11 |
11 |
|
| 8313 |
11 |
▶ | XPUSHs(sv_2mortal(C2Sv(found->stringval, NULL))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(C2Sv(found->stringval, NULL))); |
0 |
11 |
11 |
|
| 8314 |
11 |
| break; |
| 8315 |
0 |
| default: |
| 8316 |
0 |
| xmlXPathFreeObject(found); |
| 8317 |
0 |
| croak("Unknown XPath return type"); |
| 8318 |
|
| } |
| 8319 |
59 |
| xmlXPathFreeObject(found); |
| 8320 |
|
| } |
| 8321 |
|
| else { |
| 8322 |
8 |
| REPORT_ERROR(0); |
| 8323 |
|
| } |
| 8324 |
|
| |
| 8325 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::InputCallback |
| 8326 |
|
| |
| 8327 |
|
| void |
| 8328 |
|
| lib_cleanup_callbacks( self ) |
| 8329 |
|
| CODE: |
| 8330 |
712 |
| xmlCleanupInputCallbacks(); |
| 8331 |
712 |
| xmlRegisterDefaultInputCallbacks(); |
| 8332 |
|
| |
| 8333 |
|
| void |
| 8334 |
|
| lib_init_callbacks( self ) |
| 8335 |
|
| CODE: |
| 8336 |
712 |
| xmlRegisterDefaultInputCallbacks(); /* important */ |
| 8337 |
712 |
| xmlRegisterInputCallbacks((xmlInputMatchCallback) LibXML_input_match, |
| 8338 |
|
| (xmlInputOpenCallback) LibXML_input_open, |
| 8339 |
|
| (xmlInputReadCallback) LibXML_input_read, |
| 8340 |
|
| (xmlInputCloseCallback) LibXML_input_close); |
| 8341 |
|
| |
| 8342 |
|
| #ifdef HAVE_READER_SUPPORT |
| 8343 |
|
| |
| 8344 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Reader |
| 8345 |
|
| |
| 8346 |
|
| xmlTextReaderPtr |
| 8347 |
|
| _newForFile(CLASS, filename, encoding, options) |
| 8348 |
|
| const char* CLASS |
| 8349 |
|
| const char* filename |
| 8350 |
|
| const char * encoding = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8351 |
|
| int options = SvOK($arg) ? SvIV($arg) : 0; |
| 8352 |
|
| CODE: |
| 8353 |
9 |
| RETVAL = xmlReaderForFile(filename, encoding, options); |
| 8354 |
|
| INIT_READER_ERROR_HANDLER(RETVAL); |
| 8355 |
|
| OUTPUT: |
| 8356 |
|
| RETVAL |
| 8357 |
|
| |
| 8358 |
|
| xmlTextReaderPtr |
| 8359 |
|
| _newForIO(CLASS, fh, url, encoding, options) |
| 8360 |
|
| const char* CLASS |
| 8361 |
|
| SV * fh |
| 8362 |
|
| const char * url = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8363 |
|
| const char * encoding = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8364 |
|
| int options = SvOK($arg) ? SvIV($arg) : 0; |
| 8365 |
|
| CODE: |
| 8366 |
1 |
| (void)SvREFCNT_inc(fh); /* _dec'd by LibXML_close_perl */ |
| 8367 |
1 |
| RETVAL = xmlReaderForIO((xmlInputReadCallback) LibXML_read_perl, |
| 8368 |
|
| (xmlInputCloseCallback) LibXML_close_perl, |
| 8369 |
|
| (void *) fh, url, encoding, options); |
| 8370 |
1 |
▶ | if (RETVAL == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL == NULL) { |
0 |
1 |
1 |
|
| 8371 |
0 |
| SvREFCNT_dec(fh); |
| 8372 |
|
| } |
| 8373 |
|
| INIT_READER_ERROR_HANDLER(RETVAL) |
| 8374 |
|
| OUTPUT: |
| 8375 |
|
| RETVAL |
| 8376 |
|
| |
| 8377 |
|
| xmlTextReaderPtr |
| 8378 |
|
| _newForString(CLASS, string, url, encoding, options) |
| 8379 |
|
| const char* CLASS |
| 8380 |
|
| SV * string |
| 8381 |
|
| const char * url = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8382 |
|
| const char * encoding = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8383 |
|
| int options = SvOK($arg) ? SvIV($arg) : 0; |
| 8384 |
|
| CODE: |
| 8385 |
19 |
▶ | if (encoding == NULL && SvUTF8( string )) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (encoding == NULL && SvUTF8( string )) { |
19 |
0 |
19 |
| if (encoding == NULL && SvUTF8( string )) { |
2 |
17 |
19 |
|
| 8386 |
2 |
| encoding = "UTF-8"; |
| 8387 |
|
| } |
| 8388 |
19 |
| RETVAL = xmlReaderForDoc((xmlChar* )SvPV_nolen(string), url, encoding, options); |
| 8389 |
|
| INIT_READER_ERROR_HANDLER(RETVAL) |
| 8390 |
|
| OUTPUT: |
| 8391 |
|
| RETVAL |
| 8392 |
|
| |
| 8393 |
|
| xmlTextReaderPtr |
| 8394 |
|
| _newForFd(CLASS, fd, url, encoding, options) |
| 8395 |
|
| const char* CLASS |
| 8396 |
|
| int fd |
| 8397 |
|
| const char * url = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8398 |
|
| const char * encoding = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8399 |
|
| int options = SvOK($arg) ? SvIV($arg) : 0; |
| 8400 |
|
| CODE: |
| 8401 |
1 |
| RETVAL = xmlReaderForFd(fd, url, encoding, options); |
| 8402 |
|
| INIT_READER_ERROR_HANDLER(RETVAL) |
| 8403 |
|
| OUTPUT: |
| 8404 |
|
| RETVAL |
| 8405 |
|
| |
| 8406 |
|
| xmlTextReaderPtr |
| 8407 |
|
| _newForDOM(CLASS, perl_doc) |
| 8408 |
|
| const char* CLASS |
| 8409 |
|
| SV * perl_doc |
| 8410 |
|
| CODE: |
| 8411 |
1 |
| PmmREFCNT_inc(SvPROXYNODE(perl_doc)); /* _dec in DESTROY */ |
| 8412 |
1 |
| RETVAL = xmlReaderWalker((xmlDocPtr) PmmSvNode(perl_doc)); |
| 8413 |
|
| OUTPUT: |
| 8414 |
|
| RETVAL |
| 8415 |
|
| |
| 8416 |
|
| int |
| 8417 |
|
| attributeCount(reader) |
| 8418 |
|
| xmlTextReaderPtr reader |
| 8419 |
|
| CODE: |
| 8420 |
1 |
| RETVAL = xmlTextReaderAttributeCount(reader); |
| 8421 |
|
| OUTPUT: |
| 8422 |
|
| RETVAL |
| 8423 |
|
| |
| 8424 |
|
| SV * |
| 8425 |
|
| baseURI(reader) |
| 8426 |
|
| xmlTextReaderPtr reader |
| 8427 |
|
| PREINIT: |
| 8428 |
1 |
| const xmlChar *result = NULL; |
| 8429 |
|
| CODE: |
| 8430 |
1 |
| result = xmlTextReaderConstBaseUri(reader); |
| 8431 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8432 |
|
| OUTPUT: |
| 8433 |
|
| RETVAL |
| 8434 |
|
| |
| 8435 |
|
| long |
| 8436 |
|
| byteConsumed(reader) |
| 8437 |
|
| xmlTextReaderPtr reader |
| 8438 |
|
| CODE: |
| 8439 |
1 |
| RETVAL = xmlTextReaderByteConsumed(reader); |
| 8440 |
|
| OUTPUT: |
| 8441 |
|
| RETVAL |
| 8442 |
|
| |
| 8443 |
|
| int |
| 8444 |
|
| _close(reader) |
| 8445 |
|
| xmlTextReaderPtr reader |
| 8446 |
|
| CODE: |
| 8447 |
1 |
| RETVAL = xmlTextReaderClose(reader); |
| 8448 |
|
| OUTPUT: |
| 8449 |
|
| RETVAL |
| 8450 |
|
| |
| 8451 |
|
| SV * |
| 8452 |
|
| encoding(reader) |
| 8453 |
|
| xmlTextReaderPtr reader |
| 8454 |
|
| PREINIT: |
| 8455 |
1 |
| const xmlChar *result = NULL; |
| 8456 |
|
| CODE: |
| 8457 |
1 |
| result = xmlTextReaderConstEncoding(reader); |
| 8458 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8459 |
|
| OUTPUT: |
| 8460 |
|
| RETVAL |
| 8461 |
|
| |
| 8462 |
|
| SV * |
| 8463 |
|
| localName(reader) |
| 8464 |
|
| xmlTextReaderPtr reader |
| 8465 |
|
| PREINIT: |
| 8466 |
2 |
| const xmlChar *result = NULL; |
| 8467 |
|
| CODE: |
| 8468 |
2 |
| result = xmlTextReaderConstLocalName(reader); |
| 8469 |
2 |
| RETVAL = C2Sv(result, NULL); |
| 8470 |
|
| OUTPUT: |
| 8471 |
|
| RETVAL |
| 8472 |
|
| |
| 8473 |
|
| SV * |
| 8474 |
|
| name(reader) |
| 8475 |
|
| xmlTextReaderPtr reader |
| 8476 |
|
| PREINIT: |
| 8477 |
76 |
| const xmlChar *result = NULL; |
| 8478 |
|
| CODE: |
| 8479 |
76 |
| result = xmlTextReaderConstName(reader); |
| 8480 |
76 |
| RETVAL = C2Sv(result, NULL); |
| 8481 |
|
| OUTPUT: |
| 8482 |
|
| RETVAL |
| 8483 |
|
| |
| 8484 |
|
| SV * |
| 8485 |
|
| namespaceURI(reader) |
| 8486 |
|
| xmlTextReaderPtr reader |
| 8487 |
|
| PREINIT: |
| 8488 |
36 |
| const xmlChar *result = NULL; |
| 8489 |
|
| CODE: |
| 8490 |
36 |
| result = xmlTextReaderConstNamespaceUri(reader); |
| 8491 |
36 |
| RETVAL = C2Sv(result, NULL); |
| 8492 |
|
| OUTPUT: |
| 8493 |
|
| RETVAL |
| 8494 |
|
| |
| 8495 |
|
| SV * |
| 8496 |
|
| prefix(reader) |
| 8497 |
|
| xmlTextReaderPtr reader |
| 8498 |
|
| PREINIT: |
| 8499 |
2 |
| const xmlChar *result = NULL; |
| 8500 |
|
| CODE: |
| 8501 |
2 |
| result = xmlTextReaderConstPrefix(reader); |
| 8502 |
2 |
| RETVAL = C2Sv(result, NULL); |
| 8503 |
|
| OUTPUT: |
| 8504 |
|
| RETVAL |
| 8505 |
|
| |
| 8506 |
|
| SV * |
| 8507 |
|
| value(reader) |
| 8508 |
|
| xmlTextReaderPtr reader |
| 8509 |
|
| PREINIT: |
| 8510 |
29 |
| const xmlChar *result = NULL; |
| 8511 |
|
| CODE: |
| 8512 |
29 |
| result = xmlTextReaderConstValue(reader); |
| 8513 |
29 |
| RETVAL = C2Sv(result, NULL); |
| 8514 |
|
| OUTPUT: |
| 8515 |
|
| RETVAL |
| 8516 |
|
| |
| 8517 |
|
| SV * |
| 8518 |
|
| xmlLang(reader) |
| 8519 |
|
| xmlTextReaderPtr reader |
| 8520 |
|
| PREINIT: |
| 8521 |
2 |
| const xmlChar *result = NULL; |
| 8522 |
|
| CODE: |
| 8523 |
2 |
| result = xmlTextReaderConstXmlLang(reader); |
| 8524 |
2 |
| RETVAL = C2Sv(result, NULL); |
| 8525 |
|
| OUTPUT: |
| 8526 |
|
| RETVAL |
| 8527 |
|
| |
| 8528 |
|
| |
| 8529 |
|
| SV * |
| 8530 |
|
| xmlVersion(reader) |
| 8531 |
|
| xmlTextReaderPtr reader |
| 8532 |
|
| PREINIT: |
| 8533 |
1 |
| const xmlChar *result = NULL; |
| 8534 |
|
| CODE: |
| 8535 |
1 |
| result = xmlTextReaderConstXmlVersion(reader); |
| 8536 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8537 |
|
| OUTPUT: |
| 8538 |
|
| RETVAL |
| 8539 |
|
| |
| 8540 |
|
| |
| 8541 |
|
| int |
| 8542 |
|
| depth(reader) |
| 8543 |
|
| xmlTextReaderPtr reader |
| 8544 |
|
| CODE: |
| 8545 |
1 |
| RETVAL = xmlTextReaderDepth(reader); |
| 8546 |
|
| OUTPUT: |
| 8547 |
|
| RETVAL |
| 8548 |
|
| |
| 8549 |
|
| |
| 8550 |
|
| SV * |
| 8551 |
|
| getAttribute(reader, name) |
| 8552 |
|
| xmlTextReaderPtr reader |
| 8553 |
|
| char * name |
| 8554 |
|
| PREINIT: |
| 8555 |
1 |
| xmlChar *result = NULL; |
| 8556 |
|
| CODE: |
| 8557 |
1 |
| result = xmlTextReaderGetAttribute(reader, (xmlChar*) name); |
| 8558 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8559 |
1 |
| xmlFree(result); |
| 8560 |
|
| OUTPUT: |
| 8561 |
|
| RETVAL |
| 8562 |
|
| |
| 8563 |
|
| SV * |
| 8564 |
|
| getAttributeNo(reader, no) |
| 8565 |
|
| xmlTextReaderPtr reader |
| 8566 |
|
| int no |
| 8567 |
|
| PREINIT: |
| 8568 |
1 |
| xmlChar *result = NULL; |
| 8569 |
|
| CODE: |
| 8570 |
1 |
| result = xmlTextReaderGetAttributeNo(reader, no); |
| 8571 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8572 |
1 |
| xmlFree(result); |
| 8573 |
|
| OUTPUT: |
| 8574 |
|
| RETVAL |
| 8575 |
|
| |
| 8576 |
|
| SV * |
| 8577 |
|
| getAttributeNs(reader, localName, namespaceURI) |
| 8578 |
|
| xmlTextReaderPtr reader |
| 8579 |
|
| char * localName |
| 8580 |
|
| char * namespaceURI = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8581 |
|
| PREINIT: |
| 8582 |
1 |
| xmlChar *result = NULL; |
| 8583 |
|
| CODE: |
| 8584 |
1 |
| result = xmlTextReaderGetAttributeNs(reader, (xmlChar*) localName, |
| 8585 |
|
| (xmlChar*) namespaceURI); |
| 8586 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8587 |
1 |
| xmlFree(result); |
| 8588 |
|
| OUTPUT: |
| 8589 |
|
| RETVAL |
| 8590 |
|
| |
| 8591 |
|
| int |
| 8592 |
|
| columnNumber(reader) |
| 8593 |
|
| xmlTextReaderPtr reader |
| 8594 |
|
| CODE: |
| 8595 |
1 |
| RETVAL = xmlTextReaderGetParserColumnNumber(reader); |
| 8596 |
|
| OUTPUT: |
| 8597 |
|
| RETVAL |
| 8598 |
|
| |
| 8599 |
|
| int |
| 8600 |
|
| lineNumber(reader) |
| 8601 |
|
| xmlTextReaderPtr reader |
| 8602 |
|
| CODE: |
| 8603 |
1 |
| RETVAL = xmlTextReaderGetParserLineNumber(reader); |
| 8604 |
|
| OUTPUT: |
| 8605 |
|
| RETVAL |
| 8606 |
|
| |
| 8607 |
|
| int |
| 8608 |
|
| _getParserProp(reader, prop) |
| 8609 |
|
| xmlTextReaderPtr reader |
| 8610 |
|
| int prop |
| 8611 |
|
| CODE: |
| 8612 |
1 |
| RETVAL = xmlTextReaderGetParserProp(reader, prop); |
| 8613 |
|
| OUTPUT: |
| 8614 |
|
| RETVAL |
| 8615 |
|
| |
| 8616 |
|
| int |
| 8617 |
|
| hasAttributes(reader) |
| 8618 |
|
| xmlTextReaderPtr reader |
| 8619 |
|
| CODE: |
| 8620 |
1 |
| RETVAL = xmlTextReaderHasAttributes(reader); |
| 8621 |
|
| OUTPUT: |
| 8622 |
|
| RETVAL |
| 8623 |
|
| |
| 8624 |
|
| int |
| 8625 |
|
| hasValue(reader) |
| 8626 |
|
| xmlTextReaderPtr reader |
| 8627 |
|
| CODE: |
| 8628 |
1 |
| RETVAL = xmlTextReaderHasValue(reader); |
| 8629 |
|
| OUTPUT: |
| 8630 |
|
| RETVAL |
| 8631 |
|
| |
| 8632 |
|
| SV* |
| 8633 |
|
| getAttributeHash(reader) |
| 8634 |
|
| xmlTextReaderPtr reader |
| 8635 |
|
| PREINIT: |
| 8636 |
|
| HV* hv; |
| 8637 |
|
| SV* sv; |
| 8638 |
|
| const xmlChar* name; |
| 8639 |
0 |
| PREINIT_SAVED_ERROR |
| 8640 |
|
| CODE: |
| 8641 |
0 |
| INIT_ERROR_HANDLER; |
| 8642 |
0 |
| hv=newHV(); |
| 8643 |
0 |
▶ | if (xmlTextReaderHasAttributes(reader) && xmlTextReaderMoveToFirstAttribute(reader)==1) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xmlTextReaderHasAttributes(reader) && xmlTextReaderMoveToFirstAttribute(reader)==1) { |
0 |
0 |
0 |
| if (xmlTextReaderHasAttributes(reader) && xmlTextReaderMoveToFirstAttribute(reader)==1) { |
0 |
0 |
0 |
|
| 8644 |
|
| do { |
| 8645 |
0 |
| name = xmlTextReaderConstName(reader); |
| 8646 |
0 |
| sv=C2Sv((xmlTextReaderConstValue(reader)),NULL); |
| 8647 |
0 |
▶ | if (sv && hv_store(hv, (const char*) name, xmlStrlen(name), sv, 0)==NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv && hv_store(hv, (const char*) name, xmlStrlen(name), sv, 0)==NULL) { |
0 |
0 |
0 |
| if (sv && hv_store(hv, (const char*) name, xmlStrlen(name), sv, 0)==NULL) { |
0 |
0 |
0 |
|
| 8648 |
0 |
| SvREFCNT_dec(sv); /* free if not needed by hv_stores */ |
| 8649 |
|
| } |
| 8650 |
0 |
▶ | } while (xmlTextReaderMoveToNextAttribute(reader)==1); |
Branch: 1 branch
| Branch | True | False | Total |
| } while (xmlTextReaderMoveToNextAttribute(reader)==1); |
0 |
0 |
0 |
|
| 8651 |
0 |
| xmlTextReaderMoveToElement(reader); |
| 8652 |
|
| } |
| 8653 |
0 |
| RETVAL=newRV_noinc((SV*)hv); |
| 8654 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 8655 |
0 |
| REPORT_ERROR(0); |
| 8656 |
|
| OUTPUT: |
| 8657 |
|
| RETVAL |
| 8658 |
|
| |
| 8659 |
|
| int |
| 8660 |
|
| isDefault(reader) |
| 8661 |
|
| xmlTextReaderPtr reader |
| 8662 |
|
| CODE: |
| 8663 |
1 |
| RETVAL = xmlTextReaderIsDefault(reader); |
| 8664 |
|
| OUTPUT: |
| 8665 |
|
| RETVAL |
| 8666 |
|
| |
| 8667 |
|
| int |
| 8668 |
|
| isEmptyElement(reader) |
| 8669 |
|
| xmlTextReaderPtr reader |
| 8670 |
|
| CODE: |
| 8671 |
1 |
| RETVAL = xmlTextReaderIsEmptyElement(reader); |
| 8672 |
|
| OUTPUT: |
| 8673 |
|
| RETVAL |
| 8674 |
|
| |
| 8675 |
|
| int |
| 8676 |
|
| isNamespaceDecl(reader) |
| 8677 |
|
| xmlTextReaderPtr reader |
| 8678 |
|
| CODE: |
| 8679 |
1 |
| RETVAL = xmlTextReaderIsNamespaceDecl(reader); |
| 8680 |
|
| OUTPUT: |
| 8681 |
|
| RETVAL |
| 8682 |
|
| |
| 8683 |
|
| int |
| 8684 |
|
| isValid(reader) |
| 8685 |
|
| xmlTextReaderPtr reader |
| 8686 |
|
| CODE: |
| 8687 |
1 |
| RETVAL = xmlTextReaderIsValid(reader); |
| 8688 |
|
| OUTPUT: |
| 8689 |
|
| RETVAL |
| 8690 |
|
| |
| 8691 |
|
| SV * |
| 8692 |
|
| lookupNamespace(reader, prefix) |
| 8693 |
|
| xmlTextReaderPtr reader |
| 8694 |
|
| char * prefix = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8695 |
|
| PREINIT: |
| 8696 |
1 |
| xmlChar *result = NULL; |
| 8697 |
|
| CODE: |
| 8698 |
1 |
| result = xmlTextReaderLookupNamespace(reader, (xmlChar*) prefix); |
| 8699 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8700 |
1 |
| xmlFree(result); |
| 8701 |
|
| OUTPUT: |
| 8702 |
|
| RETVAL |
| 8703 |
|
| |
| 8704 |
|
| |
| 8705 |
|
| int |
| 8706 |
|
| moveToAttribute(reader, name) |
| 8707 |
|
| xmlTextReaderPtr reader |
| 8708 |
|
| char * name |
| 8709 |
|
| CODE: |
| 8710 |
1 |
| RETVAL = xmlTextReaderMoveToAttribute(reader, (xmlChar*) name); |
| 8711 |
|
| OUTPUT: |
| 8712 |
|
| RETVAL |
| 8713 |
|
| |
| 8714 |
|
| int |
| 8715 |
|
| moveToAttributeNo(reader, no) |
| 8716 |
|
| xmlTextReaderPtr reader |
| 8717 |
|
| int no |
| 8718 |
|
| CODE: |
| 8719 |
1 |
| RETVAL = xmlTextReaderMoveToAttributeNo(reader, no); |
| 8720 |
|
| OUTPUT: |
| 8721 |
|
| RETVAL |
| 8722 |
|
| |
| 8723 |
|
| int |
| 8724 |
|
| moveToAttributeNs(reader, localName, namespaceURI) |
| 8725 |
|
| xmlTextReaderPtr reader |
| 8726 |
|
| char * localName |
| 8727 |
|
| char * namespaceURI = SvOK($arg) ? SvPV_nolen($arg) : NULL; |
| 8728 |
|
| CODE: |
| 8729 |
1 |
| RETVAL = xmlTextReaderMoveToAttributeNs(reader, |
| 8730 |
|
| (xmlChar*) localName, (xmlChar*) namespaceURI); |
| 8731 |
|
| OUTPUT: |
| 8732 |
|
| RETVAL |
| 8733 |
|
| |
| 8734 |
|
| int |
| 8735 |
|
| moveToElement(reader) |
| 8736 |
|
| xmlTextReaderPtr reader |
| 8737 |
|
| CODE: |
| 8738 |
2 |
| RETVAL = xmlTextReaderMoveToElement(reader); |
| 8739 |
|
| OUTPUT: |
| 8740 |
|
| RETVAL |
| 8741 |
|
| |
| 8742 |
|
| int |
| 8743 |
|
| moveToFirstAttribute(reader) |
| 8744 |
|
| xmlTextReaderPtr reader |
| 8745 |
|
| CODE: |
| 8746 |
1 |
| RETVAL = xmlTextReaderMoveToFirstAttribute(reader); |
| 8747 |
|
| OUTPUT: |
| 8748 |
|
| RETVAL |
| 8749 |
|
| |
| 8750 |
|
| int |
| 8751 |
|
| moveToNextAttribute(reader) |
| 8752 |
|
| xmlTextReaderPtr reader |
| 8753 |
|
| CODE: |
| 8754 |
1 |
| RETVAL = xmlTextReaderMoveToNextAttribute(reader); |
| 8755 |
|
| OUTPUT: |
| 8756 |
|
| RETVAL |
| 8757 |
|
| |
| 8758 |
|
| int |
| 8759 |
|
| next(reader) |
| 8760 |
|
| xmlTextReaderPtr reader |
| 8761 |
|
| PREINIT: |
| 8762 |
1 |
| PREINIT_SAVED_ERROR |
| 8763 |
|
| CODE: |
| 8764 |
1 |
| INIT_ERROR_HANDLER; |
| 8765 |
1 |
| RETVAL = xmlTextReaderNext(reader); |
| 8766 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 8767 |
1 |
| REPORT_ERROR(0); |
| 8768 |
|
| OUTPUT: |
| 8769 |
|
| RETVAL |
| 8770 |
|
| |
| 8771 |
|
| #define LIBXML_READER_NEXT_SIBLING(ret,reader) \ |
| 8772 |
|
| ret = xmlTextReaderNextSibling(reader); \ |
| 8773 |
|
| if (ret == -1) \ |
| 8774 |
|
| { \ |
| 8775 |
|
| int depth; \ |
| 8776 |
|
| depth = xmlTextReaderDepth(reader); \ |
| 8777 |
|
| ret = xmlTextReaderRead(reader); \ |
| 8778 |
|
| while (ret == 1 && xmlTextReaderDepth(reader) > depth) { \ |
| 8779 |
|
| ret = xmlTextReaderNext(reader); \ |
| 8780 |
|
| } \ |
| 8781 |
|
| if (ret == 1) { \ |
| 8782 |
|
| if (xmlTextReaderDepth(reader) != depth) { \ |
| 8783 |
|
| ret = 0; \ |
| 8784 |
|
| } else if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { \ |
| 8785 |
|
| ret = xmlTextReaderRead(reader); \ |
| 8786 |
|
| } \ |
| 8787 |
|
| } \ |
| 8788 |
|
| } |
| 8789 |
|
| |
| 8790 |
|
| int |
| 8791 |
|
| nextSibling(reader) |
| 8792 |
|
| xmlTextReaderPtr reader |
| 8793 |
|
| PREINIT: |
| 8794 |
2 |
| PREINIT_SAVED_ERROR |
| 8795 |
|
| CODE: |
| 8796 |
2 |
| INIT_ERROR_HANDLER; |
| 8797 |
10 |
▶ | LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
Branch: 6 branches
| Branch | True | False | Total |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
2 |
0 |
2 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
10 |
0 |
10 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
8 |
2 |
10 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
2 |
0 |
2 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
0 |
2 |
2 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
2 |
0 |
2 |
|
| 8798 |
2 |
| CLEANUP_ERROR_HANDLER; |
| 8799 |
2 |
| REPORT_ERROR(0); |
| 8800 |
|
| OUTPUT: |
| 8801 |
|
| RETVAL |
| 8802 |
|
| |
| 8803 |
|
| int |
| 8804 |
|
| nextSiblingElement(reader, name = NULL, nsURI = NULL) |
| 8805 |
|
| xmlTextReaderPtr reader |
| 8806 |
|
| const char * name |
| 8807 |
|
| const char * nsURI |
| 8808 |
|
| PREINIT: |
| 8809 |
1 |
| PREINIT_SAVED_ERROR |
| 8810 |
|
| CODE: |
| 8811 |
1 |
| INIT_ERROR_HANDLER; |
| 8812 |
|
| do { |
| 8813 |
10 |
▶ | LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
Branch: 6 branches
| Branch | True | False | Total |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
6 |
0 |
6 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
10 |
0 |
10 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
4 |
6 |
10 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
6 |
0 |
6 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
0 |
6 |
6 |
| LIBXML_READER_NEXT_SIBLING(RETVAL,reader) |
1 |
5 |
6 |
|
| 8814 |
6 |
▶ | if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
Branch: 9 branches
| Branch | True | False | Total |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
3 |
3 |
6 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
3 |
3 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
3 |
3 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
3 |
0 |
3 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
1 |
2 |
3 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
1 |
0 |
1 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
1 |
1 |
|
| 8815 |
|
| break; |
| 8816 |
|
| } |
| 8817 |
5 |
▶ | } while (RETVAL == 1); |
Branch: 1 branch
| Branch | True | False | Total |
| } while (RETVAL == 1); |
5 |
0 |
5 |
|
| 8818 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 8819 |
1 |
| REPORT_ERROR(0); |
| 8820 |
|
| OUTPUT: |
| 8821 |
|
| RETVAL |
| 8822 |
|
| |
| 8823 |
|
| int |
| 8824 |
|
| nextElement(reader, name = NULL, nsURI = NULL) |
| 8825 |
|
| xmlTextReaderPtr reader |
| 8826 |
|
| const char * name |
| 8827 |
|
| const char * nsURI |
| 8828 |
|
| PREINIT: |
| 8829 |
6 |
| PREINIT_SAVED_ERROR |
| 8830 |
|
| CODE: |
| 8831 |
6 |
| INIT_ERROR_HANDLER; |
| 8832 |
|
| do { |
| 8833 |
10 |
| RETVAL = xmlTextReaderRead(reader); |
| 8834 |
10 |
▶ | if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
Branch: 9 branches
| Branch | True | False | Total |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
6 |
4 |
10 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
6 |
0 |
6 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
1 |
5 |
6 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
1 |
0 |
1 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
1 |
1 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
| if (LIBXML_READER_TEST_ELEMENT(reader,name,nsURI)) { |
0 |
0 |
0 |
|
| 8835 |
|
| break; |
| 8836 |
|
| } |
| 8837 |
4 |
▶ | } while (RETVAL == 1); |
Branch: 1 branch
| Branch | True | False | Total |
| } while (RETVAL == 1); |
4 |
0 |
4 |
|
| 8838 |
6 |
| CLEANUP_ERROR_HANDLER; |
| 8839 |
6 |
| REPORT_ERROR(0); |
| 8840 |
|
| OUTPUT: |
| 8841 |
|
| RETVAL |
| 8842 |
|
| |
| 8843 |
|
| int |
| 8844 |
|
| nextPatternMatch(reader, compiled) |
| 8845 |
|
| xmlTextReaderPtr reader |
| 8846 |
|
| xmlPatternPtr compiled |
| 8847 |
|
| PREINIT: |
| 8848 |
5 |
| PREINIT_SAVED_ERROR |
| 8849 |
5 |
▶ | xmlNodePtr node = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNodePtr node = NULL; |
5 |
0 |
5 |
|
| 8850 |
|
| CODE: |
| 8851 |
5 |
▶ | if ( compiled == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( compiled == NULL ) |
0 |
5 |
5 |
|
| 8852 |
0 |
| croak("Usage: $reader->nextPatternMatch( a-XML::LibXML::Pattern-object )"); |
| 8853 |
|
| do { |
| 8854 |
42 |
| RETVAL = xmlTextReaderRead(reader); |
| 8855 |
42 |
| node = xmlTextReaderCurrentNode(reader); |
| 8856 |
42 |
▶ | if (node && xmlPatternMatch(compiled, node)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (node && xmlPatternMatch(compiled, node)) { |
41 |
1 |
42 |
| if (node && xmlPatternMatch(compiled, node)) { |
4 |
37 |
41 |
|
| 8857 |
4 |
| break; |
| 8858 |
|
| } |
| 8859 |
38 |
▶ | } while (RETVAL == 1); |
Branch: 1 branch
| Branch | True | False | Total |
| } while (RETVAL == 1); |
37 |
1 |
38 |
|
| 8860 |
5 |
| CLEANUP_ERROR_HANDLER; |
| 8861 |
5 |
| REPORT_ERROR(0); |
| 8862 |
|
| OUTPUT: |
| 8863 |
|
| RETVAL |
| 8864 |
|
| |
| 8865 |
|
| int |
| 8866 |
|
| skipSiblings(reader) |
| 8867 |
|
| xmlTextReaderPtr reader |
| 8868 |
|
| PREINIT: |
| 8869 |
|
| int depth; |
| 8870 |
|
| PREINIT: |
| 8871 |
1 |
| PREINIT_SAVED_ERROR |
| 8872 |
|
| CODE: |
| 8873 |
1 |
| INIT_ERROR_HANDLER; |
| 8874 |
1 |
| depth = xmlTextReaderDepth(reader); |
| 8875 |
1 |
| RETVAL = -1; |
| 8876 |
1 |
▶ | if (depth > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (depth > 0) { |
1 |
0 |
1 |
|
| 8877 |
|
| do { |
| 8878 |
3 |
| RETVAL = xmlTextReaderNext(reader); |
| 8879 |
3 |
▶ | } while (RETVAL == 1 && xmlTextReaderDepth(reader) >= depth); |
Branch: 2 branches
| Branch | True | False | Total |
| } while (RETVAL == 1 && xmlTextReaderDepth(reader) >= depth); |
3 |
0 |
3 |
| } while (RETVAL == 1 && xmlTextReaderDepth(reader) >= depth); |
2 |
1 |
3 |
|
| 8880 |
1 |
▶ | if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) { |
0 |
1 |
1 |
|
| 8881 |
0 |
| RETVAL = -1; |
| 8882 |
|
| } |
| 8883 |
|
| } |
| 8884 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 8885 |
1 |
| REPORT_ERROR(0); |
| 8886 |
|
| OUTPUT: |
| 8887 |
|
| RETVAL |
| 8888 |
|
| |
| 8889 |
|
| int |
| 8890 |
|
| nodeType(reader) |
| 8891 |
|
| xmlTextReaderPtr reader |
| 8892 |
|
| CODE: |
| 8893 |
179 |
| RETVAL = xmlTextReaderNodeType(reader); |
| 8894 |
|
| OUTPUT: |
| 8895 |
|
| RETVAL |
| 8896 |
|
| |
| 8897 |
|
| SV* |
| 8898 |
|
| quoteChar(reader) |
| 8899 |
|
| xmlTextReaderPtr reader |
| 8900 |
|
| PREINIT: |
| 8901 |
|
| int ret; |
| 8902 |
|
| CODE: |
| 8903 |
0 |
| ret = xmlTextReaderQuoteChar(reader); |
| 8904 |
0 |
▶ | if (ret == -1) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ret == -1) XSRETURN_UNDEF; |
0 |
0 |
0 |
|
| 8905 |
0 |
| RETVAL = newSVpvf("%c",ret); |
| 8906 |
|
| OUTPUT: |
| 8907 |
|
| RETVAL |
| 8908 |
|
| |
| 8909 |
|
| int |
| 8910 |
|
| read(reader) |
| 8911 |
|
| xmlTextReaderPtr reader |
| 8912 |
|
| PREINIT: |
| 8913 |
375 |
| PREINIT_SAVED_ERROR |
| 8914 |
|
| CODE: |
| 8915 |
375 |
| INIT_ERROR_HANDLER; |
| 8916 |
375 |
| RETVAL = xmlTextReaderRead(reader); |
| 8917 |
375 |
| CLEANUP_ERROR_HANDLER; |
| 8918 |
375 |
| REPORT_ERROR(0); |
| 8919 |
|
| OUTPUT: |
| 8920 |
|
| RETVAL |
| 8921 |
|
| |
| 8922 |
|
| int |
| 8923 |
|
| readAttributeValue(reader) |
| 8924 |
|
| xmlTextReaderPtr reader |
| 8925 |
|
| PREINIT: |
| 8926 |
1 |
| PREINIT_SAVED_ERROR |
| 8927 |
|
| CODE: |
| 8928 |
1 |
| INIT_ERROR_HANDLER; |
| 8929 |
1 |
| RETVAL = xmlTextReaderReadAttributeValue(reader); |
| 8930 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 8931 |
1 |
| REPORT_ERROR(0); |
| 8932 |
|
| OUTPUT: |
| 8933 |
|
| RETVAL |
| 8934 |
|
| |
| 8935 |
|
| |
| 8936 |
|
| SV * |
| 8937 |
|
| readInnerXml(reader) |
| 8938 |
|
| xmlTextReaderPtr reader |
| 8939 |
|
| PREINIT: |
| 8940 |
1 |
| xmlChar *result = NULL; |
| 8941 |
|
| PREINIT: |
| 8942 |
1 |
| PREINIT_SAVED_ERROR |
| 8943 |
|
| CODE: |
| 8944 |
1 |
| INIT_ERROR_HANDLER; |
| 8945 |
1 |
| result = xmlTextReaderReadInnerXml(reader); |
| 8946 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 8947 |
1 |
| REPORT_ERROR(0); |
| 8948 |
1 |
▶ | if (!result) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!result) XSRETURN_UNDEF; |
0 |
1 |
1 |
|
| 8949 |
1 |
| RETVAL = C2Sv(result, NULL); |
| 8950 |
1 |
| xmlFree(result); |
| 8951 |
|
| OUTPUT: |
| 8952 |
|
| RETVAL |
| 8953 |
|
| |
| 8954 |
|
| SV * |
| 8955 |
|
| readOuterXml(reader) |
| 8956 |
|
| xmlTextReaderPtr reader |
| 8957 |
|
| PREINIT: |
| 8958 |
3 |
| xmlChar *result = NULL; |
| 8959 |
|
| PREINIT: |
| 8960 |
3 |
| PREINIT_SAVED_ERROR |
| 8961 |
|
| CODE: |
| 8962 |
3 |
| INIT_ERROR_HANDLER; |
| 8963 |
3 |
| result = xmlTextReaderReadOuterXml(reader); |
| 8964 |
3 |
| CLEANUP_ERROR_HANDLER; |
| 8965 |
3 |
| REPORT_ERROR(0); |
| 8966 |
3 |
▶ | if (result) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (result) { |
3 |
0 |
3 |
|
| 8967 |
3 |
| RETVAL = C2Sv(result, NULL); |
| 8968 |
3 |
| xmlFree(result); |
| 8969 |
|
| } else { |
| 8970 |
0 |
| XSRETURN_UNDEF; |
| 8971 |
|
| } |
| 8972 |
|
| OUTPUT: |
| 8973 |
|
| RETVAL |
| 8974 |
|
| |
| 8975 |
|
| int |
| 8976 |
|
| readState(reader) |
| 8977 |
|
| xmlTextReaderPtr reader |
| 8978 |
|
| CODE: |
| 8979 |
1 |
| RETVAL = xmlTextReaderReadState(reader); |
| 8980 |
|
| OUTPUT: |
| 8981 |
|
| RETVAL |
| 8982 |
|
| |
| 8983 |
|
| int |
| 8984 |
|
| _setParserProp(reader, prop, value) |
| 8985 |
|
| xmlTextReaderPtr reader |
| 8986 |
|
| int prop |
| 8987 |
|
| int value |
| 8988 |
|
| CODE: |
| 8989 |
0 |
| RETVAL = xmlTextReaderSetParserProp(reader, prop, value); |
| 8990 |
|
| OUTPUT: |
| 8991 |
|
| RETVAL |
| 8992 |
|
| |
| 8993 |
|
| int |
| 8994 |
|
| standalone(reader) |
| 8995 |
|
| xmlTextReaderPtr reader |
| 8996 |
|
| CODE: |
| 8997 |
1 |
| RETVAL = xmlTextReaderStandalone(reader); |
| 8998 |
|
| OUTPUT: |
| 8999 |
|
| RETVAL |
| 9000 |
|
| |
| 9001 |
|
| SV * |
| 9002 |
|
| _nodePath(reader) |
| 9003 |
|
| xmlTextReaderPtr reader |
| 9004 |
|
| PREINIT: |
| 9005 |
8 |
| xmlNodePtr node = NULL; |
| 9006 |
8 |
| xmlChar * path = NULL; |
| 9007 |
|
| CODE: |
| 9008 |
8 |
| node = xmlTextReaderCurrentNode(reader); |
| 9009 |
8 |
▶ | if ( node ==NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node ==NULL ) { |
0 |
8 |
8 |
|
| 9010 |
0 |
| XSRETURN_UNDEF; |
| 9011 |
|
| } |
| 9012 |
8 |
| path = xmlGetNodePath( node ); |
| 9013 |
8 |
▶ | if ( path == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( path == NULL ) { |
0 |
8 |
8 |
|
| 9014 |
0 |
| XSRETURN_UNDEF; |
| 9015 |
|
| } |
| 9016 |
8 |
| RETVAL = C2Sv(path,NULL); |
| 9017 |
8 |
| xmlFree(path); |
| 9018 |
|
| OUTPUT: |
| 9019 |
|
| RETVAL |
| 9020 |
|
| |
| 9021 |
|
| #ifdef LIBXML_PATTERN_ENABLED |
| 9022 |
|
| |
| 9023 |
|
| int |
| 9024 |
|
| matchesPattern(reader, compiled) |
| 9025 |
|
| xmlTextReaderPtr reader |
| 9026 |
|
| xmlPatternPtr compiled |
| 9027 |
|
| PREINIT: |
| 9028 |
41 |
▶ | xmlNodePtr node = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlNodePtr node = NULL; |
41 |
0 |
41 |
|
| 9029 |
|
| CODE: |
| 9030 |
41 |
▶ | if ( compiled == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( compiled == NULL ) |
0 |
41 |
41 |
|
| 9031 |
0 |
| XSRETURN_UNDEF; |
| 9032 |
41 |
| node = xmlTextReaderCurrentNode(reader); |
| 9033 |
41 |
▶ | if ( node ==NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node ==NULL ) { |
0 |
41 |
41 |
|
| 9034 |
0 |
| XSRETURN_UNDEF; |
| 9035 |
|
| } |
| 9036 |
41 |
| RETVAL = xmlPatternMatch(compiled, node); |
| 9037 |
|
| OUTPUT: |
| 9038 |
|
| RETVAL |
| 9039 |
|
| |
| 9040 |
|
| #endif /* LIBXML_PATTERN_ENABLED */ |
| 9041 |
|
| |
| 9042 |
|
| SV * |
| 9043 |
|
| copyCurrentNode(reader,expand = 0) |
| 9044 |
|
| xmlTextReaderPtr reader |
| 9045 |
|
| int expand |
| 9046 |
|
| PREINIT: |
| 9047 |
34 |
| xmlNodePtr node = NULL; |
| 9048 |
|
| xmlNodePtr copy; |
| 9049 |
34 |
| xmlDocPtr doc = NULL; |
| 9050 |
|
| ProxyNodePtr proxy; |
| 9051 |
|
| PREINIT: |
| 9052 |
34 |
| PREINIT_SAVED_ERROR |
| 9053 |
|
| CODE: |
| 9054 |
34 |
| INIT_ERROR_HANDLER; |
| 9055 |
34 |
▶ | if (expand) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (expand) { |
1 |
33 |
34 |
|
| 9056 |
1 |
| node = xmlTextReaderExpand(reader); |
| 9057 |
|
| } |
| 9058 |
|
| else { |
| 9059 |
33 |
| node = xmlTextReaderCurrentNode(reader); |
| 9060 |
|
| } |
| 9061 |
34 |
▶ | if (node) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node) { |
34 |
0 |
34 |
|
| 9062 |
34 |
| doc = xmlTextReaderCurrentDoc(reader); |
| 9063 |
|
| } |
| 9064 |
34 |
▶ | if (!doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!doc) { |
0 |
34 |
34 |
|
| 9065 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 9066 |
0 |
| REPORT_ERROR(0); |
| 9067 |
0 |
| XSRETURN_UNDEF; |
| 9068 |
|
| } |
| 9069 |
34 |
▶ | if (xmlTextReaderGetParserProp(reader,XML_PARSER_VALIDATE)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (xmlTextReaderGetParserProp(reader,XML_PARSER_VALIDATE)) |
0 |
34 |
34 |
|
| 9070 |
0 |
▶ | PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
0 |
0 |
0 |
| PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
0 |
0 |
0 |
|
| 9071 |
|
| |
| 9072 |
34 |
| copy = PmmCloneNode( node, expand ); |
| 9073 |
34 |
▶ | if ( copy == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( copy == NULL ) { |
0 |
34 |
34 |
|
| 9074 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 9075 |
0 |
| REPORT_ERROR(0); |
| 9076 |
0 |
| XSRETURN_UNDEF; |
| 9077 |
|
| } |
| 9078 |
34 |
▶ | if ( copy->type == XML_DTD_NODE ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( copy->type == XML_DTD_NODE ) { |
0 |
34 |
34 |
|
| 9079 |
0 |
| RETVAL = PmmNodeToSv(copy, NULL); |
| 9080 |
|
| } |
| 9081 |
|
| else { |
| 9082 |
34 |
| ProxyNodePtr docfrag = NULL; |
| 9083 |
|
| |
| 9084 |
34 |
▶ | if ( doc != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( doc != NULL ) { |
34 |
0 |
34 |
|
| 9085 |
34 |
| xmlSetTreeDoc(copy, doc); |
| 9086 |
|
| } |
| 9087 |
34 |
| proxy = PmmNewNode((xmlNodePtr)doc); |
| 9088 |
34 |
▶ | if (PmmREFCNT(proxy) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PmmREFCNT(proxy) == 0) { |
4 |
30 |
34 |
|
| 9089 |
4 |
| PmmREFCNT_inc(proxy); |
| 9090 |
|
| } |
| 9091 |
34 |
| LibXML_set_reader_preserve_flag(reader); |
| 9092 |
|
| |
| 9093 |
34 |
| docfrag = PmmNewFragment( doc ); |
| 9094 |
34 |
| xmlAddChild( PmmNODE(docfrag), copy ); |
| 9095 |
34 |
| RETVAL = PmmNodeToSv(copy, docfrag); |
| 9096 |
|
| } |
| 9097 |
34 |
| CLEANUP_ERROR_HANDLER; |
| 9098 |
34 |
| REPORT_ERROR(0); |
| 9099 |
|
| OUTPUT: |
| 9100 |
|
| RETVAL |
| 9101 |
|
| |
| 9102 |
|
| SV * |
| 9103 |
|
| document(reader) |
| 9104 |
|
| xmlTextReaderPtr reader |
| 9105 |
|
| PREINIT: |
| 9106 |
8 |
| xmlDocPtr doc = NULL; |
| 9107 |
|
| CODE: |
| 9108 |
8 |
| doc = xmlTextReaderCurrentDoc(reader); |
| 9109 |
8 |
▶ | if (!doc) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!doc) XSRETURN_UNDEF; |
0 |
8 |
8 |
|
| 9110 |
8 |
| RETVAL = PmmNodeToSv((xmlNodePtr)doc, NULL); |
| 9111 |
|
| /* FIXME: taint the document with PmmInvalidatePSVI if the reader did validation */ |
| 9112 |
8 |
▶ | if ( PmmREFCNT(SvPROXYNODE(RETVAL))==1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( PmmREFCNT(SvPROXYNODE(RETVAL))==1 ) { |
0 |
8 |
8 |
|
| 9113 |
|
| /* will be decremented in Reader destructor */ |
| 9114 |
0 |
| PmmREFCNT_inc(SvPROXYNODE(RETVAL)); |
| 9115 |
|
| } |
| 9116 |
8 |
▶ | if (xmlTextReaderGetParserProp(reader,XML_PARSER_VALIDATE)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (xmlTextReaderGetParserProp(reader,XML_PARSER_VALIDATE)) |
2 |
6 |
8 |
|
| 9117 |
2 |
▶ | PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
Branch: 2 branches
| Branch | True | False | Total |
| PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
2 |
0 |
2 |
| PmmInvalidatePSVI(doc); /* the document may have psvi info */ |
2 |
0 |
2 |
|
| 9118 |
|
| |
| 9119 |
8 |
| LibXML_set_reader_preserve_flag(reader); |
| 9120 |
|
| |
| 9121 |
|
| OUTPUT: |
| 9122 |
|
| RETVAL |
| 9123 |
|
| |
| 9124 |
|
| int |
| 9125 |
|
| _preservePattern(reader,pattern,ns_map=NULL) |
| 9126 |
|
| xmlTextReaderPtr reader |
| 9127 |
|
| char * pattern |
| 9128 |
|
| AV * ns_map |
| 9129 |
|
| PREINIT: |
| 9130 |
2 |
▶ | xmlChar** namespaces = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| xmlChar** namespaces = NULL; |
2 |
0 |
2 |
|
| 9131 |
|
| SV** aux; |
| 9132 |
|
| int last,i; |
| 9133 |
|
| CODE: |
| 9134 |
2 |
▶ | if (ns_map) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ns_map) { |
1 |
1 |
2 |
|
| 9135 |
1 |
| last = av_len(ns_map); |
| 9136 |
1 |
| New(0,namespaces, last+2, xmlChar*); |
| 9137 |
3 |
▶ | for( i = 0; i <= last ; i++ ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for( i = 0; i <= last ; i++ ) { |
2 |
1 |
3 |
|
| 9138 |
2 |
| aux = av_fetch(ns_map,i,0); |
| 9139 |
4 |
| namespaces[i]=(xmlChar*) SvPV_nolen(*aux); |
| 9140 |
|
| } |
| 9141 |
1 |
| namespaces[i]=0; |
| 9142 |
|
| } |
| 9143 |
2 |
| RETVAL = xmlTextReaderPreservePattern(reader,(const xmlChar*) pattern, |
| 9144 |
|
| (const xmlChar**)namespaces); |
| 9145 |
2 |
| Safefree(namespaces); |
| 9146 |
|
| OUTPUT: |
| 9147 |
|
| RETVAL |
| 9148 |
|
| |
| 9149 |
|
| SV * |
| 9150 |
|
| preserveNode(reader) |
| 9151 |
|
| xmlTextReaderPtr reader |
| 9152 |
|
| PREINIT: |
| 9153 |
|
| xmlNodePtr node; |
| 9154 |
|
| xmlDocPtr doc; |
| 9155 |
|
| ProxyNodePtr proxy; |
| 9156 |
20 |
| PREINIT_SAVED_ERROR |
| 9157 |
|
| CODE: |
| 9158 |
20 |
| INIT_ERROR_HANDLER; |
| 9159 |
20 |
| doc = xmlTextReaderCurrentDoc(reader); |
| 9160 |
20 |
▶ | if (!doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!doc) { |
0 |
20 |
20 |
|
| 9161 |
0 |
| CLEANUP_ERROR_HANDLER; |
| 9162 |
0 |
| REPORT_ERROR(0); |
| 9163 |
0 |
| XSRETURN_UNDEF; |
| 9164 |
|
| } |
| 9165 |
20 |
| proxy = PmmNewNode((xmlNodePtr)doc); |
| 9166 |
20 |
▶ | if ( PmmREFCNT(proxy) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( PmmREFCNT(proxy) == 0 ) { |
5 |
15 |
20 |
|
| 9167 |
|
| /* new proxy node */ |
| 9168 |
5 |
| PmmREFCNT_inc(proxy); |
| 9169 |
|
| } |
| 9170 |
20 |
| LibXML_set_reader_preserve_flag(reader); |
| 9171 |
|
| |
| 9172 |
20 |
| node = xmlTextReaderPreserve(reader); |
| 9173 |
20 |
| CLEANUP_ERROR_HANDLER; |
| 9174 |
20 |
| REPORT_ERROR(0); |
| 9175 |
20 |
▶ | if (node) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (node) { |
20 |
0 |
20 |
|
| 9176 |
20 |
| RETVAL = PmmNodeToSv(node, proxy); |
| 9177 |
|
| } else { |
| 9178 |
0 |
| XSRETURN_UNDEF; |
| 9179 |
|
| } |
| 9180 |
|
| OUTPUT: |
| 9181 |
|
| RETVAL |
| 9182 |
|
| |
| 9183 |
|
| int |
| 9184 |
|
| finish(reader) |
| 9185 |
|
| xmlTextReaderPtr reader |
| 9186 |
|
| PREINIT: |
| 9187 |
10 |
| PREINIT_SAVED_ERROR |
| 9188 |
|
| CODE: |
| 9189 |
10 |
| INIT_ERROR_HANDLER; |
| 9190 |
|
| while (1) { |
| 9191 |
102 |
| RETVAL = xmlTextReaderRead(reader); |
| 9192 |
102 |
▶ | if (RETVAL!=1) break; |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL!=1) break; |
10 |
92 |
102 |
|
| 9193 |
|
| } |
| 9194 |
10 |
| CLEANUP_ERROR_HANDLER; |
| 9195 |
10 |
| REPORT_ERROR(0); |
| 9196 |
5 |
▶ | RETVAL++; /* we want 0 - fail, 1- success */ |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL++; /* we want 0 - fail, 1- success */ |
2 |
3 |
5 |
|
| 9197 |
|
| OUTPUT: |
| 9198 |
|
| RETVAL |
| 9199 |
|
| |
| 9200 |
|
| #ifdef HAVE_SCHEMAS |
| 9201 |
|
| |
| 9202 |
|
| int |
| 9203 |
|
| _setRelaxNGFile(reader,rng) |
| 9204 |
|
| xmlTextReaderPtr reader |
| 9205 |
|
| char* rng |
| 9206 |
|
| CODE: |
| 9207 |
2 |
| RETVAL = xmlTextReaderRelaxNGValidate(reader,rng); |
| 9208 |
|
| OUTPUT: |
| 9209 |
|
| RETVAL |
| 9210 |
|
| |
| 9211 |
|
| int |
| 9212 |
|
| _setRelaxNG(reader,rng_doc) |
| 9213 |
|
| xmlTextReaderPtr reader |
| 9214 |
|
| xmlRelaxNGPtr rng_doc |
| 9215 |
|
| CODE: |
| 9216 |
2 |
| RETVAL = xmlTextReaderRelaxNGSetSchema(reader,rng_doc); |
| 9217 |
|
| OUTPUT: |
| 9218 |
|
| RETVAL |
| 9219 |
|
| |
| 9220 |
|
| int |
| 9221 |
|
| _setXSDFile(reader,xsd) |
| 9222 |
|
| xmlTextReaderPtr reader |
| 9223 |
|
| char* xsd |
| 9224 |
|
| CODE: |
| 9225 |
2 |
| RETVAL = xmlTextReaderSchemaValidate(reader,xsd); |
| 9226 |
|
| OUTPUT: |
| 9227 |
|
| RETVAL |
| 9228 |
|
| |
| 9229 |
|
| int |
| 9230 |
|
| _setXSD(reader,xsd_doc) |
| 9231 |
|
| xmlTextReaderPtr reader |
| 9232 |
|
| xmlSchemaPtr xsd_doc |
| 9233 |
|
| CODE: |
| 9234 |
2 |
| RETVAL = xmlTextReaderSetSchema(reader,xsd_doc); |
| 9235 |
|
| OUTPUT: |
| 9236 |
|
| RETVAL |
| 9237 |
|
| |
| 9238 |
|
| #endif /* HAVE_SCHEMAS */ |
| 9239 |
|
| |
| 9240 |
|
| void |
| 9241 |
|
| _DESTROY(reader) |
| 9242 |
|
| xmlTextReaderPtr reader |
| 9243 |
|
| PREINIT: |
| 9244 |
|
| xmlDocPtr doc; |
| 9245 |
|
| ProxyNodePtr proxy; |
| 9246 |
|
| /* SV * error_sv = NULL; |
| 9247 |
|
| xmlTextReaderErrorFunc f = NULL; */ |
| 9248 |
|
| CODE: |
| 9249 |
|
| |
| 9250 |
31 |
▶ | if ( LibXML_get_reader_preserve_flag(reader) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( LibXML_get_reader_preserve_flag(reader) ) { |
10 |
21 |
31 |
|
| 9251 |
10 |
| doc = xmlTextReaderCurrentDoc(reader); |
| 9252 |
10 |
▶ | if (doc) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (doc) { |
10 |
0 |
10 |
|
| 9253 |
10 |
| proxy = PmmNewNode((xmlNodePtr)doc); |
| 9254 |
10 |
▶ | if ( PmmREFCNT(proxy) == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( PmmREFCNT(proxy) == 0 ) { |
0 |
10 |
10 |
|
| 9255 |
0 |
| PmmREFCNT_inc(proxy); |
| 9256 |
|
| } |
| 9257 |
10 |
| PmmREFCNT_dec(proxy); |
| 9258 |
|
| } |
| 9259 |
|
| } |
| 9260 |
31 |
▶ | if (xmlTextReaderReadState(reader) != XML_TEXTREADER_MODE_CLOSED) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xmlTextReaderReadState(reader) != XML_TEXTREADER_MODE_CLOSED) { |
30 |
1 |
31 |
|
| 9261 |
30 |
| xmlTextReaderClose(reader); |
| 9262 |
|
| } |
| 9263 |
|
| /* xmlTextReaderGetErrorHandler(reader, &f, (void **) &error_sv); |
| 9264 |
|
| if (error_sv) { |
| 9265 |
|
| sv_2mortal(error_sv); |
| 9266 |
|
| } */ |
| 9267 |
31 |
| xmlFreeTextReader(reader); |
| 9268 |
|
| |
| 9269 |
|
| #endif /* HAVE_READER_SUPPORT */ |
| 9270 |
|
| |
| 9271 |
|
| #ifdef WITH_SERRORS |
| 9272 |
|
| |
| 9273 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::LibError |
| 9274 |
|
| |
| 9275 |
|
| int |
| 9276 |
|
| domain( self ) |
| 9277 |
|
| xmlErrorPtr self |
| 9278 |
|
| CODE: |
| 9279 |
265 |
▶ | RETVAL = self->domain; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->domain; |
240 |
25 |
265 |
|
| 9280 |
|
| OUTPUT: |
| 9281 |
|
| RETVAL |
| 9282 |
|
| |
| 9283 |
|
| int |
| 9284 |
|
| code( self ) |
| 9285 |
|
| xmlErrorPtr self |
| 9286 |
|
| CODE: |
| 9287 |
265 |
▶ | RETVAL = self->code; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->code; |
240 |
25 |
265 |
|
| 9288 |
|
| OUTPUT: |
| 9289 |
|
| RETVAL |
| 9290 |
|
| |
| 9291 |
|
| int |
| 9292 |
|
| line( self ) |
| 9293 |
|
| xmlErrorPtr self |
| 9294 |
|
| CODE: |
| 9295 |
265 |
▶ | RETVAL = self->line; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->line; |
240 |
25 |
265 |
|
| 9296 |
|
| OUTPUT: |
| 9297 |
|
| RETVAL |
| 9298 |
|
| |
| 9299 |
|
| int |
| 9300 |
|
| num1( self ) |
| 9301 |
|
| xmlErrorPtr self |
| 9302 |
|
| ALIAS: |
| 9303 |
|
| int1 = 1 |
| 9304 |
|
| CODE: |
| 9305 |
|
| PERL_UNUSED_VAR(ix); |
| 9306 |
265 |
▶ | RETVAL = self->int1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->int1; |
240 |
25 |
265 |
|
| 9307 |
|
| OUTPUT: |
| 9308 |
|
| RETVAL |
| 9309 |
|
| |
| 9310 |
|
| int |
| 9311 |
|
| num2( self ) |
| 9312 |
|
| xmlErrorPtr self |
| 9313 |
|
| ALIAS: |
| 9314 |
|
| int2 = 1 |
| 9315 |
|
| CODE: |
| 9316 |
|
| PERL_UNUSED_VAR(ix); |
| 9317 |
265 |
▶ | RETVAL = self->int2; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = self->int2; |
240 |
25 |
265 |
|
| 9318 |
|
| OUTPUT: |
| 9319 |
|
| RETVAL |
| 9320 |
|
| |
| 9321 |
|
| int |
| 9322 |
|
| level( self ) |
| 9323 |
|
| xmlErrorPtr self |
| 9324 |
|
| CODE: |
| 9325 |
265 |
▶ | RETVAL = (int)self->level; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (int)self->level; |
240 |
25 |
265 |
|
| 9326 |
|
| OUTPUT: |
| 9327 |
|
| RETVAL |
| 9328 |
|
| |
| 9329 |
|
| char * |
| 9330 |
|
| message( self ) |
| 9331 |
|
| xmlErrorPtr self |
| 9332 |
|
| CODE: |
| 9333 |
265 |
| RETVAL = self->message; |
| 9334 |
|
| OUTPUT: |
| 9335 |
|
| RETVAL |
| 9336 |
|
| |
| 9337 |
|
| char * |
| 9338 |
|
| file( self ) |
| 9339 |
|
| xmlErrorPtr self |
| 9340 |
|
| CODE: |
| 9341 |
265 |
| RETVAL = (char*)self->file; |
| 9342 |
|
| OUTPUT: |
| 9343 |
|
| RETVAL |
| 9344 |
|
| |
| 9345 |
|
| char * |
| 9346 |
|
| str1( self ) |
| 9347 |
|
| xmlErrorPtr self |
| 9348 |
|
| CODE: |
| 9349 |
265 |
| RETVAL = (char*)self->str1; |
| 9350 |
|
| OUTPUT: |
| 9351 |
|
| RETVAL |
| 9352 |
|
| |
| 9353 |
|
| char * |
| 9354 |
|
| str2( self ) |
| 9355 |
|
| xmlErrorPtr self |
| 9356 |
|
| CODE: |
| 9357 |
265 |
| RETVAL = (char*)self->str2; |
| 9358 |
|
| OUTPUT: |
| 9359 |
|
| RETVAL |
| 9360 |
|
| |
| 9361 |
|
| char * |
| 9362 |
|
| str3( self ) |
| 9363 |
|
| xmlErrorPtr self |
| 9364 |
|
| CODE: |
| 9365 |
265 |
| RETVAL = (char*)self->str3; |
| 9366 |
|
| OUTPUT: |
| 9367 |
|
| RETVAL |
| 9368 |
|
| |
| 9369 |
|
| void |
| 9370 |
|
| context_and_column( self ) |
| 9371 |
|
| xmlErrorPtr self |
| 9372 |
|
| PREINIT: |
| 9373 |
|
| xmlParserInputPtr input; |
| 9374 |
|
| const xmlChar *cur, *base, *col_cur; |
| 9375 |
|
| unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */ |
| 9376 |
|
| xmlChar content[81]; /* space for 80 chars + line terminator */ |
| 9377 |
|
| xmlChar *ctnt; |
| 9378 |
|
| int domain; |
| 9379 |
265 |
| xmlParserCtxtPtr ctxt = NULL; |
| 9380 |
|
| PPCODE: |
| 9381 |
265 |
| domain = self->domain; |
| 9382 |
265 |
▶ | if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || |
Branch: 3 branches
| Branch | True | False | Total |
| if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || |
118 |
147 |
265 |
| if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || |
116 |
2 |
118 |
| if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || |
114 |
2 |
116 |
|
| 9383 |
114 |
▶ | (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || |
Branch: 2 branches
| Branch | True | False | Total |
| (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || |
113 |
1 |
114 |
| (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || |
86 |
27 |
113 |
|
| 9384 |
86 |
▶ | (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { |
Branch: 1 branch
| Branch | True | False | Total |
| (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { |
17 |
69 |
86 |
|
| 9385 |
196 |
| ctxt = (xmlParserCtxtPtr) self->ctxt; |
| 9386 |
|
| } |
| 9387 |
265 |
▶ | if (ctxt == NULL) XSRETURN_EMPTY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctxt == NULL) XSRETURN_EMPTY; |
71 |
194 |
265 |
|
| 9388 |
194 |
| input = ctxt->input; |
| 9389 |
194 |
▶ | if ((input != NULL) && (input->filename == NULL) && |
Branch: 2 branches
| Branch | True | False | Total |
| if ((input != NULL) && (input->filename == NULL) && |
184 |
10 |
194 |
| if ((input != NULL) && (input->filename == NULL) && |
27 |
157 |
184 |
|
| 9390 |
27 |
▶ | (ctxt->inputNr > 1)) { |
Branch: 1 branch
| Branch | True | False | Total |
| (ctxt->inputNr > 1)) { |
1 |
26 |
27 |
|
| 9391 |
1 |
| input = ctxt->inputTab[ctxt->inputNr - 2]; |
| 9392 |
|
| } |
| 9393 |
194 |
▶ | if (input == NULL) XSRETURN_EMPTY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (input == NULL) XSRETURN_EMPTY; |
10 |
184 |
194 |
|
| 9394 |
184 |
| cur = input->cur; |
| 9395 |
184 |
| base = input->base; |
| 9396 |
|
| /* skip backwards over any end-of-lines */ |
| 9397 |
193 |
▶ | while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { |
Branch: 3 branches
| Branch | True | False | Total |
| while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { |
189 |
4 |
193 |
| while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { |
9 |
180 |
189 |
| while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) { |
0 |
180 |
180 |
|
| 9398 |
9 |
| cur--; |
| 9399 |
|
| } |
| 9400 |
184 |
| n = 0; |
| 9401 |
|
| /* search backwards for beginning-of-line (to max buff size) */ |
| 9402 |
4510 |
▶ | while ((n++ < (sizeof(content)-1)) && (cur > base) && |
Branch: 1 branch
| Branch | True | False | Total |
| while ((n++ < (sizeof(content)-1)) && (cur > base) && |
4208 |
118 |
4326 |
|
| 9403 |
8552 |
▶ | (*(cur) != '\n') && (*(cur) != '\r')) |
Branch: 3 branches
| Branch | True | False | Total |
| (*(cur) != '\n') && (*(cur) != '\r')) |
4326 |
18 |
4344 |
| (*(cur) != '\n') && (*(cur) != '\r')) |
4160 |
48 |
4208 |
| (*(cur) != '\n') && (*(cur) != '\r')) |
4160 |
0 |
4160 |
|
| 9404 |
4160 |
| cur--; |
| 9405 |
|
| /* search backwards for beginning-of-line for calculating the |
| 9406 |
|
| * column. */ |
| 9407 |
184 |
| col_cur = cur; |
| 9408 |
19253 |
▶ | while ((col_cur > base) && (*(col_cur) != '\n') && (*(col_cur) != '\r')) |
Branch: 3 branches
| Branch | True | False | Total |
| while ((col_cur > base) && (*(col_cur) != '\n') && (*(col_cur) != '\r')) |
19125 |
128 |
19253 |
| while ((col_cur > base) && (*(col_cur) != '\n') && (*(col_cur) != '\r')) |
19069 |
56 |
19125 |
| while ((col_cur > base) && (*(col_cur) != '\n') && (*(col_cur) != '\r')) |
19069 |
0 |
19069 |
|
| 9409 |
19069 |
| col_cur--; |
| 9410 |
184 |
▶ | if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; |
Branch: 2 branches
| Branch | True | False | Total |
| if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; |
136 |
48 |
184 |
| if ((*(cur) == '\n') || (*(cur) == '\r')) cur++; |
0 |
136 |
136 |
|
| 9411 |
184 |
▶ | if ((*(col_cur) == '\n') || (*(col_cur) == '\r')) col_cur++; |
Branch: 2 branches
| Branch | True | False | Total |
| if ((*(col_cur) == '\n') || (*(col_cur) == '\r')) col_cur++; |
128 |
56 |
184 |
| if ((*(col_cur) == '\n') || (*(col_cur) == '\r')) col_cur++; |
0 |
128 |
128 |
|
| 9412 |
|
| /* calculate the error position in terms of the current position */ |
| 9413 |
184 |
| col = input->cur - col_cur; |
| 9414 |
|
| /* search forward for end-of-line (to max buff size) */ |
| 9415 |
184 |
| n = 0; |
| 9416 |
184 |
| ctnt = content; |
| 9417 |
|
| /* copy selected text to our buffer */ |
| 9418 |
5084 |
▶ | while ((*cur != 0) && (*(cur) != '\n') && |
Branch: 1 branch
| Branch | True | False | Total |
| while ((*cur != 0) && (*(cur) != '\n') && |
4861 |
39 |
4900 |
|
| 9419 |
9888 |
▶ | (*(cur) != '\r') && (n < sizeof(content)-1)) { |
Branch: 3 branches
| Branch | True | False | Total |
| (*(cur) != '\r') && (n < sizeof(content)-1)) { |
4900 |
127 |
5027 |
| (*(cur) != '\r') && (n < sizeof(content)-1)) { |
4861 |
0 |
4861 |
| (*(cur) != '\r') && (n < sizeof(content)-1)) { |
4843 |
18 |
4861 |
|
| 9420 |
4843 |
| *ctnt++ = *cur++; |
| 9421 |
4843 |
| n++; |
| 9422 |
|
| } |
| 9423 |
184 |
| *ctnt = 0; |
| 9424 |
184 |
▶ | EXTEND(SP,2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP,2); |
0 |
184 |
184 |
|
| 9425 |
184 |
| PUSHs(sv_2mortal(C2Sv(content, NULL))); |
| 9426 |
184 |
| PUSHs(sv_2mortal(newSViv(col))); |
| 9427 |
|
| |
| 9428 |
|
| #endif /* WITH_SERRORS */ |
| 9429 |
|
| |
| 9430 |
|
| |
| 9431 |
|
| #ifdef LIBXML_PATTERN_ENABLED |
| 9432 |
|
| |
| 9433 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Pattern |
| 9434 |
|
| |
| 9435 |
|
| xmlPatternPtr |
| 9436 |
|
| _compilePattern(CLASS, ppattern, pattern_type, ns_map=NULL) |
| 9437 |
|
| SV * ppattern |
| 9438 |
|
| AV * ns_map |
| 9439 |
|
| int pattern_type |
| 9440 |
|
| PREINIT: |
| 9441 |
1 |
| xmlChar * pattern = Sv2C(ppattern, NULL); |
| 9442 |
1 |
| xmlChar** namespaces = NULL; |
| 9443 |
|
| SV** aux; |
| 9444 |
|
| int last,i; |
| 9445 |
1 |
| PREINIT_SAVED_ERROR |
| 9446 |
|
| CODE: |
| 9447 |
1 |
▶ | if ( pattern == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( pattern == NULL ) |
0 |
1 |
1 |
|
| 9448 |
0 |
| XSRETURN_UNDEF; |
| 9449 |
1 |
▶ | if (ns_map) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ns_map) { |
1 |
0 |
1 |
|
| 9450 |
1 |
| last = av_len(ns_map); |
| 9451 |
1 |
| New(0,namespaces, last+2, xmlChar*); |
| 9452 |
3 |
▶ | for( i = 0; i <= last ; i++ ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for( i = 0; i <= last ; i++ ) { |
2 |
1 |
3 |
|
| 9453 |
2 |
| aux = av_fetch(ns_map,i,0); |
| 9454 |
4 |
| namespaces[i]=(xmlChar*) SvPV_nolen(*aux); |
| 9455 |
|
| } |
| 9456 |
1 |
| namespaces[i]=0; |
| 9457 |
|
| } |
| 9458 |
1 |
| INIT_ERROR_HANDLER; |
| 9459 |
1 |
| RETVAL = xmlPatterncompile(pattern, NULL, pattern_type, (const xmlChar **) namespaces); |
| 9460 |
1 |
| Safefree(namespaces); |
| 9461 |
1 |
| xmlFree( pattern ); |
| 9462 |
1 |
| CLEANUP_ERROR_HANDLER; |
| 9463 |
1 |
| REPORT_ERROR(0); |
| 9464 |
1 |
▶ | if ( RETVAL == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == NULL ) { |
0 |
1 |
1 |
|
| 9465 |
0 |
| croak("Compilation of pattern failed"); |
| 9466 |
|
| } |
| 9467 |
|
| OUTPUT: |
| 9468 |
|
| RETVAL |
| 9469 |
|
| |
| 9470 |
|
| int |
| 9471 |
|
| matchesNode(self, node) |
| 9472 |
|
| xmlPatternPtr self |
| 9473 |
|
| xmlNodePtr node |
| 9474 |
|
| CODE: |
| 9475 |
34 |
▶ | if ( node ==NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node ==NULL ) { |
0 |
34 |
34 |
|
| 9476 |
0 |
| XSRETURN_UNDEF; |
| 9477 |
|
| } |
| 9478 |
34 |
| RETVAL = xmlPatternMatch(self, node); |
| 9479 |
|
| OUTPUT: |
| 9480 |
|
| RETVAL |
| 9481 |
|
| |
| 9482 |
|
| void |
| 9483 |
|
| DESTROY( self ) |
| 9484 |
|
| xmlPatternPtr self |
| 9485 |
|
| CODE: |
| 9486 |
|
| xs_warn( "DESTROY PATTERN OBJECT" ); |
| 9487 |
1 |
| xmlFreePattern(self); |
| 9488 |
|
| |
| 9489 |
|
| #endif /* LIBXML_PATTERN_ENABLED */ |
| 9490 |
|
| |
| 9491 |
|
| #ifdef LIBXML_REGEXP_ENABLED |
| 9492 |
|
| |
| 9493 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::RegExp |
| 9494 |
|
| |
| 9495 |
|
| xmlRegexpPtr |
| 9496 |
|
| _compile(CLASS, pregexp) |
| 9497 |
|
| SV * pregexp |
| 9498 |
|
| PREINIT: |
| 9499 |
3 |
| xmlChar * regexp = Sv2C(pregexp, NULL); |
| 9500 |
3 |
| PREINIT_SAVED_ERROR |
| 9501 |
|
| CODE: |
| 9502 |
3 |
▶ | if ( regexp == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( regexp == NULL ) |
0 |
3 |
3 |
|
| 9503 |
0 |
| XSRETURN_UNDEF; |
| 9504 |
3 |
| INIT_ERROR_HANDLER; |
| 9505 |
3 |
| RETVAL = xmlRegexpCompile(regexp); |
| 9506 |
3 |
| xmlFree( regexp ); |
| 9507 |
3 |
| CLEANUP_ERROR_HANDLER; |
| 9508 |
3 |
| REPORT_ERROR(0); |
| 9509 |
2 |
▶ | if ( RETVAL == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == NULL ) { |
0 |
2 |
2 |
|
| 9510 |
0 |
| croak("Compilation of regexp failed"); |
| 9511 |
|
| } |
| 9512 |
|
| OUTPUT: |
| 9513 |
|
| RETVAL |
| 9514 |
|
| |
| 9515 |
|
| int |
| 9516 |
|
| matches(self, pvalue) |
| 9517 |
|
| xmlRegexpPtr self |
| 9518 |
|
| SV* pvalue |
| 9519 |
|
| PREINIT: |
| 9520 |
8 |
| xmlChar * value = Sv2C(pvalue, NULL); |
| 9521 |
|
| CODE: |
| 9522 |
8 |
▶ | if ( value == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( value == NULL ) |
0 |
8 |
8 |
|
| 9523 |
0 |
| XSRETURN_UNDEF; |
| 9524 |
8 |
| RETVAL = xmlRegexpExec(self,value); |
| 9525 |
8 |
| xmlFree( value ); |
| 9526 |
|
| OUTPUT: |
| 9527 |
|
| RETVAL |
| 9528 |
|
| |
| 9529 |
|
| int |
| 9530 |
|
| isDeterministic(self) |
| 9531 |
|
| xmlRegexpPtr self |
| 9532 |
|
| CODE: |
| 9533 |
2 |
| RETVAL = xmlRegexpIsDeterminist(self); |
| 9534 |
|
| OUTPUT: |
| 9535 |
|
| RETVAL |
| 9536 |
|
| |
| 9537 |
|
| void |
| 9538 |
|
| DESTROY( self ) |
| 9539 |
|
| xmlRegexpPtr self |
| 9540 |
|
| CODE: |
| 9541 |
|
| xs_warn( "DESTROY REGEXP OBJECT" ); |
| 9542 |
2 |
| xmlRegFreeRegexp(self); |
| 9543 |
|
| |
| 9544 |
|
| #endif /* LIBXML_REGEXP_ENABLED */ |
| 9545 |
|
| |
| 9546 |
|
| |
| 9547 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::XPathExpression |
| 9548 |
|
| |
| 9549 |
|
| xmlXPathCompExprPtr |
| 9550 |
|
| new(CLASS, pxpath) |
| 9551 |
|
| SV * pxpath |
| 9552 |
|
| PREINIT: |
| 9553 |
10 |
| xmlChar * xpath = Sv2C(pxpath, NULL); |
| 9554 |
10 |
| PREINIT_SAVED_ERROR |
| 9555 |
|
| CODE: |
| 9556 |
10 |
▶ | if ( pxpath == NULL ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( pxpath == NULL ) |
0 |
10 |
10 |
|
| 9557 |
0 |
| XSRETURN_UNDEF; |
| 9558 |
10 |
| INIT_ERROR_HANDLER; |
| 9559 |
10 |
| RETVAL = xmlXPathCompile( xpath ); |
| 9560 |
10 |
| xmlFree( xpath ); |
| 9561 |
10 |
| CLEANUP_ERROR_HANDLER; |
| 9562 |
10 |
| REPORT_ERROR(0); |
| 9563 |
10 |
▶ | if ( RETVAL == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( RETVAL == NULL ) { |
0 |
10 |
10 |
|
| 9564 |
0 |
| croak("Compilation of XPath expression failed!"); |
| 9565 |
|
| } |
| 9566 |
|
| OUTPUT: |
| 9567 |
|
| RETVAL |
| 9568 |
|
| |
| 9569 |
|
| void |
| 9570 |
|
| DESTROY( self ) |
| 9571 |
|
| xmlXPathCompExprPtr self |
| 9572 |
|
| CODE: |
| 9573 |
|
| xs_warn( "DESTROY COMPILED XPATH OBJECT" ); |
| 9574 |
10 |
| xmlXPathFreeCompExpr(self); |
| 9575 |
|
| |
| 9576 |
|
| MODULE = XML::LibXML PACKAGE = XML::LibXML::Common |
| 9577 |
|
| |
| 9578 |
|
| PROTOTYPES: DISABLE |
| 9579 |
|
| |
| 9580 |
|
| SV* |
| 9581 |
|
| encodeToUTF8( encoding, string ) |
| 9582 |
|
| const char * encoding |
| 9583 |
|
| SV * string |
| 9584 |
|
| PREINIT: |
| 9585 |
17 |
| xmlChar * realstring = NULL; |
| 9586 |
17 |
| xmlChar * tstr = NULL; |
| 9587 |
17 |
| xmlCharEncoding enc = 0; |
| 9588 |
17 |
| STRLEN len = 0; |
| 9589 |
17 |
| xmlBufferPtr in = NULL, out = NULL; |
| 9590 |
17 |
| xmlCharEncodingHandlerPtr coder = NULL; |
| 9591 |
17 |
| PREINIT_SAVED_ERROR |
| 9592 |
|
| CODE: |
| 9593 |
17 |
▶ | if (!SvOK(string)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(string)) { |
1 |
16 |
17 |
|
| 9594 |
2 |
| XSRETURN_UNDEF; |
| 9595 |
16 |
▶ | } else if (!SvCUR(string)) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (!SvCUR(string)) { |
1 |
15 |
16 |
|
| 9596 |
1 |
| XSRETURN_PV(""); |
| 9597 |
|
| } |
| 9598 |
15 |
| realstring = (xmlChar*) SvPV(string, len); |
| 9599 |
15 |
▶ | if ( realstring != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( realstring != NULL ) { |
15 |
0 |
15 |
|
| 9600 |
|
| /* warn("encode %s", realstring ); */ |
| 9601 |
|
| #ifdef HAVE_UTF8 |
| 9602 |
15 |
▶ | if ( !DO_UTF8(string) && encoding != NULL ) { |
Branch: 3 branches
| Branch | True | False | Total |
| if ( !DO_UTF8(string) && encoding != NULL ) { |
0 |
15 |
15 |
| if ( !DO_UTF8(string) && encoding != NULL ) { |
0 |
0 |
0 |
| if ( !DO_UTF8(string) && encoding != NULL ) { |
15 |
0 |
15 |
|
| 9603 |
|
| #else |
| 9604 |
|
| if ( encoding != NULL ) { |
| 9605 |
|
| #endif |
| 9606 |
15 |
| enc = xmlParseCharEncoding( encoding ); |
| 9607 |
|
| |
| 9608 |
15 |
▶ | if ( enc == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc == 0 ) { |
0 |
15 |
15 |
|
| 9609 |
|
| /* this happens if the encoding is "" or NULL */ |
| 9610 |
0 |
| enc = XML_CHAR_ENCODING_UTF8; |
| 9611 |
|
| } |
| 9612 |
|
| |
| 9613 |
15 |
▶ | if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
4 |
11 |
15 |
|
| 9614 |
|
| /* copy the string */ |
| 9615 |
|
| /* warn( "simply copy the string" ); */ |
| 9616 |
4 |
| tstr = xmlStrndup( realstring, len ); |
| 9617 |
|
| } |
| 9618 |
|
| else { |
| 9619 |
11 |
| INIT_ERROR_HANDLER; |
| 9620 |
11 |
▶ | if ( enc > 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc > 1 ) { |
10 |
1 |
11 |
|
| 9621 |
10 |
| coder= xmlGetCharEncodingHandler( enc ); |
| 9622 |
|
| } |
| 9623 |
1 |
▶ | else if ( enc == XML_CHAR_ENCODING_ERROR ){ |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( enc == XML_CHAR_ENCODING_ERROR ){ |
1 |
0 |
1 |
|
| 9624 |
1 |
| coder =xmlFindCharEncodingHandler( encoding ); |
| 9625 |
|
| } |
| 9626 |
|
| else { |
| 9627 |
0 |
| croak("no encoder found\n"); |
| 9628 |
|
| } |
| 9629 |
11 |
▶ | if ( coder == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( coder == NULL ) { |
1 |
10 |
11 |
|
| 9630 |
1 |
| croak( "cannot encode string" ); |
| 9631 |
|
| } |
| 9632 |
10 |
| in = xmlBufferCreateStatic((void*)realstring, len ); |
| 9633 |
10 |
| out = xmlBufferCreate(); |
| 9634 |
10 |
▶ | if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) { |
10 |
0 |
10 |
|
| 9635 |
10 |
| tstr = xmlStrdup( out->content ); |
| 9636 |
|
| } |
| 9637 |
|
| |
| 9638 |
10 |
| xmlBufferFree( in ); |
| 9639 |
10 |
| xmlBufferFree( out ); |
| 9640 |
10 |
| xmlCharEncCloseFunc( coder ); |
| 9641 |
|
| |
| 9642 |
10 |
| CLEANUP_ERROR_HANDLER; |
| 9643 |
10 |
| REPORT_ERROR(0); |
| 9644 |
|
| } |
| 9645 |
|
| } |
| 9646 |
|
| else { |
| 9647 |
0 |
| tstr = xmlStrndup( realstring, len ); |
| 9648 |
|
| } |
| 9649 |
|
| |
| 9650 |
14 |
▶ | if ( !tstr ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !tstr ) { |
0 |
14 |
14 |
|
| 9651 |
0 |
| croak( "return value missing!" ); |
| 9652 |
|
| } |
| 9653 |
|
| |
| 9654 |
14 |
| len = xmlStrlen( tstr ); |
| 9655 |
14 |
| RETVAL = newSVpvn( (const char *)tstr, len ); |
| 9656 |
|
| #ifdef HAVE_UTF8 |
| 9657 |
14 |
| SvUTF8_on(RETVAL); |
| 9658 |
|
| #endif |
| 9659 |
14 |
| xmlFree(tstr); |
| 9660 |
|
| } |
| 9661 |
|
| else { |
| 9662 |
0 |
| XSRETURN_UNDEF; |
| 9663 |
|
| } |
| 9664 |
|
| OUTPUT: |
| 9665 |
|
| RETVAL |
| 9666 |
|
| |
| 9667 |
|
| SV* |
| 9668 |
|
| decodeFromUTF8( encoding, string ) |
| 9669 |
|
| const char * encoding |
| 9670 |
|
| SV* string |
| 9671 |
|
| PREINIT: |
| 9672 |
9 |
| xmlChar * tstr = NULL; |
| 9673 |
9 |
| xmlChar * realstring = NULL; |
| 9674 |
9 |
| xmlCharEncoding enc = 0; |
| 9675 |
9 |
| STRLEN len = 0; |
| 9676 |
9 |
| xmlBufferPtr in = NULL, out = NULL; |
| 9677 |
9 |
| xmlCharEncodingHandlerPtr coder = NULL; |
| 9678 |
9 |
| PREINIT_SAVED_ERROR |
| 9679 |
|
| CODE: |
| 9680 |
|
| #ifdef HAVE_UTF8 |
| 9681 |
9 |
▶ | if ( !SvOK(string) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !SvOK(string) ) { |
1 |
8 |
9 |
|
| 9682 |
2 |
| XSRETURN_UNDEF; |
| 9683 |
8 |
▶ | } else if (!SvCUR(string)) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (!SvCUR(string)) { |
1 |
7 |
8 |
|
| 9684 |
1 |
| XSRETURN_PV(""); |
| 9685 |
7 |
▶ | } else if ( !SvUTF8(string) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if ( !SvUTF8(string) ) { |
0 |
7 |
7 |
|
| 9686 |
0 |
| croak("string is not utf8!!"); |
| 9687 |
|
| } else { |
| 9688 |
|
| #endif |
| 9689 |
7 |
| realstring = (xmlChar*) SvPV(string, len); |
| 9690 |
7 |
▶ | if ( realstring != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( realstring != NULL ) { |
7 |
0 |
7 |
|
| 9691 |
|
| /* warn("decode %s", realstring ); */ |
| 9692 |
7 |
| enc = xmlParseCharEncoding( encoding ); |
| 9693 |
7 |
▶ | if ( enc == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc == 0 ) { |
0 |
7 |
7 |
|
| 9694 |
|
| /* this happens if the encoding is "" or NULL */ |
| 9695 |
0 |
| enc = XML_CHAR_ENCODING_UTF8; |
| 9696 |
|
| } |
| 9697 |
|
| |
| 9698 |
7 |
▶ | if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
1 |
6 |
7 |
|
| 9699 |
|
| /* copy the string */ |
| 9700 |
|
| /* warn( "simply copy the string" ); */ |
| 9701 |
1 |
| tstr = xmlStrdup( realstring ); |
| 9702 |
1 |
| len = xmlStrlen( tstr ); |
| 9703 |
|
| } |
| 9704 |
|
| else { |
| 9705 |
6 |
| INIT_ERROR_HANDLER; |
| 9706 |
6 |
▶ | if ( enc > 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc > 1 ) { |
6 |
0 |
6 |
|
| 9707 |
6 |
| coder= xmlGetCharEncodingHandler( enc ); |
| 9708 |
|
| } |
| 9709 |
0 |
▶ | else if ( enc == XML_CHAR_ENCODING_ERROR ){ |
Branch: 1 branch
| Branch | True | False | Total |
| else if ( enc == XML_CHAR_ENCODING_ERROR ){ |
0 |
0 |
0 |
|
| 9710 |
0 |
| coder = xmlFindCharEncodingHandler( encoding ); |
| 9711 |
|
| } |
| 9712 |
|
| else { |
| 9713 |
0 |
| croak("no encoder found\n"); |
| 9714 |
|
| } |
| 9715 |
|
| |
| 9716 |
6 |
▶ | if ( coder == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( coder == NULL ) { |
0 |
6 |
6 |
|
| 9717 |
0 |
| croak( "cannot encode string" ); |
| 9718 |
|
| } |
| 9719 |
|
| |
| 9720 |
6 |
| in = xmlBufferCreate(); |
| 9721 |
6 |
| out = xmlBufferCreate(); |
| 9722 |
6 |
| xmlBufferCCat( in, (char*) realstring ); |
| 9723 |
6 |
▶ | if ( xmlCharEncOutFunc( coder, out, in ) >= 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( xmlCharEncOutFunc( coder, out, in ) >= 0 ) { |
6 |
0 |
6 |
|
| 9724 |
6 |
| len = xmlBufferLength( out ); |
| 9725 |
6 |
| tstr = xmlCharStrndup( (char*) xmlBufferContent( out ), len ); |
| 9726 |
|
| } |
| 9727 |
|
| |
| 9728 |
6 |
| xmlBufferFree( in ); |
| 9729 |
6 |
| xmlBufferFree( out ); |
| 9730 |
6 |
| xmlCharEncCloseFunc( coder ); |
| 9731 |
6 |
| CLEANUP_ERROR_HANDLER; |
| 9732 |
6 |
| REPORT_ERROR(0); |
| 9733 |
6 |
▶ | if ( !tstr ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( !tstr ) { |
0 |
6 |
6 |
|
| 9734 |
0 |
| croak( "return value missing!" ); |
| 9735 |
|
| } |
| 9736 |
|
| } |
| 9737 |
|
| |
| 9738 |
7 |
| RETVAL = newSVpvn( (const char *)tstr, len ); |
| 9739 |
7 |
| xmlFree( tstr ); |
| 9740 |
|
| #ifdef HAVE_UTF8 |
| 9741 |
7 |
▶ | if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( enc == XML_CHAR_ENCODING_UTF8 ) { |
1 |
6 |
7 |
|
| 9742 |
1 |
| SvUTF8_on(RETVAL); |
| 9743 |
|
| } |
| 9744 |
|
| #endif |
| 9745 |
|
| } |
| 9746 |
|
| else { |
| 9747 |
0 |
| XSRETURN_UNDEF; |
| 9748 |
|
| } |
| 9749 |
|
| #ifdef HAVE_UTF8 |
| 9750 |
|
| } |
| 9751 |
|
| #endif |
| 9752 |
|
| OUTPUT: |
| 9753 |
|
| RETVAL |