Re: [xslt] Rogue newline appearing between elements
- From: Daniel Veillard <veillard redhat com>
- To: xslt gnome org
- Subject: Re: [xslt] Rogue newline appearing between elements
- Date: Thu, 1 Nov 2001 09:05:39 -0500
On Wed, Oct 31, 2001 at 08:50:38PM +0000, Justin Fletcher wrote:
> In message <548ebbd14a.Justin@gerph.movspclr.co.uk>
> Justin Fletcher <justin.fletcher@ntlworld.com> wrote:
>
> > Hiya,
> >
> > With xsltproc from libxslt 1.0.6, I'm getting a rogue new line appearing
> > in my output and I cannot see where it's coming from. If there is something
> > special in the specification that covers this behaviour, it has elluded
> > me. I have cut down the stylesheet and data set to about as small as I can
> > make it whilst retaining some vague sense and still exhibit the oddity.
> >
> > Command used to process input:
> > *xsltproc -o data.html data.xsl data.xml
> >
> > --8<-------- data/xsl
> > <?xml version="1.0" standalone="yes"?>
> >
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns="http://www.w3.org/TR/xhtml1/strict">
> >
> > <xsl:output method="html" indent="no"/>
>
> [snip]
>
> Further to my previous email, if I make the output method xml, the
> 'rogue white-space' goes away; which lead me to investigate a little
> further.
>
> libxslt calls htmlDocContentDumpOutput in xsltSaveResultTo. This in
> turn calls htmlDocContentDumpFormatOutput with the 'format' parameter
> set to 1, which forces formatting return/spaces to be added. Should there
> be a way of calling htmlDocContentDumpFormatOutput directly with an
> option for the formating, rather than forcing the use of it ?
Hum the indent= value in the case of xsl:output with method="html"
was not taken into account. The enclosed patch fixes it
thanks,
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
*** libxslt/xsltutils.c 2001/10/24 11:07:15 1.51
--- libxslt/xsltutils.c 2001/11/01 13:51:51
***************
*** 764,769 ****
--- 764,770 ----
xmlNodePtr root;
int base;
const xmlChar *method;
+ int indent;
if ((buf == NULL) || (result == NULL) || (style == NULL))
return(-1);
***************
*** 784,789 ****
--- 785,791 ----
XSLT_GET_IMPORT_PTR(method, style, method)
XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+ XSLT_GET_IMPORT_INT(indent, style, indent);
if ((method == NULL) && (result->type == XML_HTML_DOCUMENT_NODE))
method = (const xmlChar *) "html";
***************
*** 800,806 ****
} else {
htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
}
! htmlDocContentDumpOutput(buf, result, (const char *) encoding);
xmlOutputBufferFlush(buf);
} else if ((method != NULL) &&
(xmlStrEqual(method, (const xmlChar *) "xhtml"))) {
--- 802,811 ----
} else {
htmlSetMetaEncoding(result, (const xmlChar *) "UTF-8");
}
! if (indent != 0)
! indent = 1;
! htmlDocContentDumpFormatOutput(buf, result, (const char *) encoding,
! indent);
xmlOutputBufferFlush(buf);
} else if ((method != NULL) &&
(xmlStrEqual(method, (const xmlChar *) "xhtml"))) {
***************
*** 854,865 ****
} else {
int omitXmlDecl;
int standalone;
- int indent;
const xmlChar *version;
XSLT_GET_IMPORT_INT(omitXmlDecl, style, omitXmlDeclaration);
XSLT_GET_IMPORT_INT(standalone, style, standalone);
- XSLT_GET_IMPORT_INT(indent, style, indent);
XSLT_GET_IMPORT_PTR(version, style, version)
if (omitXmlDecl != 1) {
--- 859,868 ----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]