Re: [xslt] cdata-section-elements not supported ?



Le Thu, Jun 28, 2001 at 08:33:19AM -0400, Daniel Veillard écrivait:

[ CDATA block when listed in cdata-section-elements ]
>   fortunately this should not be too hard to implement, there is
> already most of the infrastructure in place.

Alright, here's the patch. :-) I hope I have it right. I just create
CDataBlock node instead of Text nodes when the parent element is a node
listed in cdata-section-elements.

Cheers,
-- 
Raphaël Hertzog -+- http://strasbourg.linuxfr.org/~raphael/
Le bouche à oreille du Net : http://www.beetell.com
Naviguez sans se fatiguer à chercher : http://www.deenoo.com
Formation Linux et logiciel libre : http://www.logidee.com
Index: transform.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/transform.c,v
retrieving revision 1.114
diff -u -r1.114 transform.c
--- transform.c	2001/06/28 21:03:31	1.114
+++ transform.c	2001/06/29 14:45:21
@@ -510,6 +510,7 @@
     int nbchild = 0, oldSize;
     int childno = 0, oldPos;
     xsltTemplatePtr template;
+    const xmlChar* cdataKey = NULL;
 
     CHECK_STOPPED;
     /*
@@ -526,7 +527,18 @@
 	     "xsltDefaultProcessOneNode: copy CDATA %s\n",
 		node->content);
 #endif
-	    copy = xmlNewDocText(ctxt->output, node->content);
+	    if ((ctxt->style->stripSpaces != NULL)) {
+		cdataKey = (const xmlChar *) 
+			    xmlHashLookup(ctxt->style->stripSpaces,
+					  node->parent->name);
+	    }
+	    if ((cdataKey != NULL) && 
+		(xmlStrEqual(cdataKey, (xmlChar *) "cdata"))) {
+		copy = xmlNewCDataBlock(ctxt->output, node->content,
+					xmlStrlen(node->content));
+	    } else {
+		copy = xmlNewDocText(ctxt->output, node->content);
+	    }
 	    if (copy != NULL) {
 		xmlAddChild(ctxt->insert, copy);
 	    } else {
@@ -544,7 +556,18 @@
 		 "xsltDefaultProcessOneNode: copy text %s\n",
 			node->content);
 #endif
-	    copy = xmlCopyNode(node, 0);
+	    if ((ctxt->style->stripSpaces != NULL)) {
+		cdataKey = (const xmlChar *) 
+			    xmlHashLookup(ctxt->style->stripSpaces,
+					  node->parent->name);
+	    }
+	    if ((cdataKey != NULL) && 
+		(xmlStrEqual(cdataKey, (xmlChar *) "cdata"))) {
+		copy = xmlNewCDataBlock(ctxt->output, node->content,
+					xmlStrlen(node->content));
+	    } else {
+		copy = xmlCopyNode(node, 0);
+	    }
 	    if (copy != NULL) {
 		xmlAddChild(ctxt->insert, copy);
 	    } else {


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