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

Go to the source code of this file.

Macros

#define NODE_IS_KEYED   (1 >> 15)
 

Functions

XSLTPUBFUN int XSLTCALL xsltAddKey (xsltStylesheetPtr style, const xmlChar *name, const xmlChar *nameURI, const xmlChar *match, const xmlChar *use, xmlNodePtr inst)
 
XSLTPUBFUN xmlNodeSetPtr XSLTCALL xsltGetKey (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI, const xmlChar *value)
 
XSLTPUBFUN void XSLTCALL xsltInitCtxtKeys (xsltTransformContextPtr ctxt, xsltDocumentPtr doc)
 
XSLTPUBFUN void XSLTCALL xsltFreeKeys (xsltStylesheetPtr style)
 
XSLTPUBFUN void XSLTCALL xsltFreeDocumentKeys (xsltDocumentPtr doc)
 

Macro Definition Documentation

◆ NODE_IS_KEYED

#define NODE_IS_KEYED   (1 >> 15)

NODE_IS_KEYED:

check for bit 15 set

Definition at line 26 of file keys.h.

Function Documentation

◆ xsltAddKey()

XSLTPUBFUN int XSLTCALL xsltAddKey ( xsltStylesheetPtr  style,
const xmlChar name,
const xmlChar nameURI,
const xmlChar match,
const xmlChar use,
xmlNodePtr  inst 
)

Definition at line 281 of file keys.c.

283 {
286 int current, end, start, i = 0;
287
288 if ((style == NULL) || (name == NULL) || (match == NULL) || (use == NULL))
289 return(-1);
290
291#ifdef WITH_XSLT_DEBUG_KEYS
293 "Add key %s, match %s, use %s\n", name, match, use);
294#endif
295
296 key = xsltNewKeyDef(name, nameURI);
297 if (key == NULL)
298 return(-1);
299 key->match = xmlStrdup(match);
300 key->use = xmlStrdup(use);
301 key->inst = inst;
302 key->nsList = xmlGetNsList(inst->doc, inst);
303 if (key->nsList != NULL) {
304 while (key->nsList[i] != NULL)
305 i++;
306 }
307 key->nsNr = i;
308
309 /*
310 * Split the | and register it as as many keys
311 */
312 current = end = 0;
313 while (match[current] != 0) {
314 start = current;
315 while (xmlIsBlank_ch(match[current]))
316 current++;
317 end = current;
318 while ((match[end] != 0) && (match[end] != '|')) {
319 if (match[end] == '[') {
321 if (end <= 0) {
323 "xsl:key : 'match' pattern is malformed: %s",
324 key->match);
325 if (style != NULL) style->errors++;
326 goto error;
327 }
328 } else
329 end++;
330 }
331 if (current == end) {
333 "xsl:key : 'match' pattern is empty\n");
334 if (style != NULL) style->errors++;
335 goto error;
336 }
337 if (match[start] != '/') {
338 pattern = xmlStrcat(pattern, (xmlChar *)"//");
339 if (pattern == NULL) {
340 if (style != NULL) style->errors++;
341 goto error;
342 }
343 }
345 if (pattern == NULL) {
346 if (style != NULL) style->errors++;
347 goto error;
348 }
349
350 if (match[end] == '|') {
351 pattern = xmlStrcat(pattern, (xmlChar *)"|");
352 end++;
353 }
354 current = end;
355 }
356 if (pattern == NULL) {
358 "xsl:key : 'match' pattern is empty\n");
359 if (style != NULL) style->errors++;
360 goto error;
361 }
362#ifdef WITH_XSLT_DEBUG_KEYS
364 " resulting pattern %s\n", pattern);
365#endif
366 /*
367 * XSLT-1: "It is an error for the value of either the use
368 * attribute or the match attribute to contain a
369 * VariableReference."
370 * TODO: We should report a variable-reference at compile-time.
371 * Maybe a search for "$", if it occurs outside of quotation
372 * marks, could be sufficient.
373 */
374#ifdef XML_XPATH_NOVAR
375 key->comp = xsltXPathCompileFlags(style, pattern, XML_XPATH_NOVAR);
376#else
378#endif
379 if (key->comp == NULL) {
381 "xsl:key : 'match' pattern compilation failed '%s'\n",
382 pattern);
383 if (style != NULL) style->errors++;
384 }
385#ifdef XML_XPATH_NOVAR
386 key->usecomp = xsltXPathCompileFlags(style, use, XML_XPATH_NOVAR);
387#else
388 key->usecomp = xsltXPathCompile(style, use);
389#endif
390 if (key->usecomp == NULL) {
392 "xsl:key : 'use' expression compilation failed '%s'\n",
393 use);
394 if (style != NULL) style->errors++;
395 }
396
397 /*
398 * Sometimes the stylesheet writer use the order to ease the
399 * resolution of keys when they are dependant, keep the provided
400 * order so add the new one at the end.
401 */
402 if (style->keys == NULL) {
403 style->keys = key;
404 } else {
405 xsltKeyDefPtr prev = style->keys;
406
407 while (prev->next != NULL)
408 prev = prev->next;
409
410 prev->next = key;
411 }
412 key->next = NULL;
413 key = NULL;
414
415error:
416 if (pattern != NULL)
418 if (key != NULL)
420 return(0);
421}
Arabic default style
Definition: afstyles.h:94
#define xmlIsBlank_ch(c)
Definition: chvalid.h:88
#define NULL
Definition: types.h:112
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLubyte * pattern
Definition: glext.h:7787
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static xsltKeyDefPtr xsltNewKeyDef(const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:56
static int skipPredicate(const xmlChar *cur, int end)
Definition: keys.c:243
static void xsltFreeKeyDef(xsltKeyDefPtr keyd)
Definition: keys.c:81
#define error(str)
Definition: mkdosfs.c:1605
struct task_struct * current
Definition: linux.c:32
xmlFreeFunc xmlFree
Definition: globals.c:184
struct _xsltKeyDef * next
Definition: copy.c:22
Definition: match.c:28
Definition: name.c:39
XMLPUBFUN xmlChar * xmlStrncat(xmlChar *cur, const xmlChar *add, int len)
Definition: xmlstring.c:448
XMLPUBFUN xmlChar * xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:524
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlXPathCompExprPtr xsltXPathCompileFlags(xsltStylesheetPtr style, const xmlChar *str, int flags)
Definition: xsltutils.c:2550
xmlXPathCompExprPtr xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str)
Definition: xsltutils.c:2593
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633

Referenced by xsltParseStylesheetKey().

◆ xsltFreeDocumentKeys()

XSLTPUBFUN void XSLTCALL xsltFreeDocumentKeys ( xsltDocumentPtr  idoc)

xsltFreeDocumentKeys: @idoc: a XSLT document

Free the keys associated to a document

Definition at line 931 of file keys.c.

931 {
932 if (idoc != NULL)
934}
static void xsltFreeKeyTableList(xsltKeyTablePtr keyt)
Definition: keys.c:179

Referenced by xsltFreeDocuments(), xsltFreeRVTs(), xsltFreeStyleDocuments(), xsltReleaseRVT(), and xsltTransformCacheFree().

◆ xsltFreeKeys()

XSLTPUBFUN void XSLTCALL xsltFreeKeys ( xsltStylesheetPtr  style)

xsltFreeKeys: @style: an XSLT stylesheet

Free up the memory used by XSLT keys in a stylesheet

Definition at line 203 of file keys.c.

203 {
204 if (style->keys)
206}
static void xsltFreeKeyDefList(xsltKeyDefPtr keyd)
Definition: keys.c:109

Referenced by xsltFreeStylesheet().

◆ xsltGetKey()

XSLTPUBFUN xmlNodeSetPtr XSLTCALL xsltGetKey ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar nameURI,
const xmlChar value 
)

Definition at line 437 of file keys.c.

438 {
439 xmlNodeSetPtr ret;
441 int init_table = 0;
442
443 if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||
444 (ctxt->document == NULL))
445 return(NULL);
446
447#ifdef WITH_XSLT_DEBUG_KEYS
449 "Get key %s, value %s\n", name, value);
450#endif
451
452 /*
453 * keys are computed only on-demand on first key access for a document
454 */
455 if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&
456 (ctxt->keyInitLevel == 0)) {
457 /*
458 * If non-recursive behaviour, just try to initialize all keys
459 */
460 if (xsltInitAllDocKeys(ctxt))
461 return(NULL);
462 }
463
464retry:
466 while (table != NULL) {
467 if (((nameURI != NULL) == (table->nameURI != NULL)) &&
469 xmlStrEqual(table->nameURI, nameURI))
470 {
471 ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);
472 return(ret);
473 }
474 table = table->next;
475 }
476
477 if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {
478 /*
479 * Apparently one key is recursive and this one is needed,
480 * initialize just it, that time and retry
481 */
482 xsltInitDocKeyTable(ctxt, name, nameURI);
483 init_table = 1;
484 goto retry;
485 }
486
487 return(NULL);
488}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
return ret
Definition: mutex.c:146
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:499
int xsltInitAllDocKeys(xsltTransformContextPtr ctxt)
Definition: keys.c:555
void * xmlHashLookup(xmlHashTablePtr hash, const xmlChar *key)
Definition: hash.c:739
xsltDocumentPtr document
const WCHAR * name
Definition: pdh_main.c:96
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
xsltKeyTable * xsltKeyTablePtr

Referenced by xsltKeyFunction(), and xsltTestStepMatch().

◆ xsltInitCtxtKeys()

XSLTPUBFUN void XSLTCALL xsltInitCtxtKeys ( xsltTransformContextPtr  ctxt,
xsltDocumentPtr  idoc 
)

xsltInitCtxtKeys: @ctxt: an XSLT transformation context @idoc: a document info

Computes all the keys tables for the current input document. Should be done before global varibales are initialized. NOTE: Not used anymore in the refactored code.

Definition at line 890 of file keys.c.

890 {
892 xsltKeyDefPtr keyDef;
893
894 if ((ctxt == NULL) || (idoc == NULL))
895 return;
896
897#ifdef KEY_INIT_DEBUG
898fprintf(stderr, "xsltInitCtxtKeys on document\n");
899#endif
900
901#ifdef WITH_XSLT_DEBUG_KEYS
902 if ((idoc->doc != NULL) && (idoc->doc->URL != NULL))
903 XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext, "Initializing keys on %s\n",
904 idoc->doc->URL));
905#endif
906 style = ctxt->style;
907 while (style != NULL) {
908 keyDef = (xsltKeyDefPtr) style->keys;
909 while (keyDef != NULL) {
910 xsltInitCtxtKey(ctxt, idoc, keyDef);
911
912 keyDef = keyDef->next;
913 }
914
916 }
917
918#ifdef KEY_INIT_DEBUG
919fprintf(stderr, "xsltInitCtxtKeys on document: done\n");
920#endif
921
922}
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
#define stderr
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
int xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc, xsltKeyDefPtr keyDef)
Definition: keys.c:624
xmlDocPtr doc
xsltStylesheetPtr style
xsltKeyDef * xsltKeyDefPtr
@ XSLT_TRACE_KEYS
Definition: xsltutils.h:123
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:132