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

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

Issue 661058: libxslt update (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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/win32config.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
===================================================================
--- third_party/libxslt/libxslt/xslt.c (revision 39981)
+++ third_party/libxslt/libxslt/xslt.c (working copy)
@@ -56,6 +56,10 @@
const xmlChar *xsltConstNamespaceNameXSLT = (const xmlChar *) XSLT_NAMESPACE;
+#define XSLT_ELEMENT_CATEGORY_XSLT 0
+#define XSLT_ELEMENT_CATEGORY_EXTENSION 1
+#define XSLT_ELEMENT_CATEGORY_LRE 2
+
/*
* xsltLiteralResultMarker:
* Marker for Literal result elements, in order to avoid multiple attempts
@@ -83,6 +87,9 @@
#endif
+#ifdef XSLT_LOCALE_WINAPI
+extern xmlRMutexPtr xsltLocaleMutex;
+#endif
/*
* Harmless but avoiding a problem when compiling against a
* libxml <= 2.3.11 without LIBXML_DEBUG_ENABLED
@@ -141,11 +148,14 @@
*
* Push an excluded namespace name on the stack
*
- * Returns the new index in the stack or 0 in case of error
+ * Returns the new index in the stack or -1 if already present or
+ * in case of error
*/
static int
exclPrefixPush(xsltStylesheetPtr style, xmlChar * value)
{
+ int i;
+
if (style->exclPrefixMax == 0) {
style->exclPrefixMax = 4;
style->exclPrefixTab =
@@ -153,9 +163,14 @@
sizeof(style->exclPrefixTab[0]));
if (style->exclPrefixTab == NULL) {
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
- return (0);
+ return (-1);
}
}
+ /* do not push duplicates */
+ for (i = 0;i < style->exclPrefixNr;i++) {
+ if (xmlStrEqual(style->exclPrefixTab[i], value))
+ return(-1);
+ }
if (style->exclPrefixNr >= style->exclPrefixMax) {
style->exclPrefixMax *= 2;
style->exclPrefixTab =
@@ -164,7 +179,7 @@
sizeof(style->exclPrefixTab[0]));
if (style->exclPrefixTab == NULL) {
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
- return (0);
+ return (-1);
}
}
style->exclPrefixTab[style->exclPrefixNr] = value;
@@ -214,6 +229,9 @@
xsltInit (void) {
if (initialized == 0) {
initialized = 1;
+#ifdef XSLT_LOCALE_WINAPI
+ xsltLocaleMutex = xmlNewRMutex();
+#endif
xsltRegisterAllExtras();
}
}
@@ -1704,12 +1722,13 @@
prefix);
if (style != NULL) style->warnings++;
} else {
+ if (exclPrefixPush(style, (xmlChar *) ns->href) >= 0) {
#ifdef WITH_XSLT_DEBUG_PARSING
- xsltGenericDebug(xsltGenericDebugContext,
- "exclude result prefix %s\n", prefix);
+ xsltGenericDebug(xsltGenericDebugContext,
+ "exclude result prefix %s\n", prefix);
#endif
- exclPrefixPush(style, (xmlChar *) ns->href);
- nb++;
+ nb++;
+ }
}
xmlFree(prefix);
}
@@ -4921,13 +4940,14 @@
* okay this is an extension element compile it too
*/
xsltStylePreCompute(style, cur);
- } else {
+ }
+ else if (cur->type == XML_ELEMENT_NODE)
+ {
/*
* This is an element which will be output as part of the
* template exectution, precompile AVT if found.
*/
- if ((cur->ns == NULL) && (style->defaultAlias != NULL) &&
- (cur->type == XML_ELEMENT_NODE)) {
+ if ((cur->ns == NULL) && (style->defaultAlias != NULL)) {
cur->ns = xmlSearchNsByHref(cur->doc, cur,
style->defaultAlias);
}
@@ -6233,6 +6253,15 @@
}
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
+/**
+ * xsltRestoreDocumentNamespaces:
+ * @ns: map of namespaces
+ * @doc: the document
+ *
+ * Restore the namespaces for the document
+ *
+ * Returns 0 in case of success, -1 in case of failure
+ */
int
xsltRestoreDocumentNamespaces(xsltNsMapPtr ns, xmlDocPtr doc)
{
@@ -6274,6 +6303,7 @@
xmlNodePtr cur;
int oldIsSimplifiedStylesheet;
+ xsltInitGlobals();
if ((style == NULL) || (doc == NULL))
return(NULL);
@@ -6326,10 +6356,25 @@
#else /* XSLT_REFACTORED */
+/**
+ * xsltParseStylesheetProcess:
+ * @ret: the XSLT stylesheet (the current stylesheet-level)
+ * @doc: and xmlDoc parsed XML
+ *
+ * Parses an XSLT stylesheet, adding the associated structures.
+ * Called by:
+ * xsltParseStylesheetImportedDoc() (xslt.c)
+ * xsltParseStylesheetInclude() (imports.c)
+ *
+ * Returns the value of the @style parameter if everything
+ * went right, NULL if something went amiss.
+ */
xsltStylesheetPtr
xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
xmlNodePtr cur;
+ xsltInitGlobals();
+
if (doc == NULL)
return(NULL);
if (ret == NULL)
@@ -6616,6 +6661,8 @@
xsltParseStylesheetDoc(xmlDocPtr doc) {
xsltStylesheetPtr ret;
+ xsltInitGlobals();
+
ret = xsltParseStylesheetImportedDoc(doc, NULL);
if (ret == NULL)
return(NULL);
@@ -6650,6 +6697,7 @@
xsltStylesheetPtr ret;
xmlDocPtr doc;
+ xsltInitGlobals();
if (filename == NULL)
return(NULL);
@@ -6811,6 +6859,8 @@
xmlChar *href = NULL;
xmlURIPtr URI;
+ xsltInitGlobals();
+
if (doc == NULL)
return(NULL);
@@ -6862,8 +6912,14 @@
"xml-stylesheet : no ID %s found\n", URI->fragment);
} else {
xmlDocPtr fake;
- xmlNodePtr subtree;
+ xmlNodePtr subtree, newtree;
+ xmlNsPtr ns;
+#ifdef WITH_XSLT_DEBUG
+ xsltGenericDebug(xsltGenericDebugContext,
+ "creating new document from %s for embedded stylesheet\n",
+ doc->URL);
+#endif
/*
* move the subtree in a new document passed to
* the stylesheet analyzer
@@ -6871,20 +6927,38 @@
subtree = ID->parent;
fake = xmlNewDoc(NULL);
if (fake != NULL) {
- /*
- * the dictionary should be shared since nodes are
- * moved over.
- */
+ /*
+ * Should the dictionary still be shared even though
+ * the nodes are being copied rather than moved?
+ */
fake->dict = doc->dict;
xmlDictReference(doc->dict);
#ifdef WITH_XSLT_DEBUG
xsltGenericDebug(xsltGenericDebugContext,
- "reusing dictionary from %s for stylesheet\n",
- doc->URL);
+ "reusing dictionary from %s for embedded stylesheet\n",
+ doc->URL);
#endif
- xmlUnlinkNode(subtree);
- xmlAddChild((xmlNodePtr) fake, subtree);
+ newtree = xmlDocCopyNode(subtree, fake, 1);
+
+ fake->URL = xmlNodeGetBase(doc, subtree->parent);
+#ifdef WITH_XSLT_DEBUG
+ xsltGenericDebug(xsltGenericDebugContext,
+ "set base URI for embedded stylesheet as %s\n",
+ fake->URL);
+#endif
+
+ /*
+ * Add all namespaces in scope of embedded stylesheet to
+ * root element of newly created stylesheet document
+ */
+ while ((subtree = subtree->parent) != (xmlNodePtr)doc) {
+ for (ns = subtree->ns; ns; ns = ns->next) {
+ xmlNewNs(newtree, ns->href, ns->prefix);
+ }
+ }
+
+ xmlAddChild((xmlNodePtr)fake, newtree);
ret = xsltParseStylesheetDoc(fake);
if (ret == NULL)
xmlFreeDoc(fake);
« no previous file with comments | « third_party/libxslt/libxslt/win32config.h ('k') | third_party/libxslt/libxslt/xsltInternals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698