Re: [xslt] xsltproc not copying pi's



On Thu, May 24, 2001 at 05:02:25PM -0500, Brent M Hendricks wrote:
> I can't get xsltproc to copy processing instructions.  It seems to
> match the template OK, but doing an <xsl:copy/> doesn't copy the pi to
> the result.

  humm, right !

I fixed it it seems (xsltCopy was forgetting it), and also fixed a similar
problem affecting comments:

orchis:~/XSLT/tests/general -> xsltproc bug-31-.xsl ../docs/bug-31-.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="style.css"?>


orchis:~/XSLT/tests/general -> 

  thanks a lots of the report and test, patch enclosed.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
*** libxslt/transform.c	2001/05/17 11:57:08	1.99
--- libxslt/transform.c	2001/05/26 15:05:53
***************
*** 730,735 ****
--- 730,744 ----
  		if (template) {
  		    xmlNodePtr oldNode;
  
+ #ifdef WITH_XSLT_DEBUG_PROCESS
+ 		    if (cur->type == XML_PI_NODE)
+ 			xsltGenericDebug(xsltGenericDebugContext,
+ 			 "xsltProcessOneNode: template found for PI %s\n",
+ 			                 cur->name);
+ 		    else if (cur->type == XML_COMMENT_NODE)
+ 			xsltGenericDebug(xsltGenericDebugContext,
+ 			 "xsltProcessOneNode: template found for comment\n");
+ #endif
  		    oldNode = ctxt->node;
  		    ctxt->node = cur;
  		    ctxt->xpathCtxt->contextSize = nbchild;
***************
*** 1301,1306 ****
--- 1310,1331 ----
  		}
  		break;
  	    }
+ 	    case XML_PI_NODE:
+ #ifdef WITH_XSLT_DEBUG_PROCESS
+ 		xsltGenericDebug(xsltGenericDebugContext,
+ 				 "xsl:copy: PI %s\n", node->name);
+ #endif
+ 		copy = xmlNewPI(node->name, node->content);
+ 		xmlAddChild(ctxt->insert, copy);
+ 		break;
+ 	    case XML_COMMENT_NODE:
+ #ifdef WITH_XSLT_DEBUG_PROCESS
+ 		xsltGenericDebug(xsltGenericDebugContext,
+ 				 "xsl:copy: comment\n");
+ #endif
+ 		copy = xmlNewComment(node->content);
+ 		xmlAddChild(ctxt->insert, copy);
+ 		break;
  	    default:
  		break;
  
***************
*** 2076,2081 ****
--- 2101,2108 ----
  		case XML_HTML_DOCUMENT_NODE:
  		case XML_ELEMENT_NODE:
  		case XML_CDATA_SECTION_NODE:
+ 		case XML_PI_NODE:
+ 		case XML_COMMENT_NODE:
  		    xmlXPathNodeSetAdd(list, cur);
  		    break;
  		default:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]