Solved

XSL & Space delimited entries

Posted on 2002-06-03
4
184 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
Vb.net XML Read all nodes and 4 72
Parsing the XML data to SQL Server 4 59
Convert Oracle data into XML document 2 55
XML to Excel using XSL - formatting 3 25
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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

19 Experts available now in Live!

Get 1:1 Help Now