Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2007, 02:48 AM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default redirect:write printing xml header in output csv

Hi,

I need to write to an csv file,via xsl, which I have successfully done using the following code.

Code:
    <redirect:write select="$file_name">MONTH,SERVICE ORDER TYPE,SUCCESS RATE %
    <xsl:variable name="reconciledStats" select="@month"/>
    <xsl:for-each select="$reconciledStats">
        <xsl:if test="@StartRawDateAndTime=$month">
            <xsl:value-of select="concat(@StartRawDateAndTime,',',@ID, ',',@Total)" />
        </xsl:if>

    </xsl:for-each>
The problem is that at the top of my csv file, the following header is printed, which I need to remove. How can I remove this header:?

<?xml version="1.0" encoding="UTF-8"?>

many thanks,

Jon

 
Old October 1st, 2007, 03:13 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You could try adding <xsl:output method="text"/> as a top level declaration.

/- Sam Judson : Wrox Technical Editor -/
 
Old October 1st, 2007, 05:05 AM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am currently calling the template that makes the csv file from a page that renders as html. If I call <xsl:output method="text"/> as a top level declaration i get the whole page rendering as text.

Is there a way i can just get the one template to render as text?

Many thanks,

Jon

 
Old October 1st, 2007, 05:35 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Ah yes, my mistake.

I've just confirmed in the rewrite docs that rewrite does no coordinate with the XSLT serialization, therefore is going to take no notice of the xsl:output element.

http://xml.apache.org/xalan-j/apidoc.../Redirect.html

It seems to be a 'feature' of the rewrite element so I don't think there is anything you can do about it.

/- Sam Judson : Wrox Technical Editor -/
 
Old October 1st, 2007, 05:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Time to look at XSLT 2.0, perhaps? The <xsl:result-document> element gives you full control of the way in which secondary output files are serialized.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
header redirect not working guillermo Beginning PHP 2 June 23rd, 2006 05:33 AM
Strip the XML file header data from output thomasjacob XSLT 7 April 12th, 2006 09:47 AM
Q. How do I redirect users? (Location Header) richard.york PHP FAQs 0 April 3rd, 2004 07:40 PM
Header functions is same to asp respose.redirect() knight Beginning PHP 3 March 12th, 2004 04:06 PM
header redirect dazednconfused Beginning PHP 5 September 9th, 2003 01:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.