RE: [xslt] LibXSLT adding annoying whitespace



> You could try using
> <xsl:strip-space elements="table tr td"/>
> but that's not always what you want.

This won't work because I'm not processing HTML, I'm trying to output it.
Here is an example that will illustrate my problem:

Example 1 (XSL):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml"/>

  <xsl:template match="/">
    <html><body><img/><br/><a><img/></a></body></html>
  </xsl:template>
</xsl:stylesheet>

Example 1 (Output):
<?xml version="1.0"?>
<html><body><img/><br/><a><img/></a></body></html>

Example 2 (XSL):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>

  <xsl:template match="/">
    <html><body><img/><br/><a><img/></a></body></html>
  </xsl:template>
</xsl:stylesheet>

Example 2 (Output):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<img>
<br>
<a><img></a>
</body></html>

As you can see, there is an inconsistancy in the way \n's are being
handled...I don't believe the XSL specification states that whitespace be
*added* when it isn't in the source XSL.

> I'd say check your templates to see if they have spaces in them --
> make sure all text is inside <xsl:text> ... </xsl:text> as otherwise
> whitespace becomes significant.

I don't believe this will work.  <xsl:text/> doesn't like having "<" or ">"
characters in its body.

I hope this clarifies my problem.  I'm surprised no one else has run into
this situation before (it may be my environment, but I'm using the RPMs from
xmlsoft.org, so I don't think its anything I'm doing to it).  I'm also
positive it doesn't have anything to do with AxKit or XML::LibXSLT, since I
can replicate this problem through "xsltproc".




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