mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2026-01-07 21:58:22 +03:00
- libxslt/namespaces.[ch]: added a single namespace def copy
operation xsltCopyNamespace(). cleaned up xsltCopyNamespaceList() - libxslt/transform.c: cleaned up xsltCopyNode to cope with any kind of input nodes. - libxslt/variables.c: checked and closed the last TODO about namespace propagation - tests/docs/Makefile.am tests/general/Makefile.am tests/general/bug-38-* tests/docs/bug-38-*: added a specific regression test for #56115 Daniel
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
||||
Sat Jun 16 23:26:46 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* libxslt/namespaces.[ch]: added a single namespace def copy
|
||||
operation xsltCopyNamespace(). cleaned up xsltCopyNamespaceList()
|
||||
* libxslt/transform.c: cleaned up xsltCopyNode to cope with
|
||||
any kind of input nodes.
|
||||
* libxslt/variables.c: checked and closed the last TODO about
|
||||
namespace propagation
|
||||
* tests/docs/Makefile.am tests/general/Makefile.am
|
||||
tests/general/bug-38-* tests/docs/bug-38-*: added a specific
|
||||
regression test for #56115
|
||||
|
||||
Sat Jun 16 09:27:27 MDT 2001 John Fleck <jfleck@inkstain.net>
|
||||
|
||||
* updating tutorial: adding discussion of freeing memory, image
|
||||
|
||||
@@ -235,6 +235,17 @@ xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
xmlNsPtr p = NULL,q;
|
||||
const xmlChar *URI;
|
||||
|
||||
if (cur == NULL)
|
||||
return(NULL);
|
||||
if (cur->type != XML_NAMESPACE_DECL)
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* One can add namespaces only on element nodes
|
||||
*/
|
||||
if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
|
||||
node = NULL;
|
||||
|
||||
while (cur != NULL) {
|
||||
if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {
|
||||
/* TODO apply cascading */
|
||||
@@ -257,6 +268,47 @@ xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltCopyNamespace:
|
||||
* @ctxt: a transformation context
|
||||
* @node: the target node
|
||||
* @cur: the namespace node
|
||||
*
|
||||
* Do a copy of an namespace node. If @node is non-NULL the
|
||||
* new namespaces are added automatically. This handles namespaces
|
||||
* aliases
|
||||
*
|
||||
* Returns: a new xmlNsPtr, or NULL in case of error.
|
||||
*/
|
||||
xmlNsPtr
|
||||
xsltCopyNamespace(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
xmlNsPtr cur) {
|
||||
xmlNsPtr ret = NULL;
|
||||
const xmlChar *URI;
|
||||
|
||||
if (cur == NULL)
|
||||
return(NULL);
|
||||
if (cur->type != XML_NAMESPACE_DECL)
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* One can add namespaces only on element nodes
|
||||
*/
|
||||
if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
|
||||
node = NULL;
|
||||
|
||||
if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {
|
||||
URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,
|
||||
cur->href);
|
||||
if (URI != NULL) {
|
||||
ret = xmlNewNs(node, URI, cur->prefix);
|
||||
} else {
|
||||
ret = xmlNewNs(node, cur->href, cur->prefix);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xsltFreeNamespaceAliasHashes:
|
||||
|
||||
@@ -26,6 +26,9 @@ xmlNsPtr xsltGetSpecialNamespace (xsltTransformContextPtr ctxt,
|
||||
const xmlChar *URI,
|
||||
const xmlChar *prefix,
|
||||
xmlNodePtr out);
|
||||
xmlNsPtr xsltCopyNamespace (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
xmlNsPtr cur);
|
||||
xmlNsPtr xsltCopyNamespaceList (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
xmlNsPtr cur);
|
||||
|
||||
@@ -411,6 +411,40 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
xmlNodePtr insert) {
|
||||
xmlNodePtr copy;
|
||||
|
||||
if (node == NULL)
|
||||
return(NULL);
|
||||
switch (node->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_ENTITY_REF_NODE:
|
||||
case XML_ENTITY_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
return((xmlNodePtr)
|
||||
xsltCopyProp(ctxt, insert, (xmlAttrPtr) node));
|
||||
case XML_NAMESPACE_DECL:
|
||||
return((xmlNodePtr)
|
||||
xsltCopyNamespaceList(ctxt, insert, (xmlNsPtr) node));
|
||||
|
||||
case XML_DOCUMENT_TYPE_NODE:
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
case XML_NOTATION_NODE:
|
||||
case XML_DTD_NODE:
|
||||
case XML_ELEMENT_DECL:
|
||||
case XML_ATTRIBUTE_DECL:
|
||||
case XML_ENTITY_DECL:
|
||||
case XML_XINCLUDE_START:
|
||||
case XML_XINCLUDE_END:
|
||||
return(NULL);
|
||||
}
|
||||
copy = xmlCopyNode(node, 0);
|
||||
copy->doc = ctxt->output;
|
||||
if (copy != NULL) {
|
||||
|
||||
@@ -696,7 +696,11 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
|
||||
oldContextSize = ctxt->xpathCtxt->contextSize;
|
||||
ctxt->xpathCtxt->node = (xmlNodePtr) ctxt->node;
|
||||
/* TODO: do we need to propagate the namespaces here ? */
|
||||
|
||||
/*
|
||||
* There is really no in scope namespace for parameters on the
|
||||
* command line.
|
||||
*/
|
||||
ctxt->xpathCtxt->namespaces = NULL;
|
||||
ctxt->xpathCtxt->nsNr = 0;
|
||||
result = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
|
||||
|
||||
@@ -41,6 +41,7 @@ EXTRA_DIST = \
|
||||
bug-35-.xml \
|
||||
bug-36-.xml \
|
||||
bug-37-.xml \
|
||||
bug-38-.xml \
|
||||
character.xml \
|
||||
array.xml \
|
||||
items.xml
|
||||
|
||||
17
tests/docs/bug-38-.xml
Normal file
17
tests/docs/bug-38-.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:template name="ns">
|
||||
<ns xmlns:ns="http://whatever"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="/*">
|
||||
<elem>
|
||||
<xsl:copy-of select="document('')/*/
|
||||
xsl:template[@name='ns']/
|
||||
ns/namespace::ns"/>
|
||||
</elem>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -43,6 +43,7 @@ EXTRA_DIST = \
|
||||
bug-37-.out bug-37-.xsl \
|
||||
bug-37-inc.out bug-37-inc.xsl \
|
||||
array.out array.xsl \
|
||||
bug-38-.out bug-38-.xsl \
|
||||
character.out character.xsl \
|
||||
character2.out character2.xsl \
|
||||
itemschoose.out itemschoose.xsl \
|
||||
|
||||
2
tests/general/bug-38-.out
Normal file
2
tests/general/bug-38-.out
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<elem xmlns:ns="http://whatever"/>
|
||||
17
tests/general/bug-38-.xsl
Normal file
17
tests/general/bug-38-.xsl
Normal file
@@ -0,0 +1,17 @@
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:template name="ns">
|
||||
<ns xmlns:ns="http://whatever"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="/*">
|
||||
<elem>
|
||||
<xsl:copy-of select="document('')/*/
|
||||
xsl:template[@name='ns']/
|
||||
ns/namespace::ns"/>
|
||||
</elem>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user