Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/libxslt/libxslt/xslt.c

Issue 1193533007: Upgrade to libxml 2.9.2 and libxslt 1.1.28 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no iconv Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libxslt/libxslt/xslt.h ('k') | third_party/libxslt/libxslt/xsltInternals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libxslt/libxslt/xslt.c
diff --git a/third_party/libxslt/libxslt/xslt.c b/third_party/libxslt/libxslt/xslt.c
index 0ae922848460f8e41d2ad2bc46fc56fe284a6b77..58d138674e5ec705a3b0e12b50bb1495eaadebc7 100644
--- a/third_party/libxslt/libxslt/xslt.c
+++ b/third_party/libxslt/libxslt/xslt.c
@@ -243,6 +243,10 @@ xsltInit (void) {
*/
void
xsltUninit (void) {
+#ifdef XSLT_LOCALE_WINAPI
+ xmlFreeRMutex(xsltLocaleMutex);
+ xsltLocaleMutex = NULL;
+#endif
initialized = 0;
}
@@ -281,7 +285,7 @@ xsltNewDecimalFormat(xmlChar *name)
if (self != NULL) {
self->next = NULL;
self->name = name;
-
+
/* Default values */
self->digit = xmlStrdup(BAD_CAST("#"));
self->patternSeparator = xmlStrdup(BAD_CAST(";"));
@@ -335,7 +339,7 @@ xsltFreeDecimalFormatList(xsltStylesheetPtr self)
if (self == NULL)
return;
-
+
iter = self->decimalFormat;
while (iter != NULL) {
tmp = iter->next;
@@ -417,6 +421,11 @@ xsltFreeTemplate(xsltTemplatePtr template) {
if (template->modeURI) xmlFree(template->modeURI);
*/
if (template->inheritedNs) xmlFree(template->inheritedNs);
+
+ /* free profiling data */
+ if (template->templCalledTab) xmlFree(template->templCalledTab);
+ if (template->templCountTab) xmlFree(template->templCountTab);
+
memset(template, -1, sizeof(xsltTemplate));
xmlFree(template);
}
@@ -444,12 +453,12 @@ static void
xsltFreeNsAliasList(xsltNsAliasPtr item)
{
xsltNsAliasPtr tmp;
-
+
while (item) {
tmp = item;
item = item->next;
xmlFree(tmp);
- }
+ }
return;
}
@@ -458,12 +467,12 @@ static void
xsltFreeNamespaceMap(xsltNsMapPtr item)
{
xsltNsMapPtr tmp;
-
+
while (item) {
tmp = item;
item = item->next;
xmlFree(tmp);
- }
+ }
return;
}
@@ -501,15 +510,15 @@ xsltNewNamespaceMapItem(xsltCompilerCtxtPtr cctxt,
#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
/**
- * xsltCompilerVarInfoFree:
+ * xsltCompilerVarInfoFree:
* @cctxt: the compilation context
- *
+ *
* Frees the list of information for vars/params.
*/
static void
xsltCompilerVarInfoFree(xsltCompilerCtxtPtr cctxt)
{
- xsltVarInfoPtr ivar = cctxt->ivars, ivartmp;
+ xsltVarInfoPtr ivar = cctxt->ivars, ivartmp;
while (ivar) {
ivartmp = ivar;
@@ -521,11 +530,11 @@ xsltCompilerVarInfoFree(xsltCompilerCtxtPtr cctxt)
/**
* xsltCompilerCtxtFree:
*
- * Free an XSLT compiler context.
+ * Free an XSLT compiler context.
*/
static void
xsltCompilationCtxtFree(xsltCompilerCtxtPtr cctxt)
-{
+{
if (cctxt == NULL)
return;
#ifdef WITH_XSLT_DEBUG_PARSING
@@ -597,7 +606,7 @@ xsltCompilationCtxtCreate(xsltStylesheetPtr style) {
if (ret->xpathCtxt == NULL)
goto internal_err;
#endif
-
+
return(ret);
internal_err:
@@ -645,11 +654,11 @@ xsltFreePrincipalStylesheetData(xsltPrincipalStylesheetDataPtr data)
if (data->exclResultNamespaces != NULL) {
int i;
xsltPointerListPtr list = (xsltPointerListPtr)
- data->exclResultNamespaces;
-
+ data->exclResultNamespaces;
+
for (i = 0; i < list->number; i++)
xsltPointerListFree((xsltPointerListPtr) list->items[i]);
-
+
xsltPointerListFree(list);
data->exclResultNamespaces = NULL;
}
@@ -688,10 +697,10 @@ xsltNewPrincipalStylesheetData(void)
return(NULL);
}
memset(ret, 0, sizeof(xsltPrincipalStylesheetData));
-
+
/*
* Global list of in-scope namespaces.
- */
+ */
ret->inScopeNamespaces = xsltPointerListCreate(-1);
if (ret->inScopeNamespaces == NULL)
goto internal_err;
@@ -703,7 +712,7 @@ xsltNewPrincipalStylesheetData(void)
goto internal_err;
/*
* Global list of extension instruction namespace names.
- */
+ */
ret->extElemNamespaces = xsltPointerListCreate(-1);
if (ret->extElemNamespaces == NULL)
goto internal_err;
@@ -726,7 +735,7 @@ internal_err:
*/
xsltStylesheetPtr
xsltNewStylesheet(void) {
- xsltStylesheetPtr ret = NULL;
+ xsltStylesheetPtr ret = NULL;
ret = (xsltStylesheetPtr) xmlMalloc(sizeof(xsltStylesheet));
if (ret == NULL) {
@@ -749,6 +758,7 @@ xsltNewStylesheet(void) {
ret->extrasNr = 0;
ret->internalized = 1;
ret->literal_result = 0;
+ ret->forwards_compatible = 0;
ret->dict = xmlDictCreate();
#ifdef WITH_XSLT_DEBUG
xsltGenericDebug(xsltGenericDebugContext,
@@ -865,7 +875,7 @@ xsltFreeStylesheetList(xsltStylesheetPtr style) {
static int
xsltCleanupStylesheetTree(xmlDocPtr doc ATTRIBUTE_UNUSED,
xmlNodePtr rootElem ATTRIBUTE_UNUSED)
-{
+{
#if 0 /* TODO: Currently disabled, since probably not needed. */
xmlNodePtr cur;
@@ -922,7 +932,7 @@ xsltFreeStylesheet(xsltStylesheetPtr style)
{
if (style == NULL)
return;
-
+
#ifdef XSLT_REFACTORED
/*
* Start with a cleanup of the main stylesheet's doc.
@@ -938,7 +948,7 @@ xsltFreeStylesheet(xsltStylesheetPtr style)
XSLT_HAS_INTERNAL_NSMAP(style))
{
xsltRestoreDocumentNamespaces(XSLT_GET_INTERNAL_NSMAP(style),
- style->doc);
+ style->doc);
}
#endif /* XSLT_REFACTORED_XSLT_NSCOMP */
#else
@@ -967,7 +977,7 @@ xsltFreeStylesheet(xsltStylesheetPtr style)
* TODO: Best time to shutdown extension stuff?
*/
xsltShutdownExts(style);
-
+
if (style->variables != NULL)
xsltFreeStackElemList(style->variables);
if (style->cdataSection != NULL)
@@ -1007,13 +1017,13 @@ xsltFreeStylesheet(xsltStylesheetPtr style)
xsltFreePrincipalStylesheetData(style->principalData);
style->principalData = NULL;
}
- }
+ }
#endif
/*
* Better to free the main document of this stylesheet level
* at the end - so here.
*/
- if (style->doc != NULL) {
+ if (style->doc != NULL) {
xmlFreeDoc(style->doc);
}
@@ -1044,7 +1054,7 @@ xsltFreeStylesheet(xsltStylesheetPtr style)
* @template: the template
* @node: the current node
*
- * Search all the namespace applying to a given element except the ones
+ * Search all the namespace applying to a given element except the ones
* from excluded output prefixes currently in scope. Initialize the
* template inheritedNs list with it.
*
@@ -1059,7 +1069,7 @@ xsltGetInheritedNsList(xsltStylesheetPtr style,
xmlNsPtr *ret = NULL;
int nbns = 0;
int maxns = 10;
- int i;
+ int i;
if ((style == NULL) || (template == NULL) || (node == NULL) ||
(template->inheritedNsNr != 0) || (template->inheritedNs != NULL))
@@ -1153,9 +1163,9 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
xmlChar *element,
*end;
- if ((cur == NULL) || (style == NULL))
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
-
+
prop = xmlGetNsProp(cur, (const xmlChar *) "version", NULL);
if (prop != NULL) {
if (style->version != NULL)
@@ -1281,7 +1291,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
while ((*end != 0) && (!IS_BLANK(*end)))
end++;
element = xmlStrndup(element, end - element);
- if (element) {
+ if (element) {
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"add cdata section output element %s\n",
@@ -1303,7 +1313,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
if (element == NULL) {
/*
* TODO: We'll report additionally an error
- * via the stylesheet's error handling.
+ * via the stylesheet's error handling.
*/
xsltTransformError(NULL, style, cur,
"Attribute 'cdata-section-elements': The value "
@@ -1311,7 +1321,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
style->errors++;
} else {
xmlNsPtr ns;
-
+
/*
* XSLT-1.0 "Each QName is expanded into an
* expanded-name using the namespace declarations in
@@ -1324,7 +1334,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
ns = xmlSearchNs(style->doc, cur, NULL);
if (ns != NULL)
URI = ns->href;
- }
+ }
xmlHashAddEntry2(style->cdataSection, element, URI,
(void *) "cdata");
xmlFree(element);
@@ -1368,12 +1378,12 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
xmlChar *prop;
xsltDecimalFormatPtr format;
xsltDecimalFormatPtr iter;
-
- if ((cur == NULL) || (style == NULL))
+
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
format = style->decimalFormat;
-
+
prop = xmlGetNsProp(cur, BAD_CAST("name"), NULL);
if (prop != NULL) {
format = xsltDecimalFormatGetByName(style, prop);
@@ -1402,7 +1412,7 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
if (format->decimalPoint != NULL) xmlFree(format->decimalPoint);
format->decimalPoint = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator", NULL);
if (prop != NULL) {
if (format->grouping != NULL) xmlFree(format->grouping);
@@ -1414,43 +1424,43 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
if (format->infinity != NULL) xmlFree(format->infinity);
format->infinity = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"minus-sign", NULL);
if (prop != NULL) {
if (format->minusSign != NULL) xmlFree(format->minusSign);
format->minusSign = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"NaN", NULL);
if (prop != NULL) {
if (format->noNumber != NULL) xmlFree(format->noNumber);
format->noNumber = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"percent", NULL);
if (prop != NULL) {
if (format->percent != NULL) xmlFree(format->percent);
format->percent = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"per-mille", NULL);
if (prop != NULL) {
if (format->permille != NULL) xmlFree(format->permille);
format->permille = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"zero-digit", NULL);
if (prop != NULL) {
if (format->zeroDigit != NULL) xmlFree(format->zeroDigit);
format->zeroDigit = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"digit", NULL);
if (prop != NULL) {
if (format->digit != NULL) xmlFree(format->digit);
format->digit = prop;
}
-
+
prop = xmlGetNsProp(cur, (const xmlChar *)"pattern-separator", NULL);
if (prop != NULL) {
if (format->patternSeparator != NULL) xmlFree(format->patternSeparator);
@@ -1475,7 +1485,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
xmlChar *elements;
xmlChar *element, *end;
- if ((cur == NULL) || (style == NULL))
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
@@ -1540,7 +1550,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
* an extension-element-prefixes attribute on:
* 1) an xsl:stylesheet element
* 2) an xsl:extension-element-prefixes attribute on a
- * literal result element
+ * literal result element
* 3) an extension instruction."
*/
static void
@@ -1549,7 +1559,7 @@ xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur,
xmlChar *prefixes;
xmlChar *prefix, *end;
- if ((cur == NULL) || (style == NULL))
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
if (isXsltElem) {
@@ -1614,7 +1624,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
xmlChar *elements;
xmlChar *element, *end;
- if ((cur == NULL) || (style == NULL))
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
@@ -1687,7 +1697,7 @@ xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur,
xmlChar *prefixes;
xmlChar *prefix, *end;
- if ((cur == NULL) || (style == NULL))
+ if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
return(0);
if (isXsltElem)
@@ -1744,11 +1754,11 @@ xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur,
/*
* xsltTreeEnsureXMLDecl:
* @doc: the doc
-*
+*
* BIG NOTE:
* This was copy&pasted from Libxml2's xmlTreeEnsureXMLDecl() in "tree.c".
* Ensures that there is an XML namespace declaration on the doc.
-*
+*
* Returns the XML ns-struct or NULL on API and internal errors.
*/
static xmlNsPtr
@@ -1764,7 +1774,7 @@ xsltTreeEnsureXMLDecl(xmlDocPtr doc)
if (ns == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xsltTreeEnsureXMLDecl: Failed to allocate "
- "the XML namespace.\n");
+ "the XML namespace.\n");
return (NULL);
}
memset(ns, 0, sizeof(xmlNs));
@@ -1778,7 +1788,7 @@ xsltTreeEnsureXMLDecl(xmlDocPtr doc)
else
ns->href = xmlStrdup(XML_XML_NAMESPACE);
#else
- ns->href = xmlStrdup(XML_XML_NAMESPACE);
+ ns->href = xmlStrdup(XML_XML_NAMESPACE);
#endif
ns->prefix = xmlStrdup((const xmlChar *)"xml");
doc->oldNs = ns;
@@ -1791,12 +1801,12 @@ xsltTreeEnsureXMLDecl(xmlDocPtr doc)
* @doc: the doc
* @nsName: the namespace name
* @prefix: the prefix
-*
+*
* BIG NOTE:
* This was copy&pasted from Libxml2's xmlDOMWrapStoreNs() in "tree.c".
* Creates or reuses an xmlNs struct on doc->oldNs with
* the given prefix and namespace name.
-*
+*
* Returns the aquired ns struct or NULL in case of an API
* or internal error.
*/
@@ -1829,7 +1839,7 @@ xsltTreeAcquireStoredNs(xmlDocPtr doc,
xmlStrEqual(ns->prefix, prefix) &&
xmlStrEqual(ns->href, nsName))
return (ns);
-
+
}
if (ns->next == NULL)
break;
@@ -1859,7 +1869,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
if ((cctxt->nsAliases == NULL) || (! cctxt->hasNsAliases))
return(0);
- alias = cctxt->nsAliases;
+ alias = cctxt->nsAliases;
while (alias != NULL) {
if ( /* If both namespaces are NULL... */
( (elem->ns == NULL) &&
@@ -1892,7 +1902,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
* OPTIMIZE TODO: Use the compiler-node-info inScopeNs.
*/
ns = xmlSearchNs(elem->doc, elem,
- alias->targetNs->prefix);
+ alias->targetNs->prefix);
/*
* If no matching ns-decl found, then assign a
* ns-decl stored in xmlDoc.
@@ -1914,7 +1924,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
ns = xsltTreeAcquireStoredNs(elem->doc,
alias->targetNs->href,
alias->targetNs->prefix);
-
+
if (ns == NULL) {
xsltTransformError(NULL, cctxt->style, elem,
"Internal error in "
@@ -1923,11 +1933,11 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
"ns-declaration.\n");
cctxt->style->errors++;
return(-1);
-
+
}
}
elem->ns = ns;
- }
+ }
} else {
/*
* Move into or leave in the NULL namespace.
@@ -1943,7 +1953,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
*/
if (elem->properties != NULL) {
xmlAttrPtr attr = elem->properties;
-
+
while (attr != NULL) {
if (attr->ns == NULL) {
attr = attr->next;
@@ -1962,7 +1972,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
{
if ((alias->targetNs != NULL) &&
(alias->targetNs->href != NULL))
- {
+ {
if (elem->doc == alias->docOfTargetNs) {
elem->ns = alias->targetNs;
} else {
@@ -1974,7 +1984,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
ns = xsltTreeAcquireStoredNs(elem->doc,
alias->targetNs->href,
alias->targetNs->prefix);
-
+
if (ns == NULL) {
xsltTransformError(NULL, cctxt->style, elem,
"Internal error in "
@@ -1983,7 +1993,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
"ns-declaration.\n");
cctxt->style->errors++;
return(-1);
-
+
}
}
elem->ns = ns;
@@ -1998,7 +2008,7 @@ xsltLREBuildEffectiveNs(xsltCompilerCtxtPtr cctxt,
}
alias = alias->next;
}
-
+
attr = attr->next;
}
}
@@ -2034,7 +2044,7 @@ xsltLREBuildEffectiveNsNodes(xsltCompilerCtxtPtr cctxt,
(item == NULL) || (item->effectiveNs != NULL))
return(-1);
- if (item->inScopeNs == NULL)
+ if (item->inScopeNs == NULL)
return(0);
extElemNs = cctxt->inode->extElemNs;
@@ -2065,7 +2075,7 @@ xsltLREBuildEffectiveNsNodes(xsltCompilerCtxtPtr cctxt,
* - A namespace node whose string value is a target namespace URI
* is copied to the result tree, whether or not the URI
* identifies an excluded namespace."
- *
+ *
* NOTE: The ns-aliasing machanism is non-cascading.
* (checked with Saxon, Xalan and MSXML .NET).
* URGENT TODO: is style->nsAliases the effective list of
@@ -2111,7 +2121,7 @@ xsltLREBuildEffectiveNsNodes(xsltCompilerCtxtPtr cctxt,
alias = alias->next;
} while (alias != NULL);
}
-
+
/*
* Exclude excluded result namespaces.
*/
@@ -2142,11 +2152,11 @@ add_effective_ns:
break;
}
tmpns = tmpns->next;
- } while (tmpns != NULL);
+ } while (tmpns != NULL);
} else
holdByElem = 0;
-
-
+
+
/*
* Add the effective namespace declaration.
*/
@@ -2160,7 +2170,7 @@ add_effective_ns:
}
if (cctxt->psData->effectiveNs == NULL) {
cctxt->psData->effectiveNs = effNs;
- effNs->nextInStore = NULL;
+ effNs->nextInStore = NULL;
} else {
effNs->nextInStore = cctxt->psData->effectiveNs;
cctxt->psData->effectiveNs = effNs;
@@ -2170,13 +2180,13 @@ add_effective_ns:
effNs->prefix = ns->prefix;
effNs->nsName = ns->href;
effNs->holdByElem = holdByElem;
-
+
if (lastEffNs == NULL)
item->effectiveNs = effNs;
else
lastEffNs->next = effNs;
lastEffNs = effNs;
-
+
skip_ns:
{}
}
@@ -2222,7 +2232,7 @@ xsltLREInfoCreate(xsltCompilerCtxtPtr cctxt,
* in AVTs.
*/
item->inScopeNs = cctxt->inode->inScopeNs;
-
+
if (elem)
xsltLREBuildEffectiveNsNodes(cctxt, item, elem, isLRE);
@@ -2233,13 +2243,13 @@ xsltLREInfoCreate(xsltCompilerCtxtPtr cctxt,
}
/**
- * xsltCompilerVarInfoPush:
+ * xsltCompilerVarInfoPush:
* @cctxt: the compilation context
- *
+ *
* Pushes a new var/param info onto the stack.
*
* Returns the acquired variable info.
- */
+ */
static xsltVarInfoPtr
xsltCompilerVarInfoPush(xsltCompilerCtxtPtr cctxt,
xmlNodePtr inst,
@@ -2278,12 +2288,12 @@ xsltCompilerVarInfoPush(xsltCompilerCtxtPtr cctxt,
}
/**
- * xsltCompilerVarInfoPop:
+ * xsltCompilerVarInfoPop:
* @cctxt: the compilation context
- *
+ *
* Pops all var/param infos from the stack, which
* have the current depth.
- */
+ */
static void
xsltCompilerVarInfoPop(xsltCompilerCtxtPtr cctxt)
{
@@ -2301,20 +2311,20 @@ xsltCompilerVarInfoPop(xsltCompilerCtxtPtr cctxt)
* @cctxt: the compilation context
* @node: the node to be pushed (this can also be the doc-node)
*
-*
+*
*
* Returns the current node info structure or
* NULL in case of an internal error.
*/
static xsltCompilerNodeInfoPtr
xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
-{
+{
xsltCompilerNodeInfoPtr inode, iprev;
- if ((cctxt->inode != NULL) && (cctxt->inode->next != NULL)) {
+ if ((cctxt->inode != NULL) && (cctxt->inode->next != NULL)) {
inode = cctxt->inode->next;
} else if ((cctxt->inode == NULL) && (cctxt->inodeList != NULL)) {
- inode = cctxt->inodeList;
+ inode = cctxt->inodeList;
} else {
/*
* Create a new node-info.
@@ -2334,7 +2344,7 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
inode->prev = cctxt->inodeLast;
}
cctxt->inodeLast = inode;
- cctxt->maxNodeInfos++;
+ cctxt->maxNodeInfos++;
if (cctxt->inode == NULL) {
cctxt->inode = inode;
/*
@@ -2342,12 +2352,12 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
* the root of the stylesheet.
*/
xsltLREInfoCreate(cctxt, NULL, 0);
- }
- }
+ }
+ }
cctxt->depth++;
cctxt->inode = inode;
/*
- * REVISIT TODO: Keep the reset always complete.
+ * REVISIT TODO: Keep the reset always complete.
* NOTE: Be carefull with the @node, since it might be
* a doc-node.
*/
@@ -2360,7 +2370,7 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
inode->curChildType = 0;
inode->extContentHandled = 0;
inode->isRoot = 0;
-
+
if (inode->prev != NULL) {
iprev = inode->prev;
/*
@@ -2390,7 +2400,7 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
/*
* Forwards-compatible mode
*/
- inode->forwardsCompat = iprev->forwardsCompat;
+ inode->forwardsCompat = iprev->forwardsCompat;
} else {
inode->inScopeNs = NULL;
inode->exclResultNs = NULL;
@@ -2398,7 +2408,7 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
inode->preserveWhitespace = 0;
inode->forwardsCompat = 0;
}
-
+
return(inode);
}
@@ -2412,7 +2422,7 @@ xsltCompilerNodePush(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
*/
static void
xsltCompilerNodePop(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
-{
+{
if (cctxt->inode == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xsltCompilerNodePop: Top-node mismatch.\n");
@@ -2432,13 +2442,13 @@ xsltCompilerNodePop(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
"xsltCompilerNodePop: Depth mismatch.\n");
goto mismatch;
}
+ cctxt->depth--;
/*
* Pop information of variables.
*/
if ((cctxt->ivar) && (cctxt->ivar->depth > cctxt->depth))
xsltCompilerVarInfoPop(cctxt);
- cctxt->depth--;
cctxt->inode = cctxt->inode->prev;
if (cctxt->inode != NULL)
cctxt->inode->curChildType = 0;
@@ -2448,7 +2458,7 @@ mismatch:
{
const xmlChar *nsName = NULL, *name = NULL;
const xmlChar *infnsName = NULL, *infname = NULL;
-
+
if (node) {
if (node->type == XML_ELEMENT_NODE) {
name = node->name;
@@ -2477,7 +2487,7 @@ mismatch:
} else
infname = BAD_CAST "Not given";
-
+
xmlGenericError(xmlGenericErrorContext,
"xsltCompilerNodePop: Given : '%s' URI '%s'\n",
name, nsName);
@@ -2585,7 +2595,7 @@ xsltCompilerBuildInScopeNsList(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if (xsltPointerListAddSize(
(xsltPointerListPtr)cctxt->psData->inScopeNamespaces,
(void *) nsi, 5) == -1)
- {
+ {
xmlFree(nsi);
nsi = NULL;
xsltTransformError(NULL, cctxt->style, NULL,
@@ -2602,7 +2612,7 @@ xsltCompilerBuildInScopeNsList(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
internal_err:
if (list != NULL)
- xmlFree(list);
+ xmlFree(list);
cctxt->style->errors++;
return(NULL);
}
@@ -2615,7 +2625,7 @@ xsltParseNsPrefixList(xsltCompilerCtxtPtr cctxt,
{
xmlChar *cur, *end;
xmlNsPtr ns;
-
+
if ((cctxt == NULL) || (value == NULL) || (list == NULL))
return(-1);
@@ -2632,7 +2642,7 @@ xsltParseNsPrefixList(xsltCompilerCtxtPtr cctxt,
if (cur == NULL) {
cur = end;
continue;
- }
+ }
/*
* TODO: Export and use xmlSearchNsByPrefixStrict()
* in Libxml2, tree.c, since xmlSearchNs() is in most
@@ -2644,7 +2654,7 @@ xsltParseNsPrefixList(xsltCompilerCtxtPtr cctxt,
xmlStrEqual(cur, (const xmlChar *)"#default"))
ns = xmlSearchNs(cctxt->style->doc, node, NULL);
else
- ns = xmlSearchNs(cctxt->style->doc, node, cur);
+ ns = xmlSearchNs(cctxt->style->doc, node, cur);
if (ns == NULL) {
/*
@@ -2677,7 +2687,7 @@ xsltParseNsPrefixList(xsltCompilerCtxtPtr cctxt,
}
}
xmlFree(cur);
-
+
cur = end;
}
return(0);
@@ -2710,7 +2720,7 @@ xsltCompilerUtilsCreateMergedList(xsltPointerListPtr first,
else
num = 0;
if (second)
- num += second->number;
+ num += second->number;
if (num == 0)
return(NULL);
ret = xsltPointerListCreate(num);
@@ -2746,7 +2756,7 @@ static xsltPointerListPtr
xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
xsltPointerListPtr def,
int instrCategory)
-{
+{
xsltPointerListPtr list = NULL;
xmlChar *value;
xmlAttrPtr attr;
@@ -2759,7 +2769,7 @@ xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
else
attr = xmlHasNsProp(node, BAD_CAST "exclude-result-prefixes",
XSLT_NAMESPACE);
- if (attr == NULL)
+ if (attr == NULL)
return(def);
if (attr && (instrCategory == XSLT_ELEMENT_CATEGORY_LRE)) {
@@ -2769,7 +2779,7 @@ xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
attr->psvi = (void *) xsltXSLTAttrMarker;
}
- if ((attr->children != NULL) &&
+ if ((attr->children != NULL) &&
(attr->children->content != NULL))
value = attr->children->content;
else {
@@ -2777,19 +2787,19 @@ xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
"Attribute 'exclude-result-prefixes': Invalid value.\n");
cctxt->style->errors++;
return(def);
- }
+ }
if (xsltParseNsPrefixList(cctxt, cctxt->tmpList, node,
BAD_CAST value) != 0)
goto exit;
- if (cctxt->tmpList->number == 0)
- goto exit;
+ if (cctxt->tmpList->number == 0)
+ goto exit;
/*
* Merge the list with the inherited list.
*/
list = xsltCompilerUtilsCreateMergedList(def, cctxt->tmpList);
if (list == NULL)
- goto exit;
+ goto exit;
/*
* Store the list in the stylesheet/compiler context.
*/
@@ -2806,7 +2816,7 @@ xsltParseExclResultPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
if (cctxt->inode != NULL)
cctxt->inode->nsChanged = 1;
-exit:
+exit:
if (list != NULL)
return(list);
else
@@ -2827,7 +2837,7 @@ static xsltPointerListPtr
xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
xsltPointerListPtr def,
int instrCategory)
-{
+{
xsltPointerListPtr list = NULL;
xmlAttrPtr attr;
xmlChar *value;
@@ -2841,7 +2851,7 @@ xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
else
attr = xmlHasNsProp(node, BAD_CAST "extension-element-prefixes",
XSLT_NAMESPACE);
- if (attr == NULL)
+ if (attr == NULL)
return(def);
if (attr && (instrCategory == XSLT_ELEMENT_CATEGORY_LRE)) {
@@ -2851,7 +2861,7 @@ xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
attr->psvi = (void *) xsltXSLTAttrMarker;
}
- if ((attr->children != NULL) &&
+ if ((attr->children != NULL) &&
(attr->children->content != NULL))
value = attr->children->content;
else {
@@ -2867,7 +2877,7 @@ xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
goto exit;
if (cctxt->tmpList->number == 0)
- goto exit;
+ goto exit;
/*
* REVISIT: Register the extension namespaces.
*/
@@ -2896,7 +2906,7 @@ xsltParseExtElemPrefixes(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
if (cctxt->inode != NULL)
cctxt->inode->nsChanged = 1;
-exit:
+exit:
if (list != NULL)
return(list);
else
@@ -2916,7 +2926,7 @@ exit:
* -1 if an internal or API error occured.
*/
static int
-xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
+xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
int instrCategory)
{
xmlChar *value;
@@ -2930,12 +2940,12 @@ xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
else
attr = xmlHasNsProp(node, BAD_CAST "version", XSLT_NAMESPACE);
- if (attr == NULL)
+ if (attr == NULL)
return(0);
attr->psvi = (void *) xsltXSLTAttrMarker;
- if ((attr->children != NULL) &&
+ if ((attr->children != NULL) &&
(attr->children->content != NULL))
value = attr->children->content;
else {
@@ -2944,7 +2954,7 @@ xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
cctxt->style->errors++;
return(1);
}
-
+
if (! xmlStrEqual(value, (const xmlChar *)"1.0")) {
cctxt->inode->forwardsCompat = 1;
/*
@@ -2964,7 +2974,7 @@ xsltParseAttrXSLTVersion(xsltCompilerCtxtPtr cctxt, xmlNodePtr node,
"processor.\n");
cctxt->style->warnings++;
cctxt->errSeverity = XSLT_ERROR_SEVERITY_ERROR;
- }
+ }
} else {
cctxt->inode->forwardsCompat = 0;
}
@@ -3022,8 +3032,8 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if (xmlNodeGetSpacePreserve(node) != 1)
cctxt->inode->preserveWhitespace = 0;
else
- cctxt->inode->preserveWhitespace = 1;
-
+ cctxt->inode->preserveWhitespace = 1;
+
/*
* Eval if we should keep the old incorrect behaviour.
*/
@@ -3045,7 +3055,7 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
deleteNode = NULL;
}
if (cur->type == XML_ELEMENT_NODE) {
-
+
/*
* Clear the PSVI field.
*/
@@ -3054,8 +3064,8 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
xsltCompilerNodePush(cctxt, cur);
inXSLText = 0;
- textNode = NULL;
- findSpaceAttr = 1;
+ textNode = NULL;
+ findSpaceAttr = 1;
cctxt->inode->stripWhitespace = 0;
/*
* TODO: I'd love to use a string pointer comparison here :-/
@@ -3086,18 +3096,18 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
* XSLT 2.0: "Any whitespace text node whose parent is
* one of the following elements is removed from the "
* tree, regardless of any xml:space attributes:..."
- * xsl:apply-imports,
+ * xsl:apply-imports,
* xsl:apply-templates,
* xsl:attribute-set,
- * xsl:call-template,
+ * xsl:call-template,
* xsl:choose,
* xsl:stylesheet, xsl:transform.
* XSLT 2.0: xsl:analyze-string,
* xsl:character-map,
- * xsl:next-match
+ * xsl:next-match
*
* TODO: I'd love to use a string pointer comparison here :-/
- */
+ */
name = cur->name;
switch (*name) {
case 't':
@@ -3119,7 +3129,7 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
findSpaceAttr = 0;
cctxt->inode->preserveWhitespace = 1;
inXSLText = 1;
- }
+ }
break;
case 'c':
if (xmlStrEqual(name, BAD_CAST "choose") ||
@@ -3168,7 +3178,7 @@ xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
*/
break;
}
- } while (cur->prev);
+ } while (cur->prev);
}
}
break;
@@ -3188,13 +3198,13 @@ process_attributes:
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
if ((attr->ns) && (attr->ns->href != nsNameXSLT) &&
xmlStrEqual(attr->ns->href, nsNameXSLT))
- {
+ {
nsMapItem = xsltNewNamespaceMapItem(cctxt,
doc, attr->ns, cur);
if (nsMapItem == NULL)
goto internal_err;
attr->ns->href = nsNameXSLT;
- }
+ }
#endif
if (internalize) {
/*
@@ -3223,7 +3233,7 @@ process_attributes:
if ((findSpaceAttr != 0) &&
(attr->ns != NULL) &&
(attr->name != NULL) &&
- (attr->name[0] == 's') &&
+ (attr->name[0] == 's') &&
(attr->ns->prefix != NULL) &&
(attr->ns->prefix[0] == 'x') &&
(attr->ns->prefix[1] == 'm') &&
@@ -3234,7 +3244,7 @@ process_attributes:
XML_XML_NAMESPACE);
if (value != NULL) {
if (xmlStrEqual(value, BAD_CAST "preserve")) {
- cctxt->inode->preserveWhitespace = 1;
+ cctxt->inode->preserveWhitespace = 1;
} else if (xmlStrEqual(value, BAD_CAST "default")) {
cctxt->inode->preserveWhitespace = 0;
} else {
@@ -3246,7 +3256,7 @@ process_attributes:
findSpaceAttr = 0;
xmlFree(value);
}
-
+
}
attr = attr->next;
} while (attr != NULL);
@@ -3263,17 +3273,17 @@ process_attributes:
{
/*
* Merge adjacent text/CDATA-section-nodes
- * ---------------------------------------
+ * ---------------------------------------
* In order to avoid breaking of existing stylesheets,
* if the old behaviour is wanted (strictWhitespace == 0),
* then we *won't* merge adjacent text-nodes
* (except in xsl:text); this will ensure that whitespace-only
* text nodes are (incorrectly) not stripped in some cases.
- *
+ *
* Example: : <foo> <!-- bar -->zoo</foo>
* Corrent (strict) result: <foo> zoo</foo>
* Incorrect (old) result : <foo>zoo</foo>
- *
+ *
* NOTE that we *will* merge adjacent text-nodes if
* they are in xsl:text.
* Example, the following:
@@ -3305,10 +3315,10 @@ process_attributes:
if (textNode == NULL)
textNode = cur;
goto end_of_text;
- }
+ }
} else if ((cur->type == XML_COMMENT_NODE) ||
(cur->type == XML_PI_NODE))
- {
+ {
/*
* Remove processing instructions and comments.
*/
@@ -3344,7 +3354,7 @@ end_of_text:
(! cctxt->inode->preserveWhitespace)) &&
IS_BLANK(*value) &&
xsltIsBlank(value)))
- {
+ {
if (textNode != cur) {
xmlUnlinkNode(textNode);
xmlFreeNode(textNode);
@@ -3494,7 +3504,7 @@ xsltPrecomputeStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
} else {
exclPrefixes = xsltParseStylesheetExcludePrefix(style, cur, 0);
}
-
+
if ((cur->nsDef != NULL) && (style->exclPrefixNr > 0)) {
xmlNsPtr ns = cur->nsDef, prev = NULL, next;
xmlNodePtr root = NULL;
@@ -3506,7 +3516,7 @@ xsltPrecomputeStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
moved = 0;
next = ns->next;
for (i = 0;i < style->exclPrefixNr;i++) {
- if ((ns->prefix != NULL) &&
+ if ((ns->prefix != NULL) &&
(xmlStrEqual(ns->href,
style->exclPrefixTab[i]))) {
/*
@@ -3630,7 +3640,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
if (style == NULL)
return;
- /*
+ /*
* TODO: basically if the stylesheet uses the same prefix for different
* patterns, well they may be in problem, hopefully they will get
* a warning first.
@@ -3640,7 +3650,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
* An expression should be evaluated in the context of the in-scope
* namespaces; eliminate the restriction of an XML document to contain
* no duplicate prefixes for different namespace names.
- *
+ *
*/
cur = xmlDocGetRootElement(style->doc);
while (cur != NULL) {
@@ -3689,7 +3699,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
cur = cur->next;
continue;
}
-
+
do {
cur = cur->parent;
if (cur == NULL)
@@ -3831,7 +3841,7 @@ xsltGetXSLTElementTypeByNode(xsltCompilerCtxtPtr cctxt,
*
* Returns 0 if everything's fine;
* -1 on API or internal errors.
- */
+ */
int
xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
{
@@ -3849,7 +3859,7 @@ xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
cctxt->inode->extContentHandled = 1;
}
-
+
xsltCompilerNodePush(cctxt, elem);
/*
* URGENT TODO: Find a way to speed up this annoying redundant
@@ -3858,7 +3868,7 @@ xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
if (cctxt->inode->prev->curChildType != 0)
cctxt->inode->type = cctxt->inode->prev->curChildType;
else
- cctxt->inode->type = xsltGetXSLTElementTypeByNode(cctxt, elem);
+ cctxt->inode->type = xsltGetXSLTElementTypeByNode(cctxt, elem);
/*
* Update the in-scope namespaces if needed.
*/
@@ -3879,31 +3889,31 @@ xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
/*
* Validate the content model of the XSLT-element.
*/
- switch (cctxt->inode->type) {
+ switch (cctxt->inode->type) {
case XSLT_FUNC_APPLYIMPORTS:
/* EMPTY */
goto empty_content;
case XSLT_FUNC_APPLYTEMPLATES:
/* <!-- Content: (xsl:sort | xsl:with-param)* --> */
- goto apply_templates;
- case XSLT_FUNC_ATTRIBUTE:
+ goto apply_templates;
+ case XSLT_FUNC_ATTRIBUTE:
/* <!-- Content: template --> */
goto sequence_constructor;
case XSLT_FUNC_CALLTEMPLATE:
/* <!-- Content: xsl:with-param* --> */
goto call_template;
- case XSLT_FUNC_CHOOSE:
+ case XSLT_FUNC_CHOOSE:
/* <!-- Content: (xsl:when+, xsl:otherwise?) --> */
goto choose;
case XSLT_FUNC_COMMENT:
/* <!-- Content: template --> */
- goto sequence_constructor;
+ goto sequence_constructor;
case XSLT_FUNC_COPY:
/* <!-- Content: template --> */
- goto sequence_constructor;
+ goto sequence_constructor;
case XSLT_FUNC_COPYOF:
/* EMPTY */
- goto empty_content;
+ goto empty_content;
case XSLT_FUNC_DOCUMENT: /* Extra one */
/* ?? template ?? */
goto sequence_constructor;
@@ -3970,7 +3980,7 @@ xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
* Check for redefinition.
*/
if ((elem->psvi != NULL) && (cctxt->ivar != NULL)) {
- xsltVarInfoPtr ivar = cctxt->ivar;
+ xsltVarInfoPtr ivar = cctxt->ivar;
do {
if ((ivar->name ==
@@ -4000,7 +4010,7 @@ xsltParseAnyXSLTElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem)
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"xsltParseXSLTNode: Unhandled XSLT element '%s'.\n",
- elem->name);
+ elem->name);
#endif
xsltTransformError(NULL, cctxt->style, elem,
"xsltParseXSLTNode: Internal error; "
@@ -4029,7 +4039,7 @@ apply_templates:
}
child = child->next;
} while (child != NULL);
- }
+ }
goto exit;
call_template:
@@ -4053,7 +4063,7 @@ call_template:
}
child = child->next;
} while (child != NULL);
- }
+ }
goto exit;
text:
@@ -4089,7 +4099,7 @@ empty_content:
break;
}
child = child->next;
- } while (child != NULL);
+ } while (child != NULL);
}
goto exit;
@@ -4108,7 +4118,7 @@ choose:
if (child->type == XML_ELEMENT_NODE) {
if (IS_XSLT_ELEM_FAST(child)) {
xsltStyleType type;
-
+
type = xsltGetXSLTElementTypeByNode(cctxt, child);
if (type == XSLT_FUNC_WHEN) {
nbWhen++;
@@ -4124,7 +4134,7 @@ choose:
xsltParseContentError(cctxt->style, child);
err = 1;
break;
- }
+ }
if (nbOtherwise) {
xsltTransformError(NULL, cctxt->style, elem,
"The XSLT 'choose' element must not contain "
@@ -4140,7 +4150,7 @@ choose:
xsltParseContentError(cctxt->style, child);
} else
xsltParseContentError(cctxt->style, child);
- }
+ }
/*
else
xsltParseContentError(cctxt, child);
@@ -4152,8 +4162,8 @@ choose:
"The XSLT element 'choose' must contain at least one "
"XSLT element 'when'.\n");
cctxt->style->errors++;
- }
- }
+ }
+ }
goto exit;
for_each:
@@ -4170,13 +4180,13 @@ for_each:
/*
* Parse xsl:sort first.
*/
- do {
+ do {
if ((child->type == XML_ELEMENT_NODE) &&
IS_XSLT_ELEM_FAST(child))
- {
+ {
if (xsltGetXSLTElementTypeByNode(cctxt, child) ==
XSLT_FUNC_SORT)
- {
+ {
cctxt->inode->curChildType = XSLT_FUNC_SORT;
xsltParseAnyXSLTElem(cctxt, child);
} else
@@ -4190,7 +4200,7 @@ for_each:
*/
if (child != NULL)
xsltParseSequenceConstructor(cctxt, child);
- }
+ }
goto exit;
sequence_constructor:
@@ -4207,10 +4217,10 @@ sequence_constructor:
if ((elem->next != NULL) &&
((cctxt->inode->type == XSLT_FUNC_VARIABLE) ||
(cctxt->inode->type == XSLT_FUNC_PARAM)))
- {
+ {
if ((elem->psvi != NULL) &&
(((xsltStyleBasicItemVariablePtr) elem->psvi)->name))
- {
+ {
xsltCompilerVarInfoPush(cctxt, elem,
((xsltStyleBasicItemVariablePtr) elem->psvi)->name,
((xsltStyleBasicItemVariablePtr) elem->psvi)->ns);
@@ -4230,13 +4240,13 @@ internal_err:
/**
* xsltForwardsCompatUnkownItemCreate:
*
- * @cctxt: the compilation context
+ * @cctxt: the compilation context
*
* Creates a compiled representation of the unknown
* XSLT instruction.
*
* Returns the compiled representation.
- */
+ */
static xsltStyleItemUknownPtr
xsltForwardsCompatUnkownItemCreate(xsltCompilerCtxtPtr cctxt)
{
@@ -4273,12 +4283,12 @@ xsltForwardsCompatUnkownItemCreate(xsltCompilerCtxtPtr cctxt)
* Returns 1 in the unknown XSLT instruction is rejected,
* 0 if everything's fine and
* -1 on API or internal errors.
- */
+ */
static int
xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
xmlNodePtr node)
{
- if ((cctxt == NULL) || (node == NULL))
+ if ((cctxt == NULL) || (node == NULL) || (node->type != XML_ELEMENT_NODE))
return(-1);
/*
@@ -4286,8 +4296,8 @@ xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
*/
if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
cctxt->inode->extContentHandled = 1;
- }
- if (cctxt->inode->forwardsCompat == 0) {
+ }
+ if (cctxt->inode->forwardsCompat == 0) {
/*
* We are not in forwards-compatible mode, so raise an error.
*/
@@ -4299,7 +4309,7 @@ xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
/*
* Forwards-compatible mode.
* ------------------------
- *
+ *
* Parse/compile xsl:fallback elements.
*
* QUESTION: Do we have to raise an error if there's no xsl:fallback?
@@ -4342,7 +4352,7 @@ xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
}
child = child->next;
} while (child != NULL);
-
+
xsltCompilerNodePop(cctxt, node);
}
return(0);
@@ -4356,7 +4366,7 @@ xsltParseUnknownXSLTElem(xsltCompilerCtxtPtr cctxt,
*
* Parses a "template" content (or "sequence constructor" in XSLT 2.0 terms).
* This will additionally remove xsl:text elements from the tree.
- */
+ */
void
xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
{
@@ -4375,7 +4385,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
if (cctxt->inode->category == XSLT_ELEMENT_CATEGORY_EXTENSION) {
cctxt->inode->extContentHandled = 1;
}
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return;
/*
* This is the content reffered to as a "template".
@@ -4396,14 +4406,14 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
* xsl:choose, xsl:if, xsl:text, xsl:copy, xsl:variable,
* xsl:message, xsl:fallback,
* xsl:processing-instruction, xsl:comment, xsl:element
- * xsl:attribute.
+ * xsl:attribute.
* Additional allowed content:
* 1) extension instructions
* 2) literal result elements
* 3) PCDATA
*
* NOTE that this content model does *not* allow xsl:param.
- */
+ */
while (cur != NULL) {
if (deleteNode != NULL) {
#ifdef WITH_XSLT_DEBUG_BLANKS
@@ -4414,8 +4424,8 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
xmlFreeNode(deleteNode);
deleteNode = NULL;
}
- if (cur->type == XML_ELEMENT_NODE) {
-
+ if (cur->type == XML_ELEMENT_NODE) {
+
if (cur->psvi == xsltXSLTTextMarker) {
/*
* xsl:text elements
@@ -4452,7 +4462,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
"Element 'xsl:text': Invalid type "
"of node found in content.\n");
cctxt->style->errors++;
- }
+ }
}
if (cur->properties) {
xmlAttrPtr attr;
@@ -4503,7 +4513,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
/*
* TODO: Using the XSLT-marker is still not stable yet.
*/
- /* if (cur->psvi == xsltXSLTElemMarker) { */
+ /* if (cur->psvi == xsltXSLTElemMarker) { */
/*
* XSLT instructions
* --------------------------------------------------------
@@ -4537,7 +4547,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
xsltParseAnyXSLTElem(cctxt, cur);
break;
default:
- xsltParseUnknownXSLTElem(cctxt, cur);
+ xsltParseUnknownXSLTElem(cctxt, cur);
cur = cur->next;
continue;
}
@@ -4613,7 +4623,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
}
cur->psvi = (void *)
xsltPreComputeExtModuleElement(cctxt->style, cur);
-
+
if (cur->psvi == NULL) {
/*
* OLD COMMENT: "Unknown element, maybe registered
@@ -4685,7 +4695,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
xsltParseAttrXSLTVersion(cctxt, cur,
XSLT_ELEMENT_CATEGORY_LRE);
/*
- * Report invalid XSLT attributes.
+ * Report invalid XSLT attributes.
* For XSLT 1.0 only xsl:use-attribute-sets is allowed
* next to xsl:version, xsl:exclude-result-prefixes and
* xsl:extension-element-prefixes.
@@ -4696,10 +4706,10 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
do {
if ((attr->psvi != xsltXSLTAttrMarker) &&
IS_XSLT_ATTR_FAST(attr))
- {
+ {
if (! xmlStrEqual(attr->name,
BAD_CAST "use-attribute-sets"))
- {
+ {
xsltTransformError(NULL, cctxt->style,
cur,
"Unknown XSLT attribute '%s'.\n",
@@ -4731,7 +4741,7 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
*/
if (cur->properties) {
xmlAttrPtr attr = cur->properties;
-
+
while (attr != NULL) {
xsltCompileAttr(cctxt->style, attr);
attr = attr->next;
@@ -4774,13 +4784,14 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
* constructor" in XSLT 2.0); it it allows addional xsl:param
* elements as immediate children of @templ.
*
- * Called by:
+ * Called by:
* exsltFuncFunctionComp() (EXSLT, functions.c)
* So this is intended to be called from extension functions.
*/
void
xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
- if ((style == NULL) || (templ == NULL))
+ if ((style == NULL) || (templ == NULL) ||
+ (templ->type == XML_NAMESPACE_DECL))
return;
/*
@@ -4790,13 +4801,13 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
XSLT_CCTXT(style)->inode->extContentHandled = 1;
}
- if (templ->children != NULL) {
+ if (templ->children != NULL) {
xmlNodePtr child = templ->children;
/*
* Process xsl:param elements, which can only occur as the
* immediate children of xsl:template (well, and of any
* user-defined extension instruction if needed).
- */
+ */
do {
if ((child->type == XML_ELEMENT_NODE) &&
IS_XSLT_ELEM_FAST(child) &&
@@ -4829,6 +4840,10 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
void
xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
xmlNodePtr cur, delete;
+
+ if ((style == NULL) || (templ == NULL) ||
+ (templ->type == XML_NAMESPACE_DECL)) return;
+
/*
* This content comes from the stylesheet
* For stylesheets, the set of whitespace-preserving
@@ -4859,7 +4874,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
xmlChar *prop;
xmlNodePtr text = cur->children, next;
int noesc = 0;
-
+
prop = xmlGetNsProp(cur,
(const xmlChar *)"disable-output-escaping",
NULL);
@@ -4912,7 +4927,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
*/
if (text->doc->dict != NULL) {
const xmlChar *tmp;
-
+
tmp = xmlDictLookup(text->doc->dict,
text->content, -1);
if (tmp != text->content) {
@@ -4974,7 +4989,7 @@ skip_children:
cur = cur->next;
continue;
}
-
+
do {
cur = cur->parent;
if (cur == NULL)
@@ -5048,7 +5063,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
xmlChar *name = NULL;
xmlChar *nameURI = NULL;
- if ((style == NULL) || (key == NULL))
+ if ((style == NULL) || (key == NULL) || (key->type != XML_ELEMENT_NODE))
return;
/*
@@ -5135,10 +5150,11 @@ error:
static void
xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
xsltTemplatePtr templ;
- xmlChar *prop;
- double priority;
+ xmlChar *prop;
+ double priority;
- if ((cctxt == NULL) || (templNode == NULL))
+ if ((cctxt == NULL) || (templNode == NULL) ||
+ (templNode->type != XML_ELEMENT_NODE))
return;
/*
@@ -5155,19 +5171,19 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
templ->next = cctxt->style->templates;
cctxt->style->templates = templ;
- templ->style = cctxt->style;
+ templ->style = cctxt->style;
/*
* Attribute "mode".
*/
prop = xmlGetNsProp(templNode, (const xmlChar *)"mode", NULL);
- if (prop != NULL) {
+ if (prop != NULL) {
const xmlChar *modeURI;
/*
* TODO: We need a standardized function for extraction
* of namespace names and local names from QNames.
- * Don't use xsltGetQNameURI() as it cannot channel
+ * Don't use xsltGetQNameURI() as it cannot channe�
* reports through the context.
*/
modeURI = xsltGetQNameURI(templNode, &prop);
@@ -5217,7 +5233,7 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
if (prop != NULL) {
const xmlChar *nameURI;
xsltTemplatePtr curTempl;
-
+
/*
* TODO: Don't use xsltGetQNameURI().
*/
@@ -5235,7 +5251,7 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
"the value is not a valid NCName.\n", templ->name);
cctxt->style->errors++;
goto error;
- }
+ }
if (nameURI != NULL)
templ->nameURI = xmlDictLookup(cctxt->style->dict, nameURI, -1);
curTempl = templ->next;
@@ -5254,7 +5270,7 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
}
}
if (templNode->children != NULL) {
- xsltParseTemplateContent(cctxt->style, templNode);
+ xsltParseTemplateContent(cctxt->style, templNode);
/*
* MAYBE TODO: Custom behaviour: In order to stay compatible with
* Xalan and MSXML(.NET), we could allow whitespace
@@ -5269,9 +5285,9 @@ xsltParseXSLTTemplate(xsltCompilerCtxtPtr cctxt, xmlNodePtr templNode) {
* <xsl:param name="zoo"/>
* ... the whitespace between every xsl:param would be
* added to the result tree.
- */
- }
-
+ */
+ }
+
templ->elem = templNode;
templ->content = templNode->children;
xsltAddTemplate(cctxt->style, templ, templ->mode, templ->modeURI);
@@ -5299,7 +5315,8 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
xmlChar *modeURI = NULL;
double priority;
- if (template == NULL)
+ if ((style == NULL) || (template == NULL) ||
+ (template->type != XML_ELEMENT_NODE))
return;
/*
@@ -5311,7 +5328,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
ret->next = style->templates;
style->templates = ret;
ret->style = style;
-
+
/*
* Get inherited namespaces
*/
@@ -5366,7 +5383,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
if (prop != NULL) {
const xmlChar *URI;
xsltTemplatePtr cur;
-
+
/*
* TODO: Don't use xsltGetQNameURI().
*/
@@ -5431,7 +5448,7 @@ static xsltStyleItemIncludePtr
xsltCompileXSLTIncludeElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node) {
xsltStyleItemIncludePtr item;
- if ((cctxt == NULL) || (node == NULL))
+ if ((cctxt == NULL) || (node == NULL) || (node->type != XML_ELEMENT_NODE))
return(NULL);
node->psvi = NULL;
@@ -5462,7 +5479,7 @@ xsltParseFindTopLevelElem(xsltCompilerCtxtPtr cctxt,
xmlNodePtr cur,
const xmlChar *name,
const xmlChar *namespaceURI,
- int breakOnOtherElem,
+ int breakOnOtherElem,
xmlNodePtr *resultNode)
{
if (name == NULL)
@@ -5474,7 +5491,7 @@ xsltParseFindTopLevelElem(xsltCompilerCtxtPtr cctxt,
if ((cur->ns != NULL) && (cur->name != NULL)) {
if ((*(cur->name) == *name) &&
xmlStrEqual(cur->name, name) &&
- xmlStrEqual(cur->ns->href, namespaceURI))
+ xmlStrEqual(cur->ns->href, namespaceURI))
{
*resultNode = cur;
return(1);
@@ -5517,13 +5534,13 @@ xsltParseTopLevelXSLTElem(xsltCompilerCtxtPtr cctxt,
int oldIsInclude;
if (xsltCompileXSLTIncludeElem(cctxt, node) == NULL)
- goto exit;
+ goto exit;
/*
* Mark this stylesheet tree as being currently included.
*/
oldIsInclude = cctxt->isInclude;
cctxt->isInclude = 1;
-
+
if (xsltParseStylesheetInclude(cctxt->style, node) != 0) {
cctxt->style->errors++;
}
@@ -5573,7 +5590,7 @@ xsltParseRemoveWhitespace(xmlNodePtr node)
if (((child->type == XML_TEXT_NODE) ||
(child->type == XML_CDATA_SECTION_NODE)) &&
(IS_BLANK_NODE(child)))
- delNode = child;
+ delNode = child;
child = child->next;
} while (child != NULL);
if (delNode) {
@@ -5597,9 +5614,9 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if ((cctxt == NULL) || (node == NULL) ||
(node->type != XML_ELEMENT_NODE))
- return(-1);
+ return(-1);
- style = cctxt->style;
+ style = cctxt->style;
/*
* At this stage all import declarations of all stylesheet modules
* with the same stylesheet level have been processed.
@@ -5630,13 +5647,13 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if (node == NULL) {
return(-1);
}
- }
-
+ }
+
if (node->children == NULL)
return(0);
/*
* Push the xsl:stylesheet/xsl:transform element.
- */
+ */
xsltCompilerNodePush(cctxt, node);
cctxt->inode->isRoot = 1;
cctxt->inode->nsChanged = 0;
@@ -5651,7 +5668,7 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
* stylesheet is rooted at, regardless if it's an XSLT
* instruction or a literal result instruction (or if
* this is an embedded stylesheet).
- */
+ */
cctxt->inode->inScopeNs =
xsltCompilerBuildInScopeNsList(cctxt, node);
@@ -5662,11 +5679,11 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
* id = id
* extension-element-prefixes = tokens
* exclude-result-prefixes = tokens
- * version = number (mandatory)
+ * version = number (mandatory)
*/
if (xsltParseAttrXSLTVersion(cctxt, node,
XSLT_ELEMENT_CATEGORY_XSLT) == 0)
- {
+ {
/*
* Attribute "version".
* XSLT 1.0: "An xsl:stylesheet element *must* have a version
@@ -5679,21 +5696,21 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if (isXsltElem)
xsltTransformError(NULL, cctxt->style, node,
"The attribute 'version' is missing.\n");
- cctxt->style->errors++;
+ cctxt->style->errors++;
#else
/* OLD behaviour. */
xsltTransformError(NULL, cctxt->style, node,
"xsl:version is missing: document may not be a stylesheet\n");
cctxt->style->warnings++;
#endif
- }
+ }
/*
* The namespaces declared by the attributes
* "extension-element-prefixes" and
* "exclude-result-prefixes" are local to *this*
* stylesheet tree; i.e., they are *not* visible to
* other stylesheet-modules, whether imported or included.
- *
+ *
* Attribute "extension-element-prefixes".
*/
cctxt->inode->extElemNs =
@@ -5764,9 +5781,9 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
xsltParseFindTopLevelElem(cctxt, cur,
BAD_CAST "param", XSLT_NAMESPACE, 0, &cur) == 1)
{
- xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_PARAM);
+ xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_PARAM);
cur = cur->next;
- }
+ }
/*
* Process all top-level xsl:variable elements.
*/
@@ -5777,16 +5794,16 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
{
xsltParseTopLevelXSLTElem(cctxt, cur, XSLT_FUNC_VARIABLE);
cur = cur->next;
- }
+ }
/*
* Process all the rest of top-level elements.
*/
cur = start;
- while (cur != NULL) {
+ while (cur != NULL) {
/*
* Process element nodes.
*/
- if (cur->type == XML_ELEMENT_NODE) {
+ if (cur->type == XML_ELEMENT_NODE) {
if (cur->ns == NULL) {
xsltTransformError(NULL, style, cur,
"Unexpected top-level element in no namespace.\n");
@@ -5808,7 +5825,7 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
cur = cur->next;
continue;
}
- /*
+ /*
* TODO: Change the return type of the parsing functions
* to int.
*/
@@ -5826,8 +5843,8 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
/* NOP; done already */
} else if (IS_XSLT_NAME(cur, "param")) {
/* NOP; done already */
- } else if (IS_XSLT_NAME(cur, "include")) {
- if (cur->psvi != NULL)
+ } else if (IS_XSLT_NAME(cur, "include")) {
+ if (cur->psvi != NULL)
xsltParseXSLTStylesheetElemCore(cctxt, cur);
else {
xsltTransformError(NULL, style, cur,
@@ -5849,13 +5866,13 @@ xsltParseXSLTStylesheetElemCore(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
/* TODO: node-info needed for expressions ? */
xsltParseStylesheetKey(style, cur);
} else if (IS_XSLT_NAME(cur, "decimal-format")) {
- /* No node-info needed. */
+ /* No node-info needed. */
xsltParseStylesheetDecimalFormat(style, cur);
- } else if (IS_XSLT_NAME(cur, "attribute-set")) {
+ } else if (IS_XSLT_NAME(cur, "attribute-set")) {
xsltParseTopLevelXSLTElem(cctxt, cur,
- XSLT_FUNC_ATTRSET);
+ XSLT_FUNC_ATTRSET);
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
- /* NOP; done already */
+ /* NOP; done already */
} else {
if (cctxt->inode->forwardsCompat) {
/*
@@ -5929,7 +5946,7 @@ exit:
* @cctxt: the compiler context
* @node: the xsl:stylesheet/xsl:transform element-node
*
- * Parses the xsl:stylesheet and xsl:transform element.
+ * Parses the xsl:stylesheet and xsl:transform element.
*
* <xsl:stylesheet
* id = id
@@ -5940,7 +5957,7 @@ exit:
* </xsl:stylesheet>
*
* BIG TODO: The xsl:include stuff.
- *
+ *
* Called by xsltParseStylesheetTree()
*
* Returns 0 on success, a positive result on errors and
@@ -5951,9 +5968,9 @@ xsltParseXSLTStylesheetElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
{
xmlNodePtr cur, start;
- if ((cctxt == NULL) || (node == NULL))
+ if ((cctxt == NULL) || (node == NULL) || (node->type != XML_ELEMENT_NODE))
return(-1);
-
+
if (node->children == NULL)
goto exit;
@@ -5968,7 +5985,7 @@ xsltParseXSLTStylesheetElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
* XSLT 1.0: "The xsl:import element children must precede all
* other element children of an xsl:stylesheet element,
* including any xsl:include element children."
- */
+ */
while ((cur != NULL) &&
xsltParseFindTopLevelElem(cctxt, cur,
BAD_CAST "import", XSLT_NAMESPACE, 1, &cur) == 1)
@@ -6009,14 +6026,14 @@ xsltParseXSLTStylesheetElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
if (cctxt->isInclude) {
/*
* If this stylesheet is intended for inclusion, then
- * we will process only imports and includes.
+ * we will process only imports and includes.
*/
goto exit;
- }
+ }
/*
* Now parse the rest of the top-level elements.
*/
- xsltParseXSLTStylesheetElemCore(cctxt, node);
+ xsltParseXSLTStylesheetElemCore(cctxt, node);
exit:
return(0);
@@ -6039,7 +6056,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
int templates = 0;
#endif
- if (top == NULL)
+ if ((top == NULL) || (top->type != XML_ELEMENT_NODE))
return;
prop = xmlGetNsProp(top, (const xmlChar *)"version", NULL);
@@ -6052,8 +6069,10 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
(!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
xsltTransformError(NULL, style, top,
"xsl:version: only 1.0 features are supported\n");
- /* TODO set up compatibility when not XSLT 1.0 */
- if (style != NULL) style->warnings++;
+ if (style != NULL) {
+ style->forwards_compatible = 1;
+ style->warnings++;
+ }
}
xmlFree(prop);
}
@@ -6147,12 +6166,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
xsltNamespaceAlias(style, cur);
} else {
- /*
- * BUG TODO: The version of the *doc* is irrelevant for
- * the forwards-compatible mode.
- */
- if ((style != NULL) && (style->doc->version != NULL) &&
- (!strncmp((const char *) style->doc->version, "1.0", 3))) {
+ if ((style != NULL) && (style->forwards_compatible == 0)) {
xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: unknown %s element\n",
cur->name);
@@ -6193,7 +6207,7 @@ xsltParseSimplifiedStylesheetTree(xsltCompilerCtxtPtr cctxt,
xmlNodePtr node)
{
xsltTemplatePtr templ;
-
+
if ((cctxt == NULL) || (node == NULL))
return(-1);
@@ -6209,12 +6223,12 @@ xsltParseSimplifiedStylesheetTree(xsltCompilerCtxtPtr cctxt,
cctxt->style->errors++;
return(1);
}
-
+
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"xsltParseSimplifiedStylesheetTree: document is stylesheet\n");
-#endif
-
+#endif
+
/*
* Create and link the template
*/
@@ -6270,12 +6284,12 @@ xsltRestoreDocumentNamespaces(xsltNsMapPtr ns, xmlDocPtr doc)
/*
* Revert the changes we have applied to the namespace-URIs of
* ns-decls.
- */
+ */
while (ns != NULL) {
if ((ns->doc == doc) && (ns->ns != NULL)) {
ns->ns->href = ns->origNsName;
ns->origNsName = NULL;
- ns->ns = NULL;
+ ns->ns = NULL;
}
ns = ns->next;
}
@@ -6318,9 +6332,9 @@ xsltParseStylesheetProcess(xsltStylesheetPtr style, xmlDocPtr doc)
}
oldIsSimplifiedStylesheet = cctxt->simplified;
- if ((IS_XSLT_ELEM(cur)) &&
+ if ((IS_XSLT_ELEM(cur)) &&
((IS_XSLT_NAME(cur, "stylesheet")) ||
- (IS_XSLT_NAME(cur, "transform")))) {
+ (IS_XSLT_NAME(cur, "transform")))) {
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"xsltParseStylesheetProcess : found stylesheet\n");
@@ -6347,7 +6361,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr style, xmlDocPtr doc)
} else {
if (xsltParseSimplifiedStylesheetTree(cctxt, doc, cur) != 0)
return(NULL);
- }
+ }
cctxt->simplified = oldIsSimplifiedStylesheet;
@@ -6379,7 +6393,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
return(NULL);
if (ret == NULL)
return(ret);
-
+
/*
* First steps, remove blank nodes,
* locate the xsl:stylesheet element and the
@@ -6392,9 +6406,9 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
return(NULL);
}
- if ((IS_XSLT_ELEM(cur)) &&
+ if ((IS_XSLT_ELEM(cur)) &&
((IS_XSLT_NAME(cur, "stylesheet")) ||
- (IS_XSLT_NAME(cur, "transform")))) {
+ (IS_XSLT_NAME(cur, "transform")))) {
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"xsltParseStylesheetProcess : found stylesheet\n");
@@ -6430,7 +6444,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
xsltGenericDebug(xsltGenericDebugContext,
"xsltParseStylesheetProcess : document is stylesheet\n");
#endif
-
+
if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) {
xsltTransformError(NULL, ret, cur,
"xsl:version: only 1.0 features are supported\n");
@@ -6457,7 +6471,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
template->elem = (xmlNodePtr) doc;
template->content = doc->children;
xsltAddTemplate(ret, template, NULL, NULL);
- ret->literal_result = 1;
+ ret->literal_result = 1;
}
return(ret);
@@ -6503,8 +6517,8 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
doc->URL);
#endif
xmlDictReference(retStyle->dict);
- }
-
+ }
+
/*
* TODO: Eliminate xsltGatherNamespaces(); we must not restrict
* the stylesheet to containt distinct namespace prefixes.
@@ -6515,7 +6529,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
{
xsltCompilerCtxtPtr cctxt;
xsltStylesheetPtr oldCurSheet;
-
+
if (parentStyle == NULL) {
xsltPrincipalStylesheetDataPtr principalData;
/*
@@ -6543,7 +6557,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
if (cctxt == NULL) {
xsltFreeStylesheet(retStyle);
return(NULL);
- }
+ }
retStyle->compCtxt = (void *) cctxt;
cctxt->style = retStyle;
cctxt->dict = retStyle->dict;
@@ -6567,10 +6581,10 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
*/
oldCurSheet = cctxt->style;
cctxt->style = retStyle;
-
+
retStyle->doc = doc;
xsltParseStylesheetProcess(retStyle, doc);
-
+
cctxt->style = oldCurSheet;
if (parentStyle == NULL) {
/*
@@ -6594,7 +6608,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
/*
* Restore all changes made to namespace URIs of ns-decls.
*/
- if (cctxt->psData->nsMap)
+ if (cctxt->psData->nsMap)
xsltRestoreDocumentNamespaces(cctxt->psData->nsMap, doc);
#endif
/*
@@ -6607,7 +6621,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
*/
if (parentStyle == NULL) {
xsltCleanupStylesheetTree(doc, xmlDocGetRootElement(doc));
- if (retStyle->compCtxt != NULL) {
+ if (retStyle->compCtxt != NULL) {
xsltCompilationCtxtFree(retStyle->compCtxt);
retStyle->compCtxt = NULL;
}
@@ -6618,7 +6632,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
}
}
}
-
+
#else /* XSLT_REFACTORED */
/*
* Old behaviour.
@@ -6640,7 +6654,7 @@ xsltParseStylesheetImportedDoc(xmlDocPtr doc,
}
}
#endif /* else of XSLT_REFACTORED */
-
+
return(retStyle);
}
@@ -6696,7 +6710,7 @@ xsltParseStylesheetFile(const xmlChar* filename) {
xsltSecurityPrefsPtr sec;
xsltStylesheetPtr ret;
xmlDocPtr doc;
-
+
xsltInitGlobals();
if (filename == NULL)
@@ -6795,7 +6809,7 @@ xsltParseStylesheetPI(const xmlChar *value) {
continue;
val = xmlStrndup(start, cur - start);
NEXT;
- if (val == NULL)
+ if (val == NULL)
return(NULL);
if ((xmlStrcasecmp(val, BAD_CAST "text/xml")) &&
(xmlStrcasecmp(val, BAD_CAST "text/xsl"))) {
@@ -6827,7 +6841,7 @@ xsltParseStylesheetPI(const xmlChar *value) {
while ((CUR != 0) && (!IS_BLANK(CUR)))
NEXT;
}
-
+
}
if (!isXml) {
@@ -6843,7 +6857,7 @@ xsltParseStylesheetPI(const xmlChar *value) {
* @doc: a document to process
*
* This function tries to locate the stylesheet PI in the given document
- * If found, and if contained within the document, it will extract
+ * If found, and if contained within the document, it will extract
* that subtree to build the stylesheet to process @doc (doc itself will
* be modified). If found but referencing an external document it will
* attempt to load it and generate a stylesheet from it. In both cases,
« no previous file with comments | « third_party/libxslt/libxslt/xslt.h ('k') | third_party/libxslt/libxslt/xsltInternals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698