* xmlXIncludeAddNode: * @ctxt: the XInclude context * @cur: the new node * * Add a new node to process to an XInclude context */
| 374 | * Add a new node to process to an XInclude context |
| 375 | */ |
| 376 | static xmlXIncludeRefPtr |
| 377 | xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { |
| 378 | xmlXIncludeRefPtr ref = NULL; |
| 379 | xmlXIncludeRefPtr ret = NULL; |
| 380 | xmlURIPtr uri = NULL; |
| 381 | xmlChar *href = NULL; |
| 382 | xmlChar *parse = NULL; |
| 383 | xmlChar *fragment = NULL; |
| 384 | xmlChar *base = NULL; |
| 385 | xmlChar *tmp; |
| 386 | int xml = 1; |
| 387 | int local = 0; |
| 388 | int res; |
| 389 | |
| 390 | if (ctxt == NULL) |
| 391 | return(NULL); |
| 392 | if (cur == NULL) |
| 393 | return(NULL); |
| 394 | |
| 395 | /* |
| 396 | * read the attributes |
| 397 | */ |
| 398 | |
| 399 | fragment = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE_XPOINTER); |
| 400 | |
| 401 | href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); |
| 402 | if (href == NULL) { |
| 403 | if (fragment == NULL) { |
| 404 | xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_NO_HREF, |
| 405 | "href or xpointer must be present\n", parse); |
| 406 | goto error; |
| 407 | } |
| 408 | |
| 409 | href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ |
| 410 | if (href == NULL) { |
| 411 | xmlXIncludeErrMemory(ctxt); |
| 412 | goto error; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); |
| 417 | if (parse != NULL) { |
| 418 | if (xmlStrEqual(parse, XINCLUDE_PARSE_XML)) |
| 419 | xml = 1; |
| 420 | else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT)) |
| 421 | xml = 0; |
| 422 | else { |
| 423 | xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_PARSE_VALUE, |
| 424 | "invalid value %s for 'parse'\n", parse); |
| 425 | goto error; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | /* |
| 430 | * Check the URL and remove any fragment identifier |
| 431 | */ |
| 432 | res = xmlParseURISafe((const char *)href, &uri); |
| 433 | if (uri == NULL) { |
no test coverage detected