ReactOS 0.4.15-dev-8207-gd73a838
attributes.h File Reference
#include <libxml/tree.h>
#include "xsltexports.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 1086 of file attributes.c.

1089{
1090 const xmlChar *ncname = NULL;
1091 const xmlChar *prefix = NULL;
1092 const xmlChar *curstr, *endstr;
1095
1096 if (attrSets == NULL) {
1097 if (inst == NULL)
1098 return;
1099 else {
1100 /*
1101 * Extract the value from @inst.
1102 */
1103 if (inst->type == XML_ATTRIBUTE_NODE) {
1104 if ( ((xmlAttrPtr) inst)->children != NULL)
1105 attrSets = ((xmlAttrPtr) inst)->children->content;
1106
1107 }
1108 if (attrSets == NULL) {
1109 /*
1110 * TODO: Return an error?
1111 */
1112 return;
1113 }
1114 }
1115 }
1116 /*
1117 * Parse/apply the list of QNames.
1118 */
1119 curstr = attrSets;
1120 while (*curstr != 0) {
1121 while (IS_BLANK(*curstr))
1122 curstr++;
1123 if (*curstr == 0)
1124 break;
1125 endstr = curstr;
1126 while ((*endstr != 0) && (!IS_BLANK(*endstr)))
1127 endstr++;
1128 curstr = xmlDictLookup(ctxt->dict, curstr, endstr - curstr);
1129 if (curstr) {
1130 xmlNsPtr ns;
1131 const xmlChar *nsUri = NULL;
1132
1133#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
1135 "apply attribute set %s\n", curstr);
1136#endif
1137
1138 if (xmlValidateQName(curstr, 0)) {
1139 xsltTransformError(ctxt, NULL, inst,
1140 "The name '%s' in use-attribute-sets is not a valid "
1141 "QName.\n", curstr);
1142 return;
1143 }
1144
1145 ncname = xsltSplitQName(ctxt->dict, curstr, &prefix);
1146 if (prefix != NULL) {
1147 ns = xmlSearchNs(inst->doc, inst, prefix);
1148 if (ns == NULL) {
1149 xsltTransformError(ctxt, NULL, inst,
1150 "use-attribute-set : No namespace found for QName "
1151 "'%s:%s'\n", prefix, ncname);
1152 return;
1153 }
1154 nsUri = ns->href;
1155 }
1156
1157 style = ctxt->style;
1158
1159#ifdef WITH_DEBUGGER
1160 if ((style != NULL) &&
1161 (style->attributeSets != NULL) &&
1162 (ctxt->debugStatus != XSLT_DEBUG_NONE))
1163 {
1164 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
1165 if ((set != NULL) && (set->attrs != NULL) &&
1166 (set->attrs->attr != NULL))
1167 xslHandleDebugger(set->attrs->attr->parent, node, NULL,
1168 ctxt);
1169 }
1170#endif
1171 /*
1172 * Lookup the referenced attribute-set. All attribute sets were
1173 * moved to the top stylesheet so there's no need to iterate
1174 * imported stylesheets
1175 */
1176 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
1177 if (set != NULL) {
1178 xsltAttrElemPtr cur = set->attrs;
1179 while (cur != NULL) {
1180 if (cur->attr != NULL) {
1181 xsltAttribute(ctxt, node, cur->attr,
1182 cur->attr->psvi);
1183 }
1184 cur = cur->next;
1185 }
1186 }
1187 }
1188 curstr = endstr;
1189 }
1190}
Arabic default style
Definition: afstyles.h:94
Definition: _set.h:50
#define NULL
Definition: types.h:112
#define IS_BLANK(c)
Definition: attributes.c:26
void xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr inst, xsltElemPreCompPtr castedComp)
Definition: attributes.c:716
FxCollectionEntry * cur
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:476
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
@ XML_ATTRIBUTE_NODE
Definition: tree.h:161
xmlAttr * xmlAttrPtr
Definition: tree.h:433
Definition: tree.h:434
struct _xmlDoc * doc
Definition: tree.h:498
xmlElementType type
Definition: tree.h:491
Definition: tree.h:389
xsltStylesheetPtr style
Definition: mxnamespace.c:45
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:678
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
void * xsltGenericDebugContext
Definition: xsltutils.c:549
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:720
@ XSLT_DEBUG_NONE
Definition: xsltutils.h:273

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 1205 of file attributes.c.

1205 {
1206 if (style->attributeSets != NULL)
1207 xmlHashFree((xmlHashTablePtr) style->attributeSets,
1209 style->attributeSets = NULL;
1210}
static void xsltFreeAttributeSetsEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: attributes.c:1193
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322

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 348 of file attributes.c.

348 {
349 const xmlChar *ncname;
350 const xmlChar *prefix;
351 const xmlChar *nsUri = NULL;
352 xmlChar *value;
355
356 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
357 return;
358
359 value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
360 if ((value == NULL) || (*value == 0)) {
362 "xsl:attribute-set : name is missing\n");
363 if (value)
364 xmlFree(value);
365 return;
366 }
367
368 if (xmlValidateQName(value, 0)) {
370 "xsl:attribute-set : The name '%s' is not a valid QName.\n",
371 value);
372 style->errors++;
373 xmlFree(value);
374 return;
375 }
376
377 ncname = xsltSplitQName(style->dict, value, &prefix);
378 xmlFree(value);
379 value = NULL;
380 if (prefix != NULL) {
381 xmlNsPtr ns = xmlSearchNs(style->doc, cur, prefix);
382 if (ns == NULL) {
384 "xsl:attribute-set : No namespace found for QName '%s:%s'\n",
385 prefix, ncname);
386 style->errors++;
387 return;
388 }
389 nsUri = ns->href;
390 }
391
392 if (style->attributeSets == NULL) {
393#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
395 "creating attribute set table\n");
396#endif
397 style->attributeSets = xmlHashCreate(10);
398 }
399 if (style->attributeSets == NULL)
400 return;
401
402 set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
403 if (set == NULL) {
405 if (set == NULL)
406 return;
407 xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set);
408 }
409
410 /*
411 * Parse the content. Only xsl:attribute elements are allowed.
412 */
413 child = cur->children;
414 while (child != NULL) {
415 /*
416 * Report invalid nodes.
417 */
418 if ((child->type != XML_ELEMENT_NODE) ||
419 (child->ns == NULL) ||
420 (! IS_XSLT_ELEM(child)))
421 {
422 if (child->type == XML_ELEMENT_NODE)
424 "xsl:attribute-set : unexpected child %s\n",
425 child->name);
426 else
428 "xsl:attribute-set : child of unexpected type\n");
429 } else if (!IS_XSLT_NAME(child, "attribute")) {
431 "xsl:attribute-set : unexpected child xsl:%s\n",
432 child->name);
433 } else {
434#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
436 "add attribute to list %s\n", ncname);
437#endif
439 if (child->children != NULL) {
440#ifdef XSLT_REFACTORED
441 xsltParseSequenceConstructor(XSLT_CCTXT(style),
442 child->children);
443#else
445#endif
446 }
447 if (child->psvi == NULL) {
449 "xsl:attribute-set : internal error, attribute %s not "
450 "compiled\n", child->name);
451 }
452 else {
453 set->attrs = xsltAddAttrElemList(set->attrs, child);
454 }
455 }
456
457 child = child->next;
458 }
459
460 /*
461 * Process attribute "use-attribute-sets".
462 */
463 value = xmlGetNsProp(cur, BAD_CAST "use-attribute-sets", NULL);
464 if (value != NULL) {
465 const xmlChar *curval, *endval;
466 curval = value;
467 while (*curval != 0) {
468 while (IS_BLANK(*curval)) curval++;
469 if (*curval == 0)
470 break;
471 endval = curval;
472 while ((*endval != 0) && (!IS_BLANK(*endval))) endval++;
473 curval = xmlDictLookup(style->dict, curval, endval - curval);
474 if (curval) {
475 const xmlChar *ncname2 = NULL;
476 const xmlChar *prefix2 = NULL;
477 const xmlChar *nsUri2 = NULL;
478
479#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
481 "xsl:attribute-set : %s adds use %s\n", ncname, curval);
482#endif
483
484 if (xmlValidateQName(curval, 0)) {
486 "xsl:attribute-set : The name '%s' in "
487 "use-attribute-sets is not a valid QName.\n", curval);
488 style->errors++;
489 xmlFree(value);
490 return;
491 }
492
493 ncname2 = xsltSplitQName(style->dict, curval, &prefix2);
494 if (prefix2 != NULL) {
495 xmlNsPtr ns2 = xmlSearchNs(style->doc, cur, prefix2);
496 if (ns2 == NULL) {
498 "xsl:attribute-set : No namespace found for QName "
499 "'%s:%s' in use-attribute-sets\n",
500 prefix2, ncname2);
501 style->errors++;
502 xmlFree(value);
503 return;
504 }
505 nsUri2 = ns2->href;
506 }
507 set->useAttrSets = xsltAddUseAttrSetList(set->useAttrSets,
508 ncname2, nsUri2);
509 }
510 curval = endval;
511 }
512 xmlFree(value);
513 value = NULL;
514 }
515
516#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
518 "updated attribute list %s\n", ncname);
519#endif
520}
static xsltAttrElemPtr xsltAddAttrElemList(xsltAttrElemPtr list, xmlNodePtr attr)
Definition: attributes.c:145
static xsltUseAttrSetPtr xsltAddUseAttrSetList(xsltUseAttrSetPtr list, const xmlChar *ncname, const xmlChar *ns)
Definition: attributes.c:228
static xsltAttrSetPtr xsltNewAttrSet()
Definition: attributes.c:258
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2177
static HWND child
Definition: cursoricon.c:298
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:406
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:176
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
@ XML_ELEMENT_NODE
Definition: tree.h:160
Definition: tree.h:489
const xmlChar * href
Definition: tree.h:392
Definition: pdh_main.c:94
#define BAD_CAST
Definition: xmlstring.h:35
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4878
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:502
void * xsltGenericErrorContext
Definition: xsltutils.c:503
#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 670 of file attributes.c.

670 {
672 xsltAttrSetContext asctx;
673
674#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
676 "Resolving attribute sets references\n");
677#endif
678 asctx.topStyle = style;
679 cur = style;
680 while (cur != NULL) {
681 if (cur->attributeSets != NULL) {
682 if (style->attributeSets == NULL) {
683#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
685 "creating attribute set table\n");
686#endif
687 style->attributeSets = xmlHashCreate(10);
688 }
689 asctx.style = cur;
691 &asctx);
692
693 if (cur != style) {
694 /*
695 * the attribute lists have either been migrated to style
696 * or freed directly in xsltResolveSASCallback()
697 */
698 xmlHashFree(cur->attributeSets, NULL);
699 cur->attributeSets = NULL;
700 }
701 }
703 }
704}
static void xsltResolveSASCallback(void *payload, void *data, const xmlChar *name, const xmlChar *ns, ATTRIBUTE_UNUSED const xmlChar *ignored)
Definition: attributes.c:639
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
XMLPUBFUN void XMLCALL xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data)
Definition: hash.c:875
xsltStylesheetPtr style
Definition: attributes.c:70
xsltStylesheetPtr topStyle
Definition: attributes.c:69

Referenced by xsltParseStylesheetUser().