| OLD | NEW |
| 1 /* | 1 /* |
| 2 * attributes.c: Implementation of the XSLT attributes handling | 2 * attributes.c: Implementation of the XSLT attributes handling |
| 3 * | 3 * |
| 4 * Reference: | 4 * Reference: |
| 5 * http://www.w3.org/TR/1999/REC-xslt-19991116 | 5 * http://www.w3.org/TR/1999/REC-xslt-19991116 |
| 6 * | 6 * |
| 7 * See Copyright for the status of this software. | 7 * See Copyright for the status of this software. |
| 8 * | 8 * |
| 9 * daniel@veillard.com | 9 * daniel@veillard.com |
| 10 */ | 10 */ |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 const xmlChar *ncname; | 290 const xmlChar *ncname; |
| 291 const xmlChar *prefix; | 291 const xmlChar *prefix; |
| 292 xmlChar *value; | 292 xmlChar *value; |
| 293 xmlNodePtr child; | 293 xmlNodePtr child; |
| 294 xsltAttrElemPtr attrItems; | 294 xsltAttrElemPtr attrItems; |
| 295 | 295 |
| 296 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE)) | 296 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE)) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL); | 299 value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL); |
| 300 if (value == NULL) { | 300 if ((value == NULL) || (*value == 0)) { |
| 301 xsltGenericError(xsltGenericErrorContext, | 301 xsltGenericError(xsltGenericErrorContext, |
| 302 "xsl:attribute-set : name is missing\n"); | 302 "xsl:attribute-set : name is missing\n"); |
| 303 if (value) |
| 304 xmlFree(value); |
| 303 return; | 305 return; |
| 304 } | 306 } |
| 305 | 307 |
| 306 ncname = xsltSplitQName(style->dict, value, &prefix); | 308 ncname = xsltSplitQName(style->dict, value, &prefix); |
| 307 xmlFree(value); | 309 xmlFree(value); |
| 308 value = NULL; | 310 value = NULL; |
| 309 | 311 |
| 310 if (style->attributeSets == NULL) { | 312 if (style->attributeSets == NULL) { |
| 311 #ifdef WITH_XSLT_DEBUG_ATTRIBUTES | 313 #ifdef WITH_XSLT_DEBUG_ATTRIBUTES |
| 312 xsltGenericDebug(xsltGenericDebugContext, | 314 xsltGenericDebug(xsltGenericDebugContext, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 while (style != NULL) { | 477 while (style != NULL) { |
| 476 values = xmlHashLookup2(style->attributeSets, name, ns); | 478 values = xmlHashLookup2(style->attributeSets, name, ns); |
| 477 if (values != NULL) | 479 if (values != NULL) |
| 478 return(values); | 480 return(values); |
| 479 style = xsltNextImport(style); | 481 style = xsltNextImport(style); |
| 480 } | 482 } |
| 481 return(NULL); | 483 return(NULL); |
| 482 } | 484 } |
| 483 | 485 |
| 484 /** | 486 /** |
| 485 * xsltResolveSASCallback,: | 487 * xsltResolveSASCallbackInt: |
| 486 * @style: the XSLT stylesheet | 488 * @style: the XSLT stylesheet |
| 487 * | 489 * |
| 488 * resolve the references in an attribute set. | 490 * resolve the references in an attribute set. |
| 489 */ | 491 */ |
| 490 static void | 492 static void |
| 491 xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, | 493 xsltResolveSASCallbackInt(xsltAttrElemPtr values, xsltStylesheetPtr style, |
| 492 const xmlChar *name, const xmlChar *ns, | 494 const xmlChar *name, const xmlChar *ns, |
| 493 » » ATTRIBUTE_UNUSED const xmlChar *ignored) { | 495 » » int depth) { |
| 494 xsltAttrElemPtr tmp; | 496 xsltAttrElemPtr tmp; |
| 495 xsltAttrElemPtr refs; | 497 xsltAttrElemPtr refs; |
| 496 | 498 |
| 497 tmp = values; | 499 tmp = values; |
| 500 if ((name == NULL) || (name[0] == 0)) |
| 501 return; |
| 502 if (depth > 100) { |
| 503 xsltGenericError(xsltGenericErrorContext, |
| 504 "xsl:attribute-set : use-attribute-sets recursion detected on %s\n", |
| 505 name); |
| 506 return; |
| 507 } |
| 498 while (tmp != NULL) { | 508 while (tmp != NULL) { |
| 499 if (tmp->set != NULL) { | 509 if (tmp->set != NULL) { |
| 500 /* | 510 /* |
| 501 * Check against cycles ! | 511 * Check against cycles ! |
| 502 */ | 512 */ |
| 503 if ((xmlStrEqual(name, tmp->set)) && (xmlStrEqual(ns, tmp->ns))) { | 513 if ((xmlStrEqual(name, tmp->set)) && (xmlStrEqual(ns, tmp->ns))) { |
| 504 xsltGenericError(xsltGenericErrorContext, | 514 xsltGenericError(xsltGenericErrorContext, |
| 505 "xsl:attribute-set : use-attribute-sets recursion detected on %s\n", | 515 "xsl:attribute-set : use-attribute-sets recursion detected on %s\n", |
| 506 name); | 516 name); |
| 507 } else { | 517 } else { |
| 508 #ifdef WITH_XSLT_DEBUG_ATTRIBUTES | 518 #ifdef WITH_XSLT_DEBUG_ATTRIBUTES |
| 509 xsltGenericDebug(xsltGenericDebugContext, | 519 xsltGenericDebug(xsltGenericDebugContext, |
| 510 "Importing attribute list %s\n", tmp->set); | 520 "Importing attribute list %s\n", tmp->set); |
| 511 #endif | 521 #endif |
| 512 | 522 |
| 513 refs = xsltGetSAS(style, tmp->set, tmp->ns); | 523 refs = xsltGetSAS(style, tmp->set, tmp->ns); |
| 514 if (refs == NULL) { | 524 if (refs == NULL) { |
| 515 xsltGenericError(xsltGenericErrorContext, | 525 xsltGenericError(xsltGenericErrorContext, |
| 516 "xsl:attribute-set : use-attribute-sets %s reference missing %s\n", | 526 "xsl:attribute-set : use-attribute-sets %s reference missing %s\n", |
| 517 name, tmp->set); | 527 name, tmp->set); |
| 518 } else { | 528 } else { |
| 519 /* | 529 /* |
| 520 * recurse first for cleanup | 530 * recurse first for cleanup |
| 521 */ | 531 */ |
| 522 » » xsltResolveSASCallback(refs, style, name, ns, NULL); | 532 » » xsltResolveSASCallbackInt(refs, style, name, ns, depth + 1); |
| 523 /* | 533 /* |
| 524 * Then merge | 534 * Then merge |
| 525 */ | 535 */ |
| 526 xsltMergeAttrElemList(style, values, refs); | 536 xsltMergeAttrElemList(style, values, refs); |
| 527 /* | 537 /* |
| 528 * Then suppress the reference | 538 * Then suppress the reference |
| 529 */ | 539 */ |
| 530 tmp->set = NULL; | 540 tmp->set = NULL; |
| 531 tmp->ns = NULL; | 541 tmp->ns = NULL; |
| 532 } | 542 } |
| 533 } | 543 } |
| 534 } | 544 } |
| 535 tmp = tmp->next; | 545 tmp = tmp->next; |
| 536 } | 546 } |
| 537 } | 547 } |
| 538 | 548 |
| 539 /** | 549 /** |
| 550 * xsltResolveSASCallback,: |
| 551 * @style: the XSLT stylesheet |
| 552 * |
| 553 * resolve the references in an attribute set. |
| 554 */ |
| 555 static void |
| 556 xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, |
| 557 const xmlChar *name, const xmlChar *ns, |
| 558 ATTRIBUTE_UNUSED const xmlChar *ignored) { |
| 559 xsltResolveSASCallbackInt(values, style, name, ns, 1); |
| 560 } |
| 561 |
| 562 /** |
| 540 * xsltMergeSASCallback,: | 563 * xsltMergeSASCallback,: |
| 541 * @style: the XSLT stylesheet | 564 * @style: the XSLT stylesheet |
| 542 * | 565 * |
| 543 * Merge an attribute set from an imported stylesheet. | 566 * Merge an attribute set from an imported stylesheet. |
| 544 */ | 567 */ |
| 545 static void | 568 static void |
| 546 xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, | 569 xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, |
| 547 const xmlChar *name, const xmlChar *ns, | 570 const xmlChar *name, const xmlChar *ns, |
| 548 ATTRIBUTE_UNUSED const xmlChar *ignored) { | 571 ATTRIBUTE_UNUSED const xmlChar *ignored) { |
| 549 int ret; | 572 int ret; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 * | 1153 * |
| 1131 * Free up the memory used by attribute sets | 1154 * Free up the memory used by attribute sets |
| 1132 */ | 1155 */ |
| 1133 void | 1156 void |
| 1134 xsltFreeAttributeSetsHashes(xsltStylesheetPtr style) { | 1157 xsltFreeAttributeSetsHashes(xsltStylesheetPtr style) { |
| 1135 if (style->attributeSets != NULL) | 1158 if (style->attributeSets != NULL) |
| 1136 xmlHashFree((xmlHashTablePtr) style->attributeSets, | 1159 xmlHashFree((xmlHashTablePtr) style->attributeSets, |
| 1137 (xmlHashDeallocator) xsltFreeAttrElemList); | 1160 (xmlHashDeallocator) xsltFreeAttrElemList); |
| 1138 style->attributeSets = NULL; | 1161 style->attributeSets = NULL; |
| 1139 } | 1162 } |
| OLD | NEW |