+Wed Mar 7 18:01:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * imports.c transform.c xslt.c xsltInternals.h: fixed a
+ strip-spaces problem
+ * tests/docs/*.xml tests/general/*.[xsl,out]: added reported
+ bugs to testsuite
+
Wed Mar 7 13:34:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/transform.[ch]: finished integrating the current
if (xmlStrEqual(val, (xmlChar *) "preserve"))
return(0);
}
- val = (const xmlChar *)
- xmlHashLookup(ctxt->style->stripSpaces,
- (const xmlChar *)"*");
- if ((val != NULL) &&
- (xmlStrEqual(val, (xmlChar *) "strip")))
+ if (ctxt->style->stripAll == 1)
return(1);
- if (xmlStrEqual(val, (xmlChar *) "preserve"))
+ if (ctxt->style->stripAll == -1)
return(0);
style = xsltNextImport(style);
xsltTemplatePtr template;
xmlNodePtr oldNode;
+ /*
+ * Cleanup children empty nodes if asked for
+ */
+ if ((node->children != NULL) &&
+ (xsltFindElemSpaceHandling(ctxt, node))) {
+ xmlNodePtr delete = NULL, cur = node->children;
+
+ while (cur != NULL) {
+ if (IS_BLANK_NODE(cur))
+ delete = cur;
+
+ cur = cur->next;
+ if (delete != NULL) {
+#ifdef DEBUG_PROCESS
+ xsltGenericDebug(xsltGenericDebugContext,
+ "xsltDefaultProcessOneNode: removing ignorable blank node\n");
+#endif
+ xmlUnlinkNode(delete);
+ xmlFreeNode(delete);
+ delete = NULL;
+ }
+ }
+ }
+
template = xsltGetTemplate(ctxt, node, NULL);
/*
* If no template is found, apply the default rule.
xsltGenericDebug(xsltGenericDebugContext,
"add preserved space element %s\n", element);
#endif
- xmlHashAddEntry(style->stripSpaces, element, "preserve");
+ if (xmlStrEqual(element, (const xmlChar *)"*")) {
+ style->stripAll = -1;
+ } else {
+ xmlHashAddEntry(style->stripSpaces, element, "preserve");
+ }
xmlFree(element);
}
element = end;
* @style: the XSLT stylesheet
* @template: the "strip-space" prefix
*
- * parse an XSLT stylesheet strip-space prefix and record
+ * parse an XSLT stylesheet extension prefix and record
* prefixes needing stripping
*/
xsltGenericDebug(xsltGenericDebugContext,
"add stripped space element %s\n", element);
#endif
- xmlHashAddEntry(style->stripSpaces, element, "strip");
+ if (xmlStrEqual(element, (const xmlChar *)"*")) {
+ style->stripAll = 1;
+ } else {
+ xmlHashAddEntry(style->stripSpaces, element, "strip");
+ }
xmlFree(element);
}
element = end;
xmlDocPtr doc; /* the parsed XML stylesheet */
xmlHashTablePtr stripSpaces;/* the hash table of the strip-space
preserve space and cdata-section elements */
+ int stripAll; /* strip-space * (1) preserve-space * (-1) */
/*
* Global variable or parameters
## Process this file with automake to produce Makefile.in
-SUBDIRS=docs REC1 REC2 REC general namespaces numbers documents xmlspec docbook
+SUBDIRS=docs REC1 REC2 REC general namespaces numbers documents \
+ xmlspec docbook
all:
--- /dev/null
+<?xml version="1.0"?>
+<foo>
+ <bar>This is bar 1</bar>
+ <xxx/>
+ <bar>This is bar 2</bar>
+</foo>
+
--- /dev/null
+<?xml version="1.0"?>
+<foo>
+ <bar>
+ This is bar 1
+ </bar>
+ <bar>
+ This is bar 2
+ </bar>
+ <bar>
+ This is bar 3
+ </bar>
+</foo>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<character>
+ <skills>
+ <skill name="Balance" base="dex" ranks="2" total="5" mod="3"/>
+ <skill name="Bluff" base="cha" ranks="3" total="4" mod="1"/>
+ <skill name="Climb" base="str" ranks="6" total="5" mod="-1"/>
+ <skill name="Diplomacy" base="cha" ranks="2" total="3" mod="1"/>
+ <skill name="Escape artist" base="dex" ranks="2" total="5" mod="3"/>
+ <skill name="Gather info" base="cha" ranks="2" total="3" mod="1"/>
+ <skill name="Hide" base="dex" ranks="2" total="5" mod="3"/>
+ <skill name="Jump" base="str" ranks="4" total="3" mod="-1"/>
+ <skill name="Listen" base="wis" ranks="2" total="3" mod="1"/>
+ <skill name="Move silently" base="dex" ranks="2" total="5" mod="3"/>
+ <skill name="Perform" base="cha" ranks="4" total="5" mod="1"/>
+ <skill name="Ride" base="dex" ranks="4" total="7" mod="3"/>
+ <skill name="Search" base="int" ranks="2" total="3" mod="1"/>
+ <skill name="Sense motive" base="wis" ranks="2" total="3" mod="1"/>
+ <skill name="Spot" base="wis" ranks="2" total="3" mod="1"/>
+ <skill name="Swim" base="str" ranks="4" total="3" mod="-1"/>
+ <skill name="Tumble" base="dex" ranks="3" total="6" mod="3"/>
+ <skill name="Use rope" base="dex" ranks="2" total="5" mod="3"/>
+ </skills>
+</character>
--- /dev/null
+<?xml version="1.0"?>
+<FOO>
+ <BAR>This is bar 1</BAR>
+ <XXX></XXX>
+ <BAR>This is bar 2</BAR>
+</FOO>
--- /dev/null
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:template match="foo">
+ <FOO>
+ <xsl:apply-templates/>
+ </FOO>
+</xsl:template>
+
+<xsl:template match="bar">
+ <BAR>
+ <xsl:value-of select="."/>
+ </BAR>
+</xsl:template>
+
+<xsl:template match="xxx">
+ <XXX>
+ <xsl:value-of select="."/>
+ </XXX>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+<FOO><BAR INDEX="1">
+ This is bar 1
+ </BAR><BAR INDEX="2">
+ This is bar 2
+ </BAR><BAR INDEX="3">
+ This is bar 3
+ </BAR></FOO>
--- /dev/null
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:strip-space elements="*"/>
+
+<xsl:template match="foo">
+ <FOO>
+ <xsl:apply-templates/>
+ </FOO>
+</xsl:template>
+
+<xsl:template match="bar">
+ <BAR INDEX="{position()}">
+ <xsl:value-of select="."/>
+ </BAR>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+Balance Bluff Climb Diplomacy Escape artist Gather info Hide Jump Listen Move silently Perform Ride Search Sense motive Spot Swim Tumble Use rope
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+version="1.0">
+ <xsl:output method="xml" indent="yes"/>
+
+<xsl:template match="character">
+ <xsl:apply-templates select="skills"/>
+</xsl:template>
+
+<xsl:template match="skills">
+ <xsl:for-each select="./*">
+ <xsl:value-of select="./@name"/>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+Balance Bluff Climb Diplomacy Escape artist Gather info Hide Jump Listen Move silently Perform Ride Search Sense motive Spot Swim Tumble Use rope
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+version="1.0">
+ <xsl:output method="xml" indent="yes"/>
+
+<xsl:template match="character">
+ <xsl:apply-templates select="skills"/>
+</xsl:template>
+
+<xsl:template match="skills">
+ <xsl:for-each select="*">
+ <xsl:value-of select="./@name"/>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>