ReactOS  0.4.15-dev-449-g64abd9f
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 263 of file keys.c.

265  {
267  xmlChar *pattern = NULL;
268  int current, end, start, i = 0;
269 
270  if ((style == NULL) || (name == NULL) || (match == NULL) || (use == NULL))
271  return(-1);
272 
273 #ifdef WITH_XSLT_DEBUG_KEYS
275  "Add key %s, match %s, use %s\n", name, match, use);
276 #endif
277 
278  key = xsltNewKeyDef(name, nameURI);
279  key->match = xmlStrdup(match);
280  key->use = xmlStrdup(use);
281  key->inst = inst;
282  key->nsList = xmlGetNsList(inst->doc, inst);
283  if (key->nsList != NULL) {
284  while (key->nsList[i] != NULL)
285  i++;
286  }
287  key->nsNr = i;
288 
289  /*
290  * Split the | and register it as as many keys
291  */
292  current = end = 0;
293  while (match[current] != 0) {
294  start = current;
295  while (IS_BLANK_CH(match[current]))
296  current++;
297  end = current;
298  while ((match[end] != 0) && (match[end] != '|')) {
299  if (match[end] == '[') {
301  if (end <= 0) {
303  "xsl:key : 'match' pattern is malformed: %s",
304  key->match);
305  if (style != NULL) style->errors++;
306  goto error;
307  }
308  } else
309  end++;
310  }
311  if (current == end) {
313  "xsl:key : 'match' pattern is empty\n");
314  if (style != NULL) style->errors++;
315  goto error;
316  }
317  if (match[start] != '/') {
318  pattern = xmlStrcat(pattern, (xmlChar *)"//");
319  if (pattern == NULL) {
320  if (style != NULL) style->errors++;
321  goto error;
322  }
323  }
325  if (pattern == NULL) {
326  if (style != NULL) style->errors++;
327  goto error;
328  }
329 
330  if (match[end] == '|') {
331  pattern = xmlStrcat(pattern, (xmlChar *)"|");
332  end++;
333  }
334  current = end;
335  }
336  if (pattern == NULL) {
338  "xsl:key : 'match' pattern is empty\n");
339  if (style != NULL) style->errors++;
340  goto error;
341  }
342 #ifdef WITH_XSLT_DEBUG_KEYS
344  " resulting pattern %s\n", pattern);
345 #endif
346  /*
347  * XSLT-1: "It is an error for the value of either the use
348  * attribute or the match attribute to contain a
349  * VariableReference."
350  * TODO: We should report a variable-reference at compile-time.
351  * Maybe a search for "$", if it occurs outside of quotation
352  * marks, could be sufficient.
353  */
354 #ifdef XML_XPATH_NOVAR
355  key->comp = xsltXPathCompileFlags(style, pattern, XML_XPATH_NOVAR);
356 #else
357  key->comp = xsltXPathCompile(style, pattern);
358 #endif
359  if (key->comp == NULL) {
361  "xsl:key : 'match' pattern compilation failed '%s'\n",
362  pattern);
363  if (style != NULL) style->errors++;
364  }
365 #ifdef XML_XPATH_NOVAR
366  key->usecomp = xsltXPathCompileFlags(style, use, XML_XPATH_NOVAR);
367 #else
368  key->usecomp = xsltXPathCompile(style, use);
369 #endif
370  if (key->usecomp == NULL) {
372  "xsl:key : 'use' expression compilation failed '%s'\n",
373  use);
374  if (style != NULL) style->errors++;
375  }
376 
377  /*
378  * Sometimes the stylesheet writer use the order to ease the
379  * resolution of keys when they are dependant, keep the provided
380  * order so add the new one at the end.
381  */
382  if (style->keys == NULL) {
383  style->keys = key;
384  } else {
385  xsltKeyDefPtr prev = style->keys;
386 
387  while (prev->next != NULL)
388  prev = prev->next;
389 
390  prev->next = key;
391  }
392  key->next = NULL;
393  key = NULL;
394 
395 error:
396  if (pattern != NULL)
397  xmlFree(pattern);
398  if (key != NULL)
400  return(0);
401 }
#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:2319
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:2276
Definition: name.c:38
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:41

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

925  {
926  if (idoc != NULL)
927  xsltFreeKeyTableList(idoc->keys);
928 }
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 417 of file keys.c.

418  {
419  xmlNodeSetPtr ret;
421  int init_table = 0;
422 
423  if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||
424  (ctxt->document == NULL))
425  return(NULL);
426 
427 #ifdef WITH_XSLT_DEBUG_KEYS
429  "Get key %s, value %s\n", name, value);
430 #endif
431 
432  /*
433  * keys are computed only on-demand on first key access for a document
434  */
435  if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&
436  (ctxt->keyInitLevel == 0)) {
437  /*
438  * If non-recursive behaviour, just try to initialize all keys
439  */
440  if (xsltInitAllDocKeys(ctxt))
441  return(NULL);
442  }
443 
444 retry:
445  table = (xsltKeyTablePtr) ctxt->document->keys;
446  while (table != NULL) {
447  if (((nameURI != NULL) == (table->nameURI != NULL)) &&
448  xmlStrEqual(table->name, name) &&
449  xmlStrEqual(table->nameURI, nameURI))
450  {
451  ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);
452  return(ret);
453  }
454  table = table->next;
455  }
456 
457  if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {
458  /*
459  * Apparently one key is recursive and this one is needed,
460  * initialize just it, that time and retry
461  */
462  xsltInitDocKeyTable(ctxt, name, nameURI);
463  init_table = 1;
464  goto retry;
465  }
466 
467  return(NULL);
468 }
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:479
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:535
Definition: name.c:38
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466
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 884 of file keys.c.

884  {
886  xsltKeyDefPtr keyDef;
887 
888  if ((ctxt == NULL) || (idoc == NULL))
889  return;
890 
891 #ifdef KEY_INIT_DEBUG
892 fprintf(stderr, "xsltInitCtxtKeys on document\n");
893 #endif
894 
895 #ifdef WITH_XSLT_DEBUG_KEYS
896  if ((idoc->doc != NULL) && (idoc->doc->URL != NULL))
897  XSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext, "Initializing keys on %s\n",
898  idoc->doc->URL));
899 #endif
900  style = ctxt->style;
901  while (style != NULL) {
902  keyDef = (xsltKeyDefPtr) style->keys;
903  while (keyDef != NULL) {
904  xsltInitCtxtKey(ctxt, idoc, keyDef);
905 
906  keyDef = keyDef->next;
907  }
908 
910  }
911 
912 #ifdef KEY_INIT_DEBUG
913 fprintf(stderr, "xsltInitCtxtKeys on document: done\n");
914 #endif
915 
916 }
const xmlChar * URL
Definition: tree.h:577
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
xsltKeyDef * xsltKeyDefPtr
int xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc, xsltKeyDefPtr keyDef)
Definition: keys.c:604
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