ReactOS  0.4.13-dev-982-g9853eab
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 261 of file keys.c.

263  {
265  xmlChar *pattern = NULL;
266  int current, end, start, i = 0;
267 
268  if ((style == NULL) || (name == NULL) || (match == NULL) || (use == NULL))
269  return(-1);
270 
271 #ifdef WITH_XSLT_DEBUG_KEYS
273  "Add key %s, match %s, use %s\n", name, match, use);
274 #endif
275 
276  key = xsltNewKeyDef(name, nameURI);
277  key->match = xmlStrdup(match);
278  key->use = xmlStrdup(use);
279  key->inst = inst;
280  key->nsList = xmlGetNsList(inst->doc, inst);
281  if (key->nsList != NULL) {
282  while (key->nsList[i] != NULL)
283  i++;
284  }
285  key->nsNr = i;
286 
287  /*
288  * Split the | and register it as as many keys
289  */
290  current = end = 0;
291  while (match[current] != 0) {
292  start = current;
293  while (IS_BLANK_CH(match[current]))
294  current++;
295  end = current;
296  while ((match[end] != 0) && (match[end] != '|')) {
297  if (match[end] == '[') {
299  if (end <= 0) {
301  "xsl:key : 'match' pattern is malformed: %s",
302  key->match);
303  if (style != NULL) style->errors++;
304  goto error;
305  }
306  } else
307  end++;
308  }
309  if (current == end) {
311  "xsl:key : 'match' pattern is empty\n");
312  if (style != NULL) style->errors++;
313  goto error;
314  }
315  if (match[start] != '/') {
316  pattern = xmlStrcat(pattern, (xmlChar *)"//");
317  if (pattern == NULL) {
318  if (style != NULL) style->errors++;
319  goto error;
320  }
321  }
323  if (pattern == NULL) {
324  if (style != NULL) style->errors++;
325  goto error;
326  }
327 
328  if (match[end] == '|') {
329  pattern = xmlStrcat(pattern, (xmlChar *)"|");
330  end++;
331  }
332  current = end;
333  }
334  if (pattern == NULL) {
336  "xsl:key : 'match' pattern is empty\n");
337  if (style != NULL) style->errors++;
338  goto error;
339  }
340 #ifdef WITH_XSLT_DEBUG_KEYS
342  " resulting pattern %s\n", pattern);
343 #endif
344  /*
345  * XSLT-1: "It is an error for the value of either the use
346  * attribute or the match attribute to contain a
347  * VariableReference."
348  * TODO: We should report a variable-reference at compile-time.
349  * Maybe a search for "$", if it occurs outside of quotation
350  * marks, could be sufficient.
351  */
352 #ifdef XML_XPATH_NOVAR
353  key->comp = xsltXPathCompileFlags(style, pattern, XML_XPATH_NOVAR);
354 #else
355  key->comp = xsltXPathCompile(style, pattern);
356 #endif
357  if (key->comp == NULL) {
359  "xsl:key : 'match' pattern compilation failed '%s'\n",
360  pattern);
361  if (style != NULL) style->errors++;
362  }
363 #ifdef XML_XPATH_NOVAR
364  key->usecomp = xsltXPathCompileFlags(style, use, XML_XPATH_NOVAR);
365 #else
366  key->usecomp = xsltXPathCompile(style, use);
367 #endif
368  if (key->usecomp == NULL) {
370  "xsl:key : 'use' expression compilation failed '%s'\n",
371  use);
372  if (style != NULL) style->errors++;
373  }
374 
375  /*
376  * Sometimes the stylesheet writer use the order to ease the
377  * resolution of keys when they are dependant, keep the provided
378  * order so add the new one at the end.
379  */
380  if (style->keys == NULL) {
381  style->keys = key;
382  } else {
383  xsltKeyDefPtr prev = style->keys;
384 
385  while (prev->next != NULL)
386  prev = prev->next;
387 
388  prev->next = key;
389  }
390  key->next = NULL;
391  key = NULL;
392 
393 error:
394  if (pattern != NULL)
395  xmlFree(pattern);
396  if (key != NULL)
398  return(0);
399 }
#define error(str)
Definition: mkdosfs.c:1605
Definition: match.c:28
static xsltKeyDefPtr xsltNewKeyDef(const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:38
xmlXPathCompExprPtr xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str)
Definition: xsltutils.c:2327
GLuint GLuint end
Definition: gl.h:1545
struct _xmlDoc * doc
Definition: tree.h:498
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
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:526
#define IS_BLANK_CH(c)
static int skipPredicate(const xmlChar *cur, int end)
Definition: keys.c:225
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN xmlChar *XMLCALL xmlStrncat(xmlChar *cur, const xmlChar *add, int len)
Definition: xmlstring.c:448
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
HKEY key
Definition: reg.c:42
unsigned char xmlChar
Definition: xmlstring.h:28
static void xsltFreeKeyDef(xsltKeyDefPtr keyd)
Definition: keys.c:63
GLuint start
Definition: gl.h:1545
struct _xsltKeyDef * next
xmlXPathCompExprPtr xsltXPathCompileFlags(xsltStylesheetPtr style, const xmlChar *str, int flags)
Definition: xsltutils.c:2262
Definition: name.c:36
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
struct task_struct * current
Definition: linux.c:32
GLubyte * pattern
Definition: glext.h:7787
Definition: path.c:42

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 920 of file keys.c.

920  {
921  if (idoc != NULL)
922  xsltFreeKeyTableList(idoc->keys);
923 }
smooth NULL
Definition: ftsmooth.c:416
static void xsltFreeKeyTableList(xsltKeyTablePtr keyt)
Definition: keys.c:161

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 185 of file keys.c.

185  {
186  if (style->keys)
188 }
static void xsltFreeKeyDefList(xsltKeyDefPtr keyd)
Definition: keys.c:91
Arabic default style
Definition: afstyles.h:93

Referenced by xsltFreeStylesheet().

◆ xsltGetKey()

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

Definition at line 415 of file keys.c.

416  {
417  xmlNodeSetPtr ret;
419  int init_table = 0;
420 
421  if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||
422  (ctxt->document == NULL))
423  return(NULL);
424 
425 #ifdef WITH_XSLT_DEBUG_KEYS
427  "Get key %s, value %s\n", name, value);
428 #endif
429 
430  /*
431  * keys are computed only on-demand on first key access for a document
432  */
433  if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&
434  (ctxt->keyInitLevel == 0)) {
435  /*
436  * If non-recursive behaviour, just try to initialize all keys
437  */
438  if (xsltInitAllDocKeys(ctxt))
439  return(NULL);
440  }
441 
442 retry:
443  table = (xsltKeyTablePtr) ctxt->document->keys;
444  while (table != NULL) {
445  if (((nameURI != NULL) == (table->nameURI != NULL)) &&
446  xmlStrEqual(table->name, name) &&
447  xmlStrEqual(table->nameURI, nameURI))
448  {
449  ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);
450  return(ret);
451  }
452  table = table->next;
453  }
454 
455  if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {
456  /*
457  * Apparently one key is recursive and this one is needed,
458  * initialize just it, that time and retry
459  */
460  xsltInitDocKeyTable(ctxt, name, nameURI);
461  init_table = 1;
462  goto retry;
463  }
464 
465  return(NULL);
466 }
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:477
const WCHAR * name
xsltKeyTable * xsltKeyTablePtr
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
while(1)
Definition: macro.lex.yy.c:740
smooth NULL
Definition: ftsmooth.c:416
xsltDocumentPtr document
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
int ret
int xsltInitAllDocKeys(xsltTransformContextPtr ctxt)
Definition: keys.c:533
Definition: name.c:36
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:459
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157

Referenced by xsltKeyFunction(), and xsltTestCompMatch().

◆ 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 879 of file keys.c.

879  {
881  xsltKeyDefPtr keyDef;
882 
883  if ((ctxt == NULL) || (idoc == NULL))
884  return;
885 
886 #ifdef KEY_INIT_DEBUG
887 fprintf(stderr, "xsltInitCtxtKeys on document\n");
888 #endif
889 
890 #ifdef WITH_XSLT_DEBUG_KEYS
891  if ((idoc->doc != NULL) && (idoc->doc->URL != NULL))
892  XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext, "Initializing keys on %s\n",
893  idoc->doc->URL));
894 #endif
895  style = ctxt->style;
896  while (style != NULL) {
897  keyDef = (xsltKeyDefPtr) style->keys;
898  while (keyDef != NULL) {
899  xsltInitCtxtKey(ctxt, idoc, keyDef);
900 
901  keyDef = keyDef->next;
902  }
903 
905  }
906 
907 #ifdef KEY_INIT_DEBUG
908 fprintf(stderr, "xsltInitCtxtKeys on document: done\n");
909 #endif
910 
911 }
const xmlChar * URL
Definition: tree.h:577
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
xsltKeyDef * xsltKeyDefPtr
int xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc, xsltKeyDefPtr keyDef)
Definition: keys.c:602
xmlDocPtr doc
while(1)
Definition: macro.lex.yy.c:740
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylesheetPtr style
struct _xsltKeyDef * next
FILE * stderr
Arabic default style
Definition: afstyles.h:93