OLD | NEW |
1 /* | 1 /* |
2 * xslt.c: Implemetation of an XSL Transformation 1.0 engine | 2 * xslt.c: Implemetation of an XSL Transformation 1.0 engine |
3 * | 3 * |
4 * Reference: | 4 * Reference: |
5 * XSLT specification | 5 * XSLT specification |
6 * http://www.w3.org/TR/1999/REC-xslt-19991116 | 6 * http://www.w3.org/TR/1999/REC-xslt-19991116 |
7 * | 7 * |
8 * Associating Style Sheets with XML documents | 8 * Associating Style Sheets with XML documents |
9 * http://www.w3.org/1999/06/REC-xml-stylesheet-19990629 | 9 * http://www.w3.org/1999/06/REC-xml-stylesheet-19990629 |
10 * | 10 * |
(...skipping 5364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5375 prop = xmlGetNsProp(template, (const xmlChar *)"priority", NULL); | 5375 prop = xmlGetNsProp(template, (const xmlChar *)"priority", NULL); |
5376 if (prop != NULL) { | 5376 if (prop != NULL) { |
5377 priority = xmlXPathStringEvalNumber(prop); | 5377 priority = xmlXPathStringEvalNumber(prop); |
5378 ret->priority = (float) priority; | 5378 ret->priority = (float) priority; |
5379 xmlFree(prop); | 5379 xmlFree(prop); |
5380 } | 5380 } |
5381 | 5381 |
5382 prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL); | 5382 prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL); |
5383 if (prop != NULL) { | 5383 if (prop != NULL) { |
5384 const xmlChar *URI; | 5384 const xmlChar *URI; |
5385 xsltTemplatePtr cur; | |
5386 | 5385 |
5387 /* | 5386 /* |
5388 * TODO: Don't use xsltGetQNameURI(). | 5387 * TODO: Don't use xsltGetQNameURI(). |
5389 */ | 5388 */ |
5390 URI = xsltGetQNameURI(template, &prop); | 5389 URI = xsltGetQNameURI(template, &prop); |
5391 if (prop == NULL) { | 5390 if (prop == NULL) { |
5392 if (style != NULL) style->errors++; | 5391 if (style != NULL) style->errors++; |
5393 goto error; | 5392 goto error; |
5394 } else { | 5393 } else { |
5395 if (xmlValidateNCName(prop,0)) { | 5394 if (xmlValidateNCName(prop,0)) { |
5396 xsltTransformError(NULL, style, template, | 5395 xsltTransformError(NULL, style, template, |
5397 "xsl:template : error invalid name '%s'\n", prop); | 5396 "xsl:template : error invalid name '%s'\n", prop); |
5398 if (style != NULL) style->errors++; | 5397 if (style != NULL) style->errors++; |
5399 goto error; | 5398 goto error; |
5400 } | 5399 } |
5401 ret->name = xmlDictLookup(style->dict, BAD_CAST prop, -1); | 5400 ret->name = xmlDictLookup(style->dict, BAD_CAST prop, -1); |
5402 xmlFree(prop); | 5401 xmlFree(prop); |
5403 prop = NULL; | 5402 prop = NULL; |
5404 if (URI != NULL) | 5403 if (URI != NULL) |
5405 ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1); | 5404 ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1); |
5406 else | 5405 else |
5407 ret->nameURI = NULL; | 5406 ret->nameURI = NULL; |
5408 cur = ret->next; | |
5409 while (cur != NULL) { | |
5410 if ((URI != NULL && xmlStrEqual(cur->name, ret->name) && | |
5411 xmlStrEqual(cur->nameURI, URI) ) || | |
5412 (URI == NULL && cur->nameURI == NULL && | |
5413 xmlStrEqual(cur->name, ret->name))) { | |
5414 xsltTransformError(NULL, style, template, | |
5415 "xsl:template: error duplicate name '%s'\n", ret->name); | |
5416 style->errors++; | |
5417 goto error; | |
5418 } | |
5419 cur = cur->next; | |
5420 } | |
5421 } | 5407 } |
5422 } | 5408 } |
5423 | 5409 |
5424 /* | 5410 /* |
5425 * parse the content and register the pattern | 5411 * parse the content and register the pattern |
5426 */ | 5412 */ |
5427 xsltParseTemplateContent(style, template); | 5413 xsltParseTemplateContent(style, template); |
5428 ret->elem = template; | 5414 ret->elem = template; |
5429 ret->content = template->children; | 5415 ret->content = template->children; |
5430 xsltAddTemplate(style, ret, ret->mode, ret->modeURI); | 5416 xsltAddTemplate(style, ret, ret->mode, ret->modeURI); |
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7002 ret = xsltParseStylesheetFile(href); | 6988 ret = xsltParseStylesheetFile(href); |
7003 } | 6989 } |
7004 if (base != NULL) | 6990 if (base != NULL) |
7005 xmlFree(base); | 6991 xmlFree(base); |
7006 } | 6992 } |
7007 xmlFreeURI(URI); | 6993 xmlFreeURI(URI); |
7008 xmlFree(href); | 6994 xmlFree(href); |
7009 } | 6995 } |
7010 return(ret); | 6996 return(ret); |
7011 } | 6997 } |
OLD | NEW |