Re: [xsl] How to transform XML to EDI format?

Subject: Re: [xsl] How to transform XML to EDI format?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 28 Aug 2001 11:06:31 -0400
Cihan,

Your problem isn't with your XSL, it's with Notepad. The end-of-line character in your file is a single Unicode LF character (&#10;). This is what XML mandates for line feeds; it happens to be what Unix systems historically have used. Windows, on the other hand, has used a LFCR (linefeed, carriage return) combination. This is what Notepad is expecting; since it doesn't get it, you see your output on one line. But the linefeeds are there. MS Word is smarter about it (it might be changing the LF into the LFCR), so you see the linefeeds when you open it in MS Word.

Your best solution is to dump Notepad (which is pretty useless as a tool in any case), in favor of an editor that knows about Unix files (or even better, XML files). Any decent programmer's text editor will do this, including Emacs, TextPad (an inexpensive Windows text editor), or a number of others.

In other words, use tools that respect the standards, don't break your data to fit your tools.

Cheers,
Wendell

At 11:26 AM 8/27/01, you wrote:
Hi,
I am trying to convert XML document to EDI format in my new project and
I have some questions;

End of line character: When I try to convert a small portion of XML to
EDI format and open it in notepad, everything is in one line there is no
line break. How Can I put line breaks-end of line characters in XSL.
Here is a portion of a code from XML and my xsl file and the output I
get when I open it in notepad. (I save my output in "test.edi" format
and open it in notepead and I get one line of output, on the other hand
if I open the same output in MS Word I get the end of line character
working.
I've tried xalan and saxon and got the same results..
How would I get my output to have the end of line when I open it with
notepad.

Thanks...



xsl file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" encoding="us-ascii" />
        <xsl:template match="/">

<xsl:text>START-CRSE-RECORD</xsl:text><xsl:text>&#10;</xsl:text>
           <xsl:text>CRSE-CD=LOCAL-CRSE-CD=</xsl:text><xsl:value-of
select="/course/@courseNum"/><xsl:text>&#10;</xsl:text>
        </xsl:template>
</xsl:stylesheet>

------------
xml file
------------
<?xml version="1.0"?>
<course courseNum="EDITEST">
  <module test-type="T">
        <title>
                <para>Test-out</para>
        </title>
        <intro>
                <para>This is the test-out module.</para>
        </intro>
  </module>
</course>

---------
output
---------
START-CRSE-RECORD CRSE-CD=LOCAL-CRSE-CD=EDITEST




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread