1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-29 15:41:13 +03:00

fixed a bug w.r.t. namespace context when doing the evaluation of

* libxslt/templates.c: fixed a bug w.r.t. namespace context when
  doing the evaluation of attribute value templates
* libxslt.spec.in python/Makefile.am: fixed some troubles
  with "make rpm"
Daniel
This commit is contained in:
Daniel Veillard
2002-08-21 19:29:32 +00:00
parent 4c95dfde98
commit 1acafc0957
4 changed files with 80 additions and 18 deletions

View File

@ -1,3 +1,10 @@
Wed Aug 21 21:27:29 CEST 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/templates.c: fixed a bug w.r.t. namespace context when
doing the evaluation of attribute value templates
* libxslt.spec.in python/Makefile.am: fixed some troubles
with "make rpm"
Wed Aug 21 18:59:28 CEST 2002 Daniel Veillard <daniel@veillard.com> Wed Aug 21 18:59:28 CEST 2002 Daniel Veillard <daniel@veillard.com>
* python/libxslt.c: fixed the parameter order when calling * python/libxslt.c: fixed the parameter order when calling

View File

@ -79,7 +79,8 @@ rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_mandir}/man1 install -d $RPM_BUILD_ROOT%{_mandir}/man1
install -d $RPM_BUILD_ROOT%{_mandir}/man4 install -d $RPM_BUILD_ROOT%{_mandir}/man4
make prefix=$RPM_BUILD_ROOT%{prefix} mandir=$RPM_BUILD_ROOT%{_mandir} install make prefix=$RPM_BUILD_ROOT%{prefix} mandir=$RPM_BUILD_ROOT%{_mandir} \
install
# #
# this is a bit ugly but tries to generate the bindings for all versions # this is a bit ugly but tries to generate the bindings for all versions
@ -96,7 +97,8 @@ do
make PYTHON="%{prefix}/bin/python$py_version" \ make PYTHON="%{prefix}/bin/python$py_version" \
PYTHON_VERSION="$py_version" \ PYTHON_VERSION="$py_version" \
prefix=$RPM_BUILD_ROOT%{prefix} \ prefix=$RPM_BUILD_ROOT%{prefix} \
mandir=$RPM_BUILD_ROOT%{_mandir} install) mandir=$RPM_BUILD_ROOT%{_mandir} \
install)
fi fi
done done
%clean %clean

View File

@ -100,17 +100,21 @@ xsltEvalXPathPredicate(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
} }
/** /**
* xsltEvalXPathString: * xsltEvalXPathStringNs:
* @ctxt: the XSLT transformation context * @ctxt: the XSLT transformation context
* @comp: the compiled XPath expression * @comp: the compiled XPath expression
* @nsNr: the number of namespaces in the list
* @nsList: the list of in-scope namespaces to use
* *
* Process the expression using XPath and get a string * Process the expression using XPath, allowing to pass a namespace mapping
* context and get a string
* *
* Returns the computed string value or NULL, must be deallocated by the * Returns the computed string value or NULL, must be deallocated by the
* caller. * caller.
*/ */
xmlChar * xmlChar *
xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) { xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
int nsNr, xmlNsPtr *nsList) {
xmlChar *ret = NULL; xmlChar *ret = NULL;
xmlXPathObjectPtr res; xmlXPathObjectPtr res;
xmlNodePtr oldInst; xmlNodePtr oldInst;
@ -128,8 +132,8 @@ xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
ctxt->xpathCtxt->node = ctxt->node; ctxt->xpathCtxt->node = ctxt->node;
/* TODO: do we need to propagate the namespaces here ? */ /* TODO: do we need to propagate the namespaces here ? */
ctxt->xpathCtxt->namespaces = NULL; ctxt->xpathCtxt->namespaces = nsList;
ctxt->xpathCtxt->nsNr = 0; ctxt->xpathCtxt->nsNr = nsNr;
res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt); res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
if (res != NULL) { if (res != NULL) {
if (res->type != XPATH_STRING) if (res->type != XPATH_STRING)
@ -159,6 +163,21 @@ xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
return(ret); return(ret);
} }
/**
* xsltEvalXPathString:
* @ctxt: the XSLT transformation context
* @comp: the compiled XPath expression
*
* Process the expression using XPath and get a string
*
* Returns the computed string value or NULL, must be deallocated by the
* caller.
*/
xmlChar *
xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
return(xsltEvalXPathStringNs(ctxt, comp, 0, NULL));
}
/** /**
* xsltEvalTemplateString: * xsltEvalTemplateString:
* @ctxt: the XSLT transformation context * @ctxt: the XSLT transformation context
@ -202,20 +221,26 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
/** /**
* xsltAttrTemplateValueProcess: * xsltAttrTemplateValueProcessNode:
* @ctxt: the XSLT transformation context * @ctxt: the XSLT transformation context
* @str: the attribute template node value * @str: the attribute template node value
* @node: the node hosting the attribute
* @nsList: the list of in-scope namespaces to use
* *
* Process the given node and return the new string value. * Process the given string, allowing to pass a namespace mapping
* context and return the new string value.
* *
* Returns the computed string value or NULL, must be deallocated by the * Returns the computed string value or NULL, must be deallocated by the
* caller. * caller.
*/ */
xmlChar * xmlChar *
xsltAttrTemplateValueProcess(xsltTransformContextPtr ctxt, const xmlChar *str) { xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
const xmlChar *str, xmlNodePtr node) {
xmlChar *ret = NULL; xmlChar *ret = NULL;
const xmlChar *cur; const xmlChar *cur;
xmlChar *expr, *val; xmlChar *expr, *val;
xmlNsPtr *nsList = NULL;
int nsNr = 0;
if (str == NULL) return(NULL); if (str == NULL) return(NULL);
if (*str == 0) if (*str == 0)
@ -244,8 +269,18 @@ xsltAttrTemplateValueProcess(xsltTransformContextPtr ctxt, const xmlChar *str) {
/* /*
* TODO: keep precompiled form around * TODO: keep precompiled form around
*/ */
if (nsList == NULL) {
int i = 0;
nsList = xmlGetNsList(node->doc, node);
if (nsList != NULL) {
while (nsList[i] != NULL)
i++;
nsNr = i;
}
}
comp = xmlXPathCompile(expr); comp = xmlXPathCompile(expr);
val = xsltEvalXPathString(ctxt, comp); val = xsltEvalXPathStringNs(ctxt, comp, nsNr, nsList);
xmlXPathFreeCompExpr(comp); xmlXPathFreeCompExpr(comp);
xmlFree(expr); xmlFree(expr);
if (val != NULL) { if (val != NULL) {
@ -262,9 +297,27 @@ xsltAttrTemplateValueProcess(xsltTransformContextPtr ctxt, const xmlChar *str) {
ret = xmlStrncat(ret, str, cur - str); ret = xmlStrncat(ret, str, cur - str);
} }
if (nsList != NULL)
xmlFree(nsList);
return(ret); return(ret);
} }
/**
* xsltAttrTemplateValueProcess:
* @ctxt: the XSLT transformation context
* @str: the attribute template node value
*
* Process the given node and return the new string value.
*
* Returns the computed string value or NULL, must be deallocated by the
* caller.
*/
xmlChar *
xsltAttrTemplateValueProcess(xsltTransformContextPtr ctxt, const xmlChar *str) {
return(xsltAttrTemplateValueProcessNode(ctxt, str, NULL));
}
/** /**
* xsltEvalAttrValueTemplate: * xsltEvalAttrValueTemplate:
* @ctxt: the XSLT transformation context * @ctxt: the XSLT transformation context
@ -298,7 +351,7 @@ xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
* attribute content and the XPath precompiled expressions around * attribute content and the XPath precompiled expressions around
*/ */
ret = xsltAttrTemplateValueProcess(ctxt, expr); ret = xsltAttrTemplateValueProcessNode(ctxt, expr, node);
#ifdef WITH_XSLT_DEBUG_TEMPLATES #ifdef WITH_XSLT_DEBUG_TEMPLATES
xsltGenericDebug(xsltGenericDebugContext, xsltGenericDebug(xsltGenericDebugContext,
"xsltEvalAttrValueTemplate: %s returns %s\n", expr, ret); "xsltEvalAttrValueTemplate: %s returns %s\n", expr, ret);
@ -392,7 +445,7 @@ xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
/* TODO: optimize if no template value was detected */ /* TODO: optimize if no template value was detected */
if (in != NULL) { if (in != NULL) {
out = xsltAttrTemplateValueProcess(ctxt, in); out = xsltAttrTemplateValueProcessNode(ctxt, in, cur->parent);
ret = xmlSetNsProp(target, ns, cur->name, out); ret = xmlSetNsProp(target, ns, cur->name, out);
if (out != NULL) if (out != NULL)
xmlFree(out); xmlFree(out);

View File

@ -42,11 +42,11 @@ libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
cat $(srcdir)/libxsl.py libxsltclass.py > libxslt.py cat $(srcdir)/libxsl.py libxsltclass.py > libxslt.py
install-data-local: install-data-local:
$(mkinstalldirs) $(DESTDIR)$(PYTHON_SITE_PACKAGES) $(mkinstalldirs) $(libdir)/python${PYTHON_VERSION}/site-packages
-@INSTALL@ -m 0644 libxslt.py $(DESTDIR)$(PYTHON_SITE_PACKAGES) @INSTALL@ -m 0644 libxslt.py $(libdir)/python${PYTHON_VERSION}/site-packages
$(mkinstalldirs) $(DESTDIR)$(DOCS_DIR) $(mkinstalldirs) $(DOCS_DIR)
-@(for doc in $(DOCS) ; \ @(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done) do @INSTALL@ -m 0644 $$doc $(DOCS_DIR) ; done)
GENERATE = generator.py GENERATE = generator.py
API_DESC = $(top_srcdir)/doc/libxslt-api.xml $(srcdir)/libxslt-python-api.xml API_DESC = $(top_srcdir)/doc/libxslt-api.xml $(srcdir)/libxslt-python-api.xml