OLD | NEW |
1 /* | 1 /* |
2 * variables.c: Implementation of the variable storage and lookup | 2 * variables.c: Implementation of the variable storage and lookup |
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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 style = ctxt->style; | 1438 style = ctxt->style; |
1439 | 1439 |
1440 #ifdef WITH_XSLT_DEBUG_VARIABLE | 1440 #ifdef WITH_XSLT_DEBUG_VARIABLE |
1441 XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContex
t, | 1441 XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContex
t, |
1442 "Evaluating user parameter %s=%s\n", name, value)); | 1442 "Evaluating user parameter %s=%s\n", name, value)); |
1443 #endif | 1443 #endif |
1444 | 1444 |
1445 /* | 1445 /* |
1446 * Name lookup | 1446 * Name lookup |
1447 */ | 1447 */ |
| 1448 href = NULL; |
1448 | 1449 |
1449 name = xsltSplitQName(ctxt->dict, name, &prefix); | 1450 if (name[0] == '{') { |
1450 href = NULL; | 1451 int len = 0; |
1451 if (prefix != NULL) { | |
1452 » xmlNsPtr ns; | |
1453 | 1452 |
1454 » ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc), | 1453 while ((name[len] != 0) && (name[len] != '}')) len++; |
1455 » » » prefix); | 1454 if (name[len] == 0) { |
1456 » if (ns == NULL) { | 1455 xsltTransformError(ctxt, style, NULL, |
1457 » xsltTransformError(ctxt, style, NULL, | 1456 "user param : malformed parameter name : %s\n", name); |
1458 » "user param : no namespace bound to prefix %s\n", prefix); | 1457 } else { |
1459 » href = NULL; | 1458 href = xmlDictLookup(ctxt->dict, &name[1], len-1); |
1460 » } else { | 1459 name = xmlDictLookup(ctxt->dict, &name[len + 1], -1); |
1461 » href = ns->href; | 1460 } |
1462 » } | 1461 } |
| 1462 else { |
| 1463 name = xsltSplitQName(ctxt->dict, name, &prefix); |
| 1464 if (prefix != NULL) { |
| 1465 xmlNsPtr ns; |
| 1466 |
| 1467 ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc), |
| 1468 prefix); |
| 1469 if (ns == NULL) { |
| 1470 xsltTransformError(ctxt, style, NULL, |
| 1471 "user param : no namespace bound to prefix %s\n", prefix); |
| 1472 href = NULL; |
| 1473 } else { |
| 1474 href = ns->href; |
| 1475 } |
| 1476 } |
1463 } | 1477 } |
1464 | 1478 |
1465 if (name == NULL) | 1479 if (name == NULL) |
1466 return (-1); | 1480 return (-1); |
1467 | 1481 |
1468 res_ptr = xmlHashLookup2(ctxt->globalVars, name, href); | 1482 res_ptr = xmlHashLookup2(ctxt->globalVars, name, href); |
1469 if (res_ptr != 0) { | 1483 if (res_ptr != 0) { |
1470 xsltTransformError(ctxt, style, NULL, | 1484 xsltTransformError(ctxt, style, NULL, |
1471 "Global parameter %s already defined\n", name); | 1485 "Global parameter %s already defined\n", name); |
1472 } | 1486 } |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2312 #ifdef WITH_XSLT_DEBUG_VARIABLE | 2326 #ifdef WITH_XSLT_DEBUG_VARIABLE |
2313 XSLT_TRACE(tctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugC
ontext, | 2327 XSLT_TRACE(tctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugC
ontext, |
2314 "found variable '%s'\n", name)); | 2328 "found variable '%s'\n", name)); |
2315 #endif | 2329 #endif |
2316 } | 2330 } |
2317 | 2331 |
2318 return(valueObj); | 2332 return(valueObj); |
2319 } | 2333 } |
2320 | 2334 |
2321 | 2335 |
OLD | NEW |