ReactOS 0.4.16-dev-2279-gc890759
attributes.h File Reference
#include <libxml/tree.h>
#include "xsltexports.h"
#include "xsltInternals.h"
Include dependency graph for attributes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XSLTPUBFUN void XSLTCALL xsltParseStylesheetAttributeSet (xsltStylesheetPtr style, xmlNodePtr cur)
 
XSLTPUBFUN void XSLTCALL xsltFreeAttributeSetsHashes (xsltStylesheetPtr style)
 
XSLTPUBFUN void XSLTCALL xsltApplyAttributeSet (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, const xmlChar *attributes)
 
XSLTPUBFUN void XSLTCALL xsltResolveStylesheetAttributeSet (xsltStylesheetPtr style)
 

Function Documentation

◆ xsltApplyAttributeSet()

XSLTPUBFUN void XSLTCALL xsltApplyAttributeSet ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
const xmlChar attrSets 
)

xsltApplyAttributeSet: @ctxt: the XSLT stylesheet @node: the node in the source tree. @inst: the attribute node "xsl:use-attribute-sets" @attrSets: the list of QNames of the attribute-sets to be applied

Apply the xsl:use-attribute-sets. If @attrSets is NULL, then @inst will be used to exctract this value. If both, @attrSets and @inst, are NULL, then this will do nothing.

Definition at line 1118 of file attributes.c.

1121{
1122 const xmlChar *ncname = NULL;
1123 const xmlChar *prefix = NULL;
1124 const xmlChar *curstr, *endstr;
1127
1128 if (attrSets == NULL) {
1129 if (inst == NULL)
1130 return;
1131 else {
1132 /*
1133 * Extract the value from @inst.
1134 */
1135 if (inst->type == XML_ATTRIBUTE_NODE) {
1136 if ( ((xmlAttrPtr) inst)->children != NULL)
1137 attrSets = ((xmlAttrPtr) inst)->children->content;
1138
1139 }
1140 if (attrSets == NULL) {
1141 /*
1142 * TODO: Return an error?
1143 */
1144 return;
1145 }
1146 }
1147 }
1148 /*
1149 * Parse/apply the list of QNames.
1150 */
1151 curstr = attrSets;
1152 while (*curstr != 0) {
1153 while (IS_BLANK(*curstr))
1154 curstr++;
1155 if (*curstr == 0)
1156 break;
1157 endstr = curstr;
1158 while ((*endstr != 0) && (!IS_BLANK(*endstr)))
1159 endstr++;
1160 curstr = xmlDictLookup(ctxt->dict, curstr, endstr - curstr);
1161 if (curstr) {
1162 xmlNsPtr ns;
1163 const xmlChar *nsUri = NULL;
1164
1165#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
1167 "apply attribute set %s\n", curstr);
1168#endif
1169
1170 if (xmlValidateQName(curstr, 0)) {
1171 xsltTransformError(ctxt, NULL, inst,
1172 "The name '%s' in use-attribute-sets is not a valid "
1173 "QName.\n", curstr);
1174 return;
1175 }
1176
1177 ncname = xsltSplitQName(ctxt->dict, curstr, &prefix);
1178 if (prefix != NULL) {
1179 ns = xmlSearchNs(inst->doc, inst, prefix);
1180 if (ns == NULL) {
1181 xsltTransformError(ctxt, NULL, inst,
1182 "use-attribute-set : No namespace found for QName "
1183 "'%s:%s'\n", prefix, ncname);
1184 return;
1185 }
1186 nsUri = ns->href;
1187 }
1188
1189 style = ctxt->style;
1190
1191#ifdef WITH_DEBUGGER
1192 if ((style != NULL) &&
1193 (style->attributeSets != NULL) &&
1194 (ctxt->debugStatus != XSLT_DEBUG_NONE))
1195 {
1196 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
1197 if ((set != NULL) && (set->attrs != NULL) &&
1198 (set->attrs->attr != NULL))
1199 xslHandleDebugger(set->attrs->attr->parent, node, NULL,
1200 ctxt);
1201 }
1202#endif
1203 /*
1204 * Lookup the referenced attribute-set. All attribute sets were
1205 * moved to the top stylesheet so there's no need to iterate
1206 * imported stylesheets
1207 */
1208 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
1209 if (set != NULL) {
1210 xsltAttrElemPtr cur = set->attrs;
1211 while (cur != NULL) {
1212 if (cur->attr != NULL) {
1213 xsltAttribute(ctxt, node, cur->attr,
1214 cur->attr->psvi);
1215 }
1216 cur = cur->next;
1217 }
1218 }
1219 }
1220 curstr = endstr;
1221 }
1222}
Arabic default style
Definition: afstyles.h:94
Definition: _set.h:50
#define NULL
Definition: types.h:112
#define IS_BLANK(c)
Definition: attributes.c:45
void xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: attributes.c:748
FxCollectionEntry * cur
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
void * xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2)
Definition: hash.c:754
xsltStylesheetPtr style
Definition: mxnamespace.c:38
Character const *const prefix
Definition: tempnam.cpp:195
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
Definition: dlist.c:348
unsigned char xmlChar
Definition: xmlstring.h:28
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:804
@ XSLT_DEBUG_NONE
Definition: xsltutils.h:304

Referenced by xsltAttrListTemplateProcess(), xsltCopy(), and xsltElement().

◆ xsltFreeAttributeSetsHashes()

XSLTPUBFUN void XSLTCALL xsltFreeAttributeSetsHashes ( xsltStylesheetPtr  style)

xsltFreeAttributeSetsHashes: @style: an XSLT stylesheet

Free up the memory used by attribute sets

Definition at line 1237 of file attributes.c.

1237 {
1238 if (style->attributeSets != NULL)
1239 xmlHashFree((xmlHashTablePtr) style->attributeSets,
1241 style->attributeSets = NULL;
1242}
static void xsltFreeAttributeSetsEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: attributes.c:1225
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229

Referenced by xsltFreeStylesheet().

◆ xsltParseStylesheetAttributeSet()

XSLTPUBFUN void XSLTCALL xsltParseStylesheetAttributeSet ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseStylesheetAttributeSet: @style: the XSLT stylesheet @cur: the "attribute-set" element

parse an XSLT stylesheet attribute-set element

Definition at line 368 of file attributes.c.

368 {
369 const xmlChar *ncname;
370 const xmlChar *prefix;
371 const xmlChar *nsUri = NULL;
372 xmlChar *value;
373 xmlNodePtr child;
375
376 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
377 return;
378
379 value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
380 if ((value == NULL) || (*value == 0)) {
382 "xsl:attribute-set : name is missing\n");
383 if (value)
384 xmlFree(value);
385 return;
386 }
387
388 if (xmlValidateQName(value, 0)) {
390 "xsl:attribute-set : The name '%s' is not a valid QName.\n",
391 value);
392 style->errors++;
393 xmlFree(value);
394 return;
395 }
396
397 ncname = xsltSplitQName(style->dict, value, &prefix);
398 xmlFree(value);
399 value = NULL;
400 if (prefix != NULL) {
401 xmlNsPtr ns = xmlSearchNs(style->doc, cur, prefix);
402 if (ns == NULL) {
404 "xsl:attribute-set : No namespace found for QName '%s:%s'\n",
405 prefix, ncname);
406 style->errors++;
407 return;
408 }
409 nsUri = ns->href;
410 }
411
412 if (style->attributeSets == NULL) {
413#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
415 "creating attribute set table\n");
416#endif
417 style->attributeSets = xmlHashCreate(10);
418 }
419 if (style->attributeSets == NULL)
420 return;
421
422 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
423 if (set == NULL) {
425 if ((set == NULL) ||
426 (xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set) < 0)) {
427 xsltGenericError(xsltGenericErrorContext, "memory error\n");
429 return;
430 }
431 }
432
433 /*
434 * Parse the content. Only xsl:attribute elements are allowed.
435 */
436 child = cur->children;
437 while (child != NULL) {
438 /*
439 * Report invalid nodes.
440 */
441 if ((child->type != XML_ELEMENT_NODE) ||
442 (child->ns == NULL) ||
443 (! IS_XSLT_ELEM(child)))
444 {
445 if (child->type == XML_ELEMENT_NODE)
447 "xsl:attribute-set : unexpected child %s\n",
448 child->name);
449 else
451 "xsl:attribute-set : child of unexpected type\n");
452 } else if (!IS_XSLT_NAME(child, "attribute")) {
454 "xsl:attribute-set : unexpected child xsl:%s\n",
455 child->name);
456 } else {
457#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
459 "add attribute to list %s\n", ncname);
460#endif
462 if (child->children != NULL) {
463#ifdef XSLT_REFACTORED
464 xsltParseSequenceConstructor(XSLT_CCTXT(style),
465 child->children);
466#else
468#endif
469 }
470 if (child->psvi == NULL) {
472 "xsl:attribute-set : internal error, attribute %s not "
473 "compiled\n", child->name);
474 }
475 else {
476 set->attrs = xsltAddAttrElemList(set->attrs, child);
477 }
478 }
479
480 child = child->next;
481 }
482
483 /*
484 * Process attribute "use-attribute-sets".
485 */
486 value = xmlGetNsProp(cur, BAD_CAST "use-attribute-sets", NULL);
487 if (value != NULL) {
488 const xmlChar *curval, *endval;
489 curval = value;
490 while (*curval != 0) {
491 while (IS_BLANK(*curval)) curval++;
492 if (*curval == 0)
493 break;
494 endval = curval;
495 while ((*endval != 0) && (!IS_BLANK(*endval))) endval++;
496 curval = xmlDictLookup(style->dict, curval, endval - curval);
497 if (curval) {
498 const xmlChar *ncname2 = NULL;
499 const xmlChar *prefix2 = NULL;
500 const xmlChar *nsUri2 = NULL;
501
502#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
504 "xsl:attribute-set : %s adds use %s\n", ncname, curval);
505#endif
506
507 if (xmlValidateQName(curval, 0)) {
509 "xsl:attribute-set : The name '%s' in "
510 "use-attribute-sets is not a valid QName.\n", curval);
511 style->errors++;
512 xmlFree(value);
513 return;
514 }
515
516 ncname2 = xsltSplitQName(style->dict, curval, &prefix2);
517 if (prefix2 != NULL) {
518 xmlNsPtr ns2 = xmlSearchNs(style->doc, cur, prefix2);
519 if (ns2 == NULL) {
521 "xsl:attribute-set : No namespace found for QName "
522 "'%s:%s' in use-attribute-sets\n",
523 prefix2, ncname2);
524 style->errors++;
525 xmlFree(value);
526 return;
527 }
528 nsUri2 = ns2->href;
529 }
530 set->useAttrSets = xsltAddUseAttrSetList(set->useAttrSets,
531 ncname2, nsUri2);
532 }
533 curval = endval;
534 }
535 xmlFree(value);
536 value = NULL;
537 }
538
539#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
541 "updated attribute list %s\n", ncname);
542#endif
543}
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2191
static xsltAttrElemPtr xsltAddAttrElemList(xsltAttrElemPtr list, xmlNodePtr attr)
Definition: attributes.c:165
static xsltUseAttrSetPtr xsltAddUseAttrSetList(xsltUseAttrSetPtr list, const xmlChar *ncname, const xmlChar *ns)
Definition: attributes.c:248
static void xsltFreeAttrSet(xsltAttrSetPtr set)
Definition: attributes.c:298
static xsltAttrSetPtr xsltNewAttrSet(void)
Definition: attributes.c:278
static HWND child
Definition: cursoricon.c:298
xmlFreeFunc xmlFree
Definition: globals.c:184
xmlHashTablePtr xmlHashCreate(int size)
Definition: hash.c:160
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639
Definition: pdh_main.c:96
#define BAD_CAST
Definition: xmlstring.h:35
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4894
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586
void * xsltGenericErrorContext
Definition: xsltutils.c:587
#define IS_XSLT_NAME(n, val)
Definition: xsltutils.h:60
#define IS_XSLT_ELEM(n)
Definition: xsltutils.h:51

Referenced by xsltParseStylesheetTop().

◆ xsltResolveStylesheetAttributeSet()

XSLTPUBFUN void XSLTCALL xsltResolveStylesheetAttributeSet ( xsltStylesheetPtr  style)

xsltResolveStylesheetAttributeSet: @style: the XSLT stylesheet

resolve the references between attribute sets.

Definition at line 701 of file attributes.c.

701 {
703 xsltAttrSetContext asctx;
704
705#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
707 "Resolving attribute sets references\n");
708#endif
709 asctx.topStyle = style;
710 asctx.error = 0;
711 cur = style;
712 while (cur != NULL) {
713 if (cur->attributeSets != NULL) {
714 if (style->attributeSets == NULL) {
715#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
717 "creating attribute set table\n");
718#endif
719 style->attributeSets = xmlHashCreate(10);
720 }
721 asctx.style = cur;
723 &asctx);
724
725 if (cur != style) {
726 /*
727 * the attribute lists have either been migrated to style
728 * or freed directly in xsltResolveSASCallback()
729 */
730 xmlHashFree(cur->attributeSets, NULL);
731 cur->attributeSets = NULL;
732 }
733 }
735 }
736}
static void xsltResolveSASCallback(void *payload, void *data, const xmlChar *name, const xmlChar *ns, ATTRIBUTE_UNUSED const xmlChar *ignored)
Definition: attributes.c:662
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
void xmlHashScanFull(xmlHashTablePtr hash, xmlHashScannerFull scan, void *data)
Definition: hash.c:914
xsltStylesheetPtr style
Definition: attributes.c:89
xsltStylesheetPtr topStyle
Definition: attributes.c:88

Referenced by xsltParseStylesheetUser().