Solved

XSL & Space delimited entries

Posted on 2002-06-03
4
185 Views
Last Modified: 2012-05-04
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
Comment
Question by:carpbyte
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 7052583
<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
 

Author Comment

by:carpbyte
ID: 7054148
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
 
LVL 23

Accepted Solution

by:
b1xml2 earned 50 total points
ID: 7054262
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
 

Author Comment

by:carpbyte
ID: 7054290
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DOCTYPE in pubmed 5 68
Mongodb hierarchy 2 55
c# code 19 71
Help with Syntax 9 37
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question