ReactOS 0.4.15-dev-6662-g1b3eed5
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 {
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 (xmlIsBlank_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
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
395error:
396 if (pattern != NULL)
398 if (key != NULL)
400 return(0);
401}
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:38
static int skipPredicate(const xmlChar *cur, int end)
Definition: keys.c:225
static void xsltFreeKeyDef(xsltKeyDefPtr keyd)
Definition: keys.c:63
#define error(str)
Definition: mkdosfs.c:1605
struct task_struct * current
Definition: linux.c:32
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
struct _xmlDoc * doc
Definition: tree.h:498
struct _xsltKeyDef * next
Definition: copy.c:22
Definition: match.c:28
Definition: name.c:39
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:524
XMLPUBFUN xmlChar *XMLCALL xmlStrncat(xmlChar *cur, const xmlChar *add, int len)
Definition: xmlstring.c:446
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
unsigned char xmlChar
Definition: xmlstring.h:28
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xmlXPathCompExprPtr xsltXPathCompileFlags(xsltStylesheetPtr style, const xmlChar *str, int flags)
Definition: xsltutils.c:2313
xmlXPathCompExprPtr xsltXPathCompile(xsltStylesheetPtr style, const xmlChar *str)
Definition: xsltutils.c:2356
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
void * xsltGenericDebugContext
Definition: xsltutils.c:549

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)
928}
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

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
444retry:
446 while (table != NULL) {
447 if (((nameURI != NULL) == (table->nameURI != NULL)) &&
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}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
static int xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: keys.c:479
int xsltInitAllDocKeys(xsltTransformContextPtr ctxt)
Definition: keys.c:535
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:461
xsltDocumentPtr document
const WCHAR * name
Definition: pdh_main.c:94
int ret
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160
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 884 of file keys.c.

884 {
886 xsltKeyDefPtr keyDef;
887
888 if ((ctxt == NULL) || (idoc == NULL))
889 return;
890
891#ifdef KEY_INIT_DEBUG
892fprintf(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
913fprintf(stderr, "xsltInitCtxtKeys on document: done\n");
914#endif
915
916}
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr idoc, xsltKeyDefPtr keyDef)
Definition: keys.c:604
const xmlChar * URL
Definition: tree.h:577
xmlDocPtr doc
xsltStylesheetPtr style
xsltKeyDef * xsltKeyDefPtr
@ XSLT_TRACE_KEYS
Definition: xsltutils.h:116
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:125