[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

whitespace in XSLT transformation

I've got a table that includes an XML control on an ASP.NET page.  The XML control has an XSLT transformation that returns some values from my XML file.  It does exactly what I want to do in terms of returning the right values from the XML, but the whitespace on the table is bothering me.  I'm not sure if its the way I designed the table or the way the XSLT file is transforming.  Can somebody help? I've attached a screenshot as well as the markup and XSLT file.  


<table border="0" width="1000px"  ><tr><td width="50px"></td>
    <td width="900px" style="border-color : #000000; background-color:#3399FF;" 
        align="left">
       
    <asp:Xml ID="Xml1" runat="server" DocumentSource="~/News.xml" 
            TransformSource="~/Newone.xslt"></asp:Xml></td><td width="50px"></td></tr></table> 
 
 
xslt file
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:strip-space elements="*"/>
  <xsl:template match="Message[Message]">
    <xsl:variable name="no-of-mess">
      <xsl:value-of select="count(Message)"/>
    </xsl:variable>
    <html>
      <body>
 
 
        <table border="0">
         
          <xsl:apply-templates select="Message[position() > ($no-of-mess - 3) ]"/>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Message[parent::Message]">
    <tr>
      <td style="color:red; font-weight:bold">
 
        <xsl:value-of select="date"/>
 
      </td>
    </tr>
    <tr>
 
      <td style ="font-weight:bold">
        <xsl:value-of select="messagetext"/>
        <br/>
        <br/>
      </td>
    </tr>
    <br/>
    <br/>
  </xsl:template>
</xsl:stylesheet>

Open in new window

screenshot010.jpg
0
JeffEae
Asked:
JeffEae
  • 2
1 Solution
 
aibusinesssolutionsCommented:
Have you tried removing the whitespace from your xslt file?

What does the source code of your page look like when you view the source?
0
 
aibusinesssolutionsCommented:
I played around with it and found the problem.  At the bottom of your XSLT file you have this.

      <td style ="font-weight:bold">
        <xsl:value-of select="messagetext"/>
        <br/>
        <br/>
      </td>
    </tr>
    <br/>
    <br/>
  </xsl:template>
</xsl:stylesheet>

Remove the two <br/>'s at the bottom, they are outside of the <td> so they go outside of the table cells.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now