ReactOS 0.4.15-dev-6662-g1b3eed5
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 303 of file imports.c.

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

Referenced by xsltApplyStripSpaces().

◆ xsltFindTemplate()

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

Definition at line 357 of file imports.c.

358 {
361
362 if ((ctxt == NULL) || (name == NULL))
363 return(NULL);
364 style = ctxt->style;
365 while (style != NULL) {
366 if (style->namedTemplates != NULL) {
368 xmlHashLookup2(style->namedTemplates, name, nameURI);
369 if (cur != NULL)
370 return(cur);
371 }
372
374 }
375 return(NULL);
376}
FxCollectionEntry * cur
Definition: name.c:39
xsltTemplate * xsltTemplatePtr

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}
void xsltNormalizeCompSteps(void *payload, void *data, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: pattern.c:217
GLuint res
Definition: glext.h:9613
static void xsltFixImportedCompSteps(xsltStylesheetPtr master, xsltStylesheetPtr style)
Definition: imports.c:28
XMLPUBFUN void XMLCALL xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data)
Definition: hash.c:859
struct define * next
Definition: compiler.c:65

Referenced by xsltFixImportedCompSteps(), and 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 276 of file imports.c.

276 {
278
279 if (ctxt == NULL)
280 return(0);
281 style = ctxt->style;
282 while (style != NULL) {
283 if (style->stripSpaces != NULL)
284 return(1);
286 }
287 return(0);
288}

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 251 of file imports.c.

251 {
252 if (cur == NULL)
253 return(NULL);
254 if (cur->imports != NULL)
255 return(cur->imports);
256 if (cur->next != NULL)
257 return(cur->next) ;
258 do {
259 cur = cur->parent;
260 if (cur == NULL) break;
261 if (cur->next != NULL) return(cur->next);
262 } while (cur != NULL);
263 return(cur);
264}

Referenced by xsltApplySequenceConstructor(), xsltCountKeys(), xsltDecimalFormatGetByName(), xsltDecimalFormatGetByQName(), xsltEvalGlobalVariables(), xsltFindElemSpaceHandling(), xsltFindTemplate(), xsltGetNamespace(), xsltGetTemplate(), xsltInitAllDocKeys(), xsltInitCtxtExts(), xsltInitCtxtKeys(), xsltInitDocKeyTable(), xsltNeedElemSpaceHandling(), xsltProcessUserParamInternal(), xsltResolveAttrSet(), xsltResolveStylesheetAttributeSet(), xsltResolveUseAttrSets(), 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
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) {
97 if (secres == 0)
99 "xsl:import: read rights for %s denied\n",
100 URI);
101 goto error;
102 }
103 }
104
105 import = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
106 (void *) style, XSLT_LOAD_STYLESHEET);
107 if (import == NULL) {
109 "xsl:import : unable to load %s\n", URI);
110 goto error;
111 }
112
114 if (res != NULL) {
115 res->next = style->imports;
116 style->imports = res;
117 if (style->parent == NULL) {
119 }
120 ret = 0;
121 } else {
122 xmlFreeDoc(import);
123 }
124
125error:
126 if (uriRef != NULL)
127 xmlFree(uriRef);
128 if (base != NULL)
129 xmlFree(base);
130 if (URI != NULL)
131 xmlFree(URI);
132
133 return (ret);
134}
xsltSecurityPrefsPtr xsltGetDefaultSecurityPrefs(void)
Definition: security.c:163
int xsltCheckRead(xsltSecurityPrefsPtr sec, xsltTransformContextPtr ctxt, const xmlChar *URL)
Definition: security.c:402
xsltDocLoaderFunc xsltDocDefaultLoader
Definition: documents.c:93
@ XSLT_LOAD_STYLESHEET
Definition: documents.h:55
#define error(str)
Definition: mkdosfs.c:1605
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN xmlChar *XMLCALL xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
Definition: tree.h:551
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
int ret
xsltStylesheetPtr xsltParseStylesheetImportedDoc(xmlDocPtr doc, xsltStylesheetPtr parentStyle)
Definition: xslt.c:6514
#define XSLT_PARSE_OPTIONS
Definition: xslt.h:54
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

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 147 of file imports.c.

147 {
148 int ret = -1;
149 xmlDocPtr oldDoc;
150 xmlChar *base = NULL;
151 xmlChar *uriRef = NULL;
152 xmlChar *URI = NULL;
155 xsltDocumentPtr docptr;
156 int oldNopreproc;
157
158 if ((cur == NULL) || (style == NULL))
159 return (ret);
160
161 uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", NULL);
162 if (uriRef == NULL) {
164 "xsl:include : missing href attribute\n");
165 goto error;
166 }
167
168 base = xmlNodeGetBase(style->doc, cur);
169 URI = xmlBuildURI(uriRef, base);
170 if (URI == NULL) {
172 "xsl:include : invalid URI reference %s\n", uriRef);
173 goto error;
174 }
175
176 /*
177 * in order to detect recursion, we check all previously included
178 * stylesheets.
179 */
180 docptr = style->includes;
181 while (docptr != NULL) {
182 if (xmlStrEqual(docptr->doc->URL, URI)) {
184 "xsl:include : recursion detected on included URL %s\n", URI);
185 goto error;
186 }
187 docptr = docptr->includes;
188 }
189
191 if (include == NULL) {
193 "xsl:include : unable to load %s\n", URI);
194 goto error;
195 }
196#ifdef XSLT_REFACTORED
197 if (IS_XSLT_ELEM_FAST(cur) && (cur->psvi != NULL)) {
198 ((xsltStyleItemIncludePtr) cur->psvi)->include = include;
199 } else {
201 "Internal error: (xsltParseStylesheetInclude) "
202 "The xsl:include element was not compiled.\n", URI);
203 style->errors++;
204 }
205#endif
206 oldDoc = style->doc;
207 style->doc = include->doc;
208 /* chain to stylesheet for recursion checking */
209 include->includes = style->includes;
210 style->includes = include;
211 oldNopreproc = style->nopreproc;
212 style->nopreproc = include->preproc;
213 /*
214 * TODO: This will change some values of the
215 * including stylesheet with every included module
216 * (e.g. excluded-result-prefixes)
217 * We need to strictly seperate such stylesheet-owned values.
218 */
220 style->nopreproc = oldNopreproc;
221 include->preproc = 1;
222 style->includes = include->includes;
223 style->doc = oldDoc;
224 if (result == NULL) {
225 ret = -1;
226 goto error;
227 }
228 ret = 0;
229
230error:
231 if (uriRef != NULL)
232 xmlFree(uriRef);
233 if (base != NULL)
234 xmlFree(base);
235 if (URI != NULL)
236 xmlFree(URI);
237
238 return (ret);
239}
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
xsltDocumentPtr xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI)
Definition: documents.c:343
GLuint64EXT * result
Definition: glext.h:11304
const xmlChar * URL
Definition: tree.h:577
xmlDocPtr doc
struct _xsltDocument * includes
xsltStylesheetPtr xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc)
Definition: xslt.c:6406

Referenced by xsltParseStylesheetTop().