RE: [xsl] Output to a file...and line feeds...

Subject: RE: [xsl] Output to a file...and line feeds...
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 23 Jul 2007 20:31:34 +0100
<xsl:output method="text"> defines the serialization format - text rather
than XML or HTML. The output destination - the place where the serialized
text is written - depends on the interface you are using to invoke your XSLT
processor, and varies from one processor to another.

Microsoft's "XML Notepad" does not support XSLT 2.0. There are currently
three XSLT 2.0 processors available, my own Saxon product, Altova's XSLT
product, and Colin Adams Gestalt processor (which isn't yet complete).

If you're using Saxon, and writing a single output file, and running it from
the command line, then you can use the -o option to direct the output to a
file, or just redirect standard output. If you're using it via a GUI such as
Kernow, you just click the right buttons.

The information about xsl:result-document was a bit of a red-herring. It's
only needed if you want to write several output files.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Naschke, Pete [mailto:NaschkePS@xxxxxxxxx] 
> Sent: 23 July 2007 19:27
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Output to a file...and line feeds...
> 
> I verified that my XSLT file does have the <xsl:output 
> method="text" /> line...but when does the program ask for a 
> filename to save the data file to??
> 
> Here's my XSLT file...
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:output method="text" />
>   <xsl:template match="/">
>     <xsl:apply-templates
> select="windowgroup/windowgroupings/windowgrouping" />
>   </xsl:template>
>   <xsl:template match="windowgrouping">
>     <xsl:value-of select="shortdescription/@Value" />
>     <xsl:text></xsl:text>
>     <xsl:value-of select="longdescription/@Value"></xsl:value-of>
>     <xsl:text></xsl:text>
>     <xsl:value-of select="longdescription/@Value"></xsl:value-of>
>     <xsl:text></xsl:text>
>   </xsl:template>
> </xsl:stylesheet>
> 
> How do I use, where do I find XSLT 2.0? I am using the 
> Microsoft program XML Notepad...does it somehow allow the 
> user to select XSLT 1.0 or XSLT 2.0??
> 
> I think if I get this file output problem figured out, I'll 
> be able to do more effective program development.
> 
> 
> -----Original Message-----
> From: Andrew Welch [mailto:andrew.j.welch@xxxxxxxxx]
> Sent: Monday, July 23, 2007 11:31 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Output to a file...and line feeds...
> 
> On 7/23/07, Naschke, Pete <NaschkePS@xxxxxxxxx> wrote:
> > 1. How is the best way to create a new text file (or Excel 
> CSV file) 
> > using an XSLT file?
> 
> If you mean in addition to the result of the transform then 
> it's like DC says, but if you mean _as_ the result of the 
> transform then use <xsl:output method="text"/>
> 
> > 2. how is the best way to create a line-feed? (After 
> printing my comma 
> > separated values, I need to "drop down" a line for the next data
> group.)
> 
> If you are creating it using a function (such as concat()) 
> within an attribute then I use &#xa; (which is &#10; :) 
> otherwise use <xsl:text>&#xa;</xsl:text> I would advise against doing:
> <xsl:text>
> </xsl:text>
> ..because it becomes a maintenance issue when you can see how 
> much white space you're adding to the result.
> 
> 
> --
> http://andrewjwelch.com

Current Thread