Solved

XSL & Space delimited entries

Posted on 2002-06-03
4
183 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now