ReactOS  0.4.14-dev-114-gc8cbd56
imports.c File Reference
#include "precomp.h"
Include dependency graph for imports.c:

Go to the source code of this file.

Functions

static void xsltFixImportedCompSteps (xsltStylesheetPtr master, xsltStylesheetPtr style)
 
int xsltParseStylesheetImport (xsltStylesheetPtr style, xmlNodePtr cur)
 
int xsltParseStylesheetInclude (xsltStylesheetPtr style, xmlNodePtr cur)
 
xsltStylesheetPtr xsltNextImport (xsltStylesheetPtr cur)
 
int xsltNeedElemSpaceHandling (xsltTransformContextPtr ctxt)
 
int xsltFindElemSpaceHandling (xsltTransformContextPtr ctxt, xmlNodePtr node)
 
: the template name

xsltFindTemplate: @ctxt: an XSLT transformation context

@nameURI: the template name URI

Finds the named template, apply import precedence rule. REVISIT TODO: We'll change the nameURI fields of templates to be in the string dict, so if the specified @nameURI is in the same dict, then use pointer comparison. Check if this can be done in a sane way. Maybe this function is not needed internally at transformation-time if we hard-wire the called templates to the caller.

Returns the xsltTemplatePtr or NULL if not found

xsltTemplatePtr xsltFindTemplate (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
 

Function Documentation

◆ xsltFindElemSpaceHandling()

int xsltFindElemSpaceHandling ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node 
)

xsltFindElemSpaceHandling: @ctxt: an XSLT transformation context @node: an XML node

Find strip-space or preserve-space information for an element respect the import precedence or the wildcards

Returns 1 if space should be stripped, 0 if not, and 2 if everything should be CDTATA wrapped.

Definition at line 302 of file imports.c.

302  {
304  const xmlChar *val;
305 
306  if ((ctxt == NULL) || (node == NULL))
307  return(0);
308  style = ctxt->style;
309  while (style != NULL) {
310  if (node->ns != NULL) {
311  val = (const xmlChar *)
312  xmlHashLookup2(style->stripSpaces, node->name, node->ns->href);
313  if (val == NULL) {
314  val = (const xmlChar *)
315  xmlHashLookup2(style->stripSpaces, BAD_CAST "*",
316  node->ns->href);
317  }
318  } else {
319  val = (const xmlChar *)
320  xmlHashLookup2(style->stripSpaces, node->name, NULL);
321  }
322  if (val != NULL) {
323  if (xmlStrEqual(val, (xmlChar *) "strip"))
324  return(1);
325  if (xmlStrEqual(val, (xmlChar *) "preserve"))
326  return(0);
327  }
328  if (style->stripAll == 1)
329  return(1);
330  if (style->stripAll == -1)
331  return(0);
332 
334  }
335  return(0);
336 }
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
unsigned char xmlChar
Definition: xmlstring.h:28
xsltStylesheetPtr style
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
Arabic default style
Definition: afstyles.h:93
Definition: dlist.c:348

Referenced by xsltApplyStripSpaces().

◆ xsltFindTemplate()

xsltTemplatePtr xsltFindTemplate ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar nameURI 
)

Definition at line 356 of file imports.c.

357  {
358  xsltTemplatePtr cur;
360 
361  if ((ctxt == NULL) || (name == NULL))
362  return(NULL);
363  style = ctxt->style;
364  while (style != NULL) {
365  if (style->namedTemplates != NULL) {
366  cur = (xsltTemplatePtr)
367  xmlHashLookup2(style->namedTemplates, name, nameURI);
368  if (cur != NULL)
369  return(cur);
370  }
371 
373  }
374  return(NULL);
375 }
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
xsltTemplate * xsltTemplatePtr
smooth NULL
Definition: ftsmooth.c:416
xsltStylesheetPtr style
Definition: name.c:36
Arabic default style
Definition: afstyles.h:93

Referenced by xsltCallTemplate().

◆ xsltFixImportedCompSteps()

static void xsltFixImportedCompSteps ( xsltStylesheetPtr  master,
xsltStylesheetPtr  style 
)
static

xsltFixImportedCompSteps: @master: the "master" stylesheet @style: the stylesheet being imported by the master

normalize the comp steps for the stylesheet being imported by the master, together with any imports within that.

Definition at line 28 of file imports.c.

29  {
31  xmlHashScan(style->templatesHash, xsltNormalizeCompSteps, master);
32  master->extrasNr += style->extrasNr;
33  for (res = style->imports; res != NULL; res = res->next) {
35  }
36 }
static void xsltFixImportedCompSteps(xsltStylesheetPtr master, xsltStylesheetPtr style)
Definition: imports.c:28
XMLPUBFUN void XMLCALL xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data)
Definition: hash.c:857
void xsltNormalizeCompSteps(void *payload, void *data, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: pattern.c:218
smooth NULL
Definition: ftsmooth.c:416
GLuint res
Definition: glext.h:9613
Arabic default style
Definition: afstyles.h:93

Referenced by xsltParseStylesheetImport().

◆ xsltNeedElemSpaceHandling()

int xsltNeedElemSpaceHandling ( xsltTransformContextPtr  ctxt)

xsltNeedElemSpaceHandling: @ctxt: an XSLT transformation context

Checks whether that stylesheet requires white-space stripping

Returns 1 if space should be stripped, 0 if not

Definition at line 275 of file imports.c.

275  {
277 
278  if (ctxt == NULL)
279  return(0);
280  style = ctxt->style;
281  while (style != NULL) {
282  if (style->stripSpaces != NULL)
283  return(1);
285  }
286  return(0);
287 }
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
smooth NULL
Definition: ftsmooth.c:416
xsltStylesheetPtr style
Arabic default style
Definition: afstyles.h:93

Referenced by xsltApplyStylesheetInternal(), and xsltLoadDocument().

◆ xsltNextImport()

xsltStylesheetPtr xsltNextImport ( xsltStylesheetPtr  cur)

xsltNextImport: @cur: the current XSLT stylesheet

Find the next stylesheet in import precedence.

Returns the next stylesheet or NULL if it was the last one

Definition at line 250 of file imports.c.

250  {
251  if (cur == NULL)
252  return(NULL);
253  if (cur->imports != NULL)
254  return(cur->imports);
255  if (cur->next != NULL)
256  return(cur->next) ;
257  do {
258  cur = cur->parent;
259  if (cur == NULL) break;
260  if (cur->next != NULL) return(cur->next);
261  } while (cur != NULL);
262  return(cur);
263 }
struct _xsltStylesheet * imports
struct _xsltStylesheet * parent
smooth NULL
Definition: ftsmooth.c:416
struct _xsltStylesheet * next

Referenced by xsltApplySequenceConstructor(), xsltCountKeys(), xsltDecimalFormatGetByName(), xsltDecimalFormatGetByQName(), xsltEvalGlobalVariables(), xsltFindElemSpaceHandling(), xsltFindTemplate(), xsltGetNamespace(), xsltGetProfileInformation(), xsltGetTemplate(), xsltInitAllDocKeys(), xsltInitCtxtExts(), xsltInitCtxtKeys(), xsltInitDocKeyTable(), xsltNeedElemSpaceHandling(), xsltProcessUserParamInternal(), xsltResolveAttrSet(), xsltResolveStylesheetAttributeSet(), xsltResolveUseAttrSets(), xsltSaveProfiling(), and xsltStyleGetExtData().

◆ xsltParseStylesheetImport()

int xsltParseStylesheetImport ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseStylesheetImport: @style: the XSLT stylesheet @cur: the import element

parse an XSLT stylesheet import element

Returns 0 in case of success -1 in case of failure.

Definition at line 49 of file imports.c.

49  {
50  int ret = -1;
51  xmlDocPtr import = NULL;
52  xmlChar *base = NULL;
53  xmlChar *uriRef = NULL;
54  xmlChar *URI = NULL;
57 
58  if ((cur == NULL) || (style == NULL))
59  return (ret);
60 
61  uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", NULL);
62  if (uriRef == NULL) {
64  "xsl:import : missing href attribute\n");
65  goto error;
66  }
67 
68  base = xmlNodeGetBase(style->doc, cur);
69  URI = xmlBuildURI(uriRef, base);
70  if (URI == NULL) {
72  "xsl:import : invalid URI reference %s\n", uriRef);
73  goto error;
74  }
75 
76  res = style;
77  while (res != NULL) {
78  if (res->doc == NULL)
79  break;
80  if (xmlStrEqual(res->doc->URL, URI)) {
82  "xsl:import : recursion detected on imported URL %s\n", URI);
83  goto error;
84  }
85  res = res->parent;
86  }
87 
88  /*
89  * Security framework check
90  */
92  if (sec != NULL) {
93  int secres;
94 
95  secres = xsltCheckRead(sec, NULL, URI);
96  if (secres == 0) {
98  "xsl:import: read rights for %s denied\n",
99  URI);
100  goto error;
101  }
102  }
103 
104  import = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
105  (void *) style, XSLT_LOAD_STYLESHEET);
106  if (import == NULL) {
108  "xsl:import : unable to load %s\n", URI);
109  goto error;
110  }
111 
113  if (res != NULL) {
114  res->next = style->imports;
115  style->imports = res;
116  if (style->parent == NULL) {
118  }
119  ret = 0;
120  } else {
121  xmlFreeDoc(import);
122  }
123 
124 error:
125  if (uriRef != NULL)
126  xmlFree(uriRef);
127  if (base != NULL)
128  xmlFree(base);
129  if (URI != NULL)
130  xmlFree(URI);
131 
132  return (ret);
133 }
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6499
static void xsltFixImportedCompSteps(xsltStylesheetPtr master, xsltStylesheetPtr style)
Definition: imports.c:28
#define error(str)
Definition: mkdosfs.c:1605
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:400
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1882
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: tree.h:551
GLuint res
Definition: glext.h:9613
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetInclude()

int xsltParseStylesheetInclude ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseStylesheetInclude: @style: the XSLT stylesheet @cur: the include node

parse an XSLT stylesheet include element

Returns 0 in case of success -1 in case of failure

Definition at line 146 of file imports.c.

146  {
147  int ret = -1;
148  xmlDocPtr oldDoc;
149  xmlChar *base = NULL;
150  xmlChar *uriRef = NULL;
151  xmlChar *URI = NULL;
153  xsltDocumentPtr include;
154  xsltDocumentPtr docptr;
155  int oldNopreproc;
156 
157  if ((cur == NULL) || (style == NULL))
158  return (ret);
159 
160  uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", NULL);
161  if (uriRef == NULL) {
163  "xsl:include : missing href attribute\n");
164  goto error;
165  }
166 
167  base = xmlNodeGetBase(style->doc, cur);
168  URI = xmlBuildURI(uriRef, base);
169  if (URI == NULL) {
171  "xsl:include : invalid URI reference %s\n", uriRef);
172  goto error;
173  }
174 
175  /*
176  * in order to detect recursion, we check all previously included
177  * stylesheets.
178  */
179  docptr = style->includes;
180  while (docptr != NULL) {
181  if (xmlStrEqual(docptr->doc->URL, URI)) {
183  "xsl:include : recursion detected on included URL %s\n", URI);
184  goto error;
185  }
186  docptr = docptr->includes;
187  }
188 
189  include = xsltLoadStyleDocument(style, URI);
190  if (include == NULL) {
192  "xsl:include : unable to load %s\n", URI);
193  goto error;
194  }
195 #ifdef XSLT_REFACTORED
196  if (IS_XSLT_ELEM_FAST(cur) && (cur->psvi != NULL)) {
197  ((xsltStyleItemIncludePtr) cur->psvi)->include = include;
198  } else {
200  "Internal error: (xsltParseStylesheetInclude) "
201  "The xsl:include element was not compiled.\n", URI);
202  style->errors++;
203  }
204 #endif
205  oldDoc = style->doc;
206  style->doc = include->doc;
207  /* chain to stylesheet for recursion checking */
208  include->includes = style->includes;
209  style->includes = include;
210  oldNopreproc = style->nopreproc;
211  style->nopreproc = include->preproc;
212  /*
213  * TODO: This will change some values of the
214  * including stylesheet with every included module
215  * (e.g. excluded-result-prefixes)
216  * We need to strictly seperate such stylesheet-owned values.
217  */
219  style->nopreproc = oldNopreproc;
220  include->preproc = 1;
221  style->includes = include->includes;
222  style->doc = oldDoc;
223  if (result == NULL) {
224  ret = -1;
225  goto error;
226  }
227  ret = 0;
228 
229 error:
230  if (uriRef != NULL)
231  xmlFree(uriRef);
232  if (base != NULL)
233  xmlFree(base);
234  if (URI != NULL)
235  xmlFree(URI);
236 
237  return (ret);
238 }
void * psvi
Definition: tree.h:505
const xmlChar * URL
Definition: tree.h:577
#define error(str)
Definition: mkdosfs.c:1605
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
xmlDocPtr doc
struct _xsltDocument * includes
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1882
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
xsltDocumentPtr xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI)
Definition: documents.c:342
Definition: tree.h:551
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
GLuint64EXT * result
Definition: glext.h:11304
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6391

Referenced by xsltParseStylesheetTop().