Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL for fixed-length output

Status
Not open for further replies.

JJ26

Programmer
Oct 22, 2002
85
ID
Dear friends,

is there someone could help me ...
What is wrong with my XSL file which is converting an XML file into fixed-length output ?
Because I get 1 empty line before & after the fixed-length data.

Here's my XML
Code:
<library>
<book>
  <style>Z79</style>
  <title>Judul Judul</title>
</book>
<book>
  <style>V00333</style>
  <title>Judul Judul 2323</title>
</book>
</library>

and my XSL
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="text" omit-xml-declaration="yes" indent="no" encoding="ISO-8859-1"/>
<xsl:template match="book">
	<xsl:value-of select="substring(concat(style,'       '),1,10)"/>
	<xsl:value-of select="substring(concat(title,'       '),1,10)"/>
</xsl:template>
</xsl:stylesheet>


the result i got
Code:
Z79       Judul Judu
V00333    Judul Judu

Thanks alot

Regards,
JJ
 
Have you tried this?
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="text" omit-xml-declaration="yes" indent="no" encoding="ISO-8859-1"/>
<xsl:template match="book"><xsl:value-of select="substring(concat(style,'       '),1,10)"/>
<xsl:value-of select="substring(concat(title,'       '),1,10)"/></xsl:template>
</xsl:stylesheet>
With text output mode, that whitespace is significant.

Tom Morrison
 
To:eek:p
>Because I get 1 empty line before & after the fixed-length data.
Should we read as "Because I want to get..." or literally "Because I get ..."?
I cannot reproduce what you seem to suggest!

If you mean "want" to get 1 empty line before & after the fixed-length data, then you can try this.
[tt]
<xsl:template match="book">
<xsl:if test="position() = 1">
<xsl:text>&#x0d;&#x0a;</xsl:text>
</xsl:if>
<xsl:value-of select="substring(concat(style,' '),1,10)"/>
<xsl:value-of select="substring(concat(title,' '),1,10)"/>
<xsl:text>&#x0d;&#x0a;</xsl:text>
</xsl:template>
[/tt]
The newline might be os-dependent, you might have to adjust accordingly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top