Go Premium for a chance to win a PS4. Enter to Win

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

XSL & Space delimited entries

I'm trying to format the output from an XSL transformation with a space between the two fields without any luck.

The following spits out text as indicated:

<xsl:for-each select="FileText/TLine">
<tr><td><pre>
<xsl:value-of select="TimeIndex"/>
<xsl:value-of select="TText"/>
<pre></td></tr>
</xsl:for-each>

12345Here's the text from this line

(where the TimeIndex=12345 & the TText=Here's the text from this line )

what I want is:
12345    Here's the text from this line

Is there any way in the XSL file to force spaces? If I put any character OTHER than spaces between the two fields it displays correctly.

<xsl:value-of select="TimeIndex"/>
:
<xsl:value-of select="TText"/>

Gives me:
12345:    Here's the text from this line

If I just put in several spaces, the output overwrites itself.

I've tried <pre>, etc. but no luck.

I'll bump the points up based on difficulty, but it seems like this should be relatively straight forward. I don't care about browser compatibility - it'll be IE only.

Thanks.

0
carpbyte
Asked:
carpbyte
  • 2
  • 2
1 Solution
 
b1xml2Commented:
<xsl:for-each select="FileText/TLine">
<tr>
<td>
<xsl:value-of select="concat(TimeIndex,' ',TText)"/>
</td>
</tr>
</xsl:for-each>

PS: You are right, this is a simple question. And the answer, is not IE-specific if it is XSLT.
0
 
carpbyteAuthor Commented:
This makes perfect sense, however I'm getting an error - "unknown method" but this may have to do with the rest of the XSL. Forgive my ignorance - I'm not new to programming but definitely new to XML.

Clarification appreciated & the points are yours :)

Thanks.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
      <xsl:for-each select="FileText/TLine">
        <tr>
     <td>
     <xsl:value-of select="concat(TimeIndex, '',TText)"/>
        </td>
     </tr>
     </xsl:for-each>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

0
 
b1xml2Commented:
that because of the namespace which is XSL and not XSLT.

XSLT Document
==============
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="yes" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="FileText/TLine">
<tr>
<td>
<xsl:value-of select="concat(TimeIndex,' ',TText)"/>
</td>
</tr>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

with XSL that you are using:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="FileText/TLine">
<tr>
<td>
<!--on one single line-->
<xsl:value-of select="TimeIndex" /><xsl:entity-ref name="nbsp" /><xsl:value-of select="TText"/>
</td>
</tr>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
0
 
carpbyteAuthor Commented:
I figured I didn't give you the full story on the rest of the document.

Works perfectly!

Thank you very much.

Carp.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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