OLD | NEW |
1 /* | 1 /* |
2 * functions.c: Implementation of the XSLT extra functions | 2 * functions.c: Implementation of the XSLT extra functions |
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 * Bjorn Reese <breese@users.sourceforge.net> for number formatting | 10 * Bjorn Reese <breese@users.sourceforge.net> for number formatting |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 * Implement the format-number() XSLT function | 596 * Implement the format-number() XSLT function |
597 * string format-number(number, string, string?) | 597 * string format-number(number, string, string?) |
598 */ | 598 */ |
599 void | 599 void |
600 xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) | 600 xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) |
601 { | 601 { |
602 xmlXPathObjectPtr numberObj = NULL; | 602 xmlXPathObjectPtr numberObj = NULL; |
603 xmlXPathObjectPtr formatObj = NULL; | 603 xmlXPathObjectPtr formatObj = NULL; |
604 xmlXPathObjectPtr decimalObj = NULL; | 604 xmlXPathObjectPtr decimalObj = NULL; |
605 xsltStylesheetPtr sheet; | 605 xsltStylesheetPtr sheet; |
606 xsltDecimalFormatPtr formatValues; | 606 xsltDecimalFormatPtr formatValues = NULL; |
607 xmlChar *result; | 607 xmlChar *result; |
| 608 const xmlChar *ncname; |
| 609 const xmlChar *prefix = NULL; |
| 610 const xmlChar *nsUri = NULL; |
608 xsltTransformContextPtr tctxt; | 611 xsltTransformContextPtr tctxt; |
609 | 612 |
610 tctxt = xsltXPathGetTransformContext(ctxt); | 613 tctxt = xsltXPathGetTransformContext(ctxt); |
611 if (tctxt == NULL) | 614 if ((tctxt == NULL) || (tctxt->inst == NULL)) |
612 return; | 615 return; |
613 sheet = tctxt->style; | 616 sheet = tctxt->style; |
614 if (sheet == NULL) | 617 if (sheet == NULL) |
615 return; | 618 return; |
616 formatValues = sheet->decimalFormat; | 619 formatValues = sheet->decimalFormat; |
617 | 620 |
618 switch (nargs) { | 621 switch (nargs) { |
619 case 3: | 622 case 3: |
620 CAST_TO_STRING; | 623 CAST_TO_STRING; |
621 decimalObj = valuePop(ctxt); | 624 decimalObj = valuePop(ctxt); |
622 » formatValues = xsltDecimalFormatGetByName(sheet, decimalObj->stringval); | 625 ncname = xsltSplitQName(sheet->dict, decimalObj->stringval, &prefix); |
| 626 if (prefix != NULL) { |
| 627 xmlNsPtr ns = xmlSearchNs(tctxt->inst->doc, tctxt->inst, prefix); |
| 628 if (ns == NULL) { |
| 629 xsltTransformError(tctxt, NULL, NULL, |
| 630 "format-number : No namespace found for QName '%s:%s'\n", |
| 631 prefix, ncname); |
| 632 sheet->errors++; |
| 633 ncname = NULL; |
| 634 } |
| 635 nsUri = ns->href; |
| 636 } |
| 637 if (ncname != NULL) { |
| 638 » formatValues = xsltDecimalFormatGetByQName(sheet, nsUri, ncname); |
| 639 } |
623 if (formatValues == NULL) { | 640 if (formatValues == NULL) { |
624 xsltTransformError(tctxt, NULL, NULL, | 641 xsltTransformError(tctxt, NULL, NULL, |
625 "format-number() : undeclared decimal format '%s'\n", | 642 "format-number() : undeclared decimal format '%s'\n", |
626 decimalObj->stringval); | 643 decimalObj->stringval); |
627 } | 644 } |
628 /* Intentional fall-through */ | 645 /* Intentional fall-through */ |
629 case 2: | 646 case 2: |
630 CAST_TO_STRING; | 647 CAST_TO_STRING; |
631 formatObj = valuePop(ctxt); | 648 formatObj = valuePop(ctxt); |
632 CAST_TO_NUMBER; | 649 CAST_TO_NUMBER; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 xsltFormatNumberFunction); | 996 xsltFormatNumberFunction); |
980 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "generate-id", | 997 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "generate-id", |
981 xsltGenerateIdFunction); | 998 xsltGenerateIdFunction); |
982 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "system-property", | 999 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "system-property", |
983 xsltSystemPropertyFunction); | 1000 xsltSystemPropertyFunction); |
984 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "element-available", | 1001 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "element-available", |
985 xsltElementAvailableFunction); | 1002 xsltElementAvailableFunction); |
986 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "function-available", | 1003 xmlXPathRegisterFunc(ctxt, (const xmlChar *) "function-available", |
987 xsltFunctionAvailableFunction); | 1004 xsltFunctionAvailableFunction); |
988 } | 1005 } |
OLD | NEW |