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 April 12th, 2006, 07:26 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strip the XML file header data from output

My XSL file

<xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version = "1.0">

    <xsl:output method="text"/>

    <xsl:template match="Records">
    <xsl:apply-templates select="Record"/>
    </xsl:template>

    <xsl:template match="Record">
    <xsl:value-of select="App_Content/OnlineApps/AppType/DragonDirect/DDAppDetails/NoOfApplicants"/>,<xsl:value-of select="App_Content/OnlineApps/AppType/DragonDirect/DDAppDetails/IsBankCustomer"/>,<xsl:value-of select="AppId"/><xsl:value-of select="'#xA;'"/>
    </xsl:template>
    </xsl:stylesheet>

My XML File
<Records>
    <Record>
        <AppId>286401</AppId>
        <App_Status>SUB</App_Status>
        <App_Created>2004-12-14 13:38:40.413</App_Created>
        <App_Updated>2005-10-21 18:16:06.273</App_Updated>
        <App_Content>
            <OnlineApps>
                <Version>
                    <VersionNumber>4.1</VersionNumber>
                    <VersionDate>23-11-2003</VersionDate>
                </Version>
                <AppType>
                    <DragonDirect>
                        <DDAppDetails>
                            <NoOfApplicants>1</NoOfApplicants>
                            <IsBankCustomer>No</IsBankCustomer>
                        </DDAppDetails>
                    </DragonDirect>
                </AppType>
            </OnlineApps>
        </App_Content>
    </Record>
    <Record>
        <AppId>286357</AppId>
        <App_Status>SUB</App_Status>
        <App_Created>2004-12-14 18:02:01.383</App_Created>
        <App_Updated>2004-12-14 18:02:57.650</App_Updated>
        <App_Content>
            <OnlineApps>
                <Version>
                    <VersionNumber>4.1</VersionNumber>
                    <VersionDate>23-11-2003</VersionDate>
                </Version>
                <AppType>
                    <DragonDirect>
                        <DDAppDetails>
                            <NoOfApplicants>1</NoOfApplicants>
                            <IsBankCustomer>No</IsBankCustomer>
                        </DDAppDetails>
                    </DragonDirect>
                </AppType>
            </OnlineApps>
        </App_Content>
    </Record>
    <RecordCount>2</RecordCount>
</Records>

My output is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1,No,286401
1,No,286357

My Question
How do i remove the <?xml version="1.0" encoding="UTF-8" standalone="no"?> from my output. Is there any way to enhance my XSL file. PLS Note:The output data is not fetched sequentially




 
Old April 12th, 2006, 07:34 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No XML declaration should be written when you specify <xsl:output method="text"/>.

What XSLT processor are you using and how are you invoking it?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 12th, 2006, 07:46 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using XALAN XSLT Processor and invoking it using java. TransformerFactory tFactory = TransformerFactory.newInstance();
I am not sure about the invocation though

Thanks
Thomas

 
Old April 12th, 2006, 07:49 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I know this one:)

Transformer transformer = transformation.newTransformer();
Properties props = new Properties();
props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperties(props);


 
Old April 12th, 2006, 09:23 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It would be useful to see what parameters you supply to the transform() method and whether you call setOutputProperties.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 12th, 2006, 09:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

omit-xml-declaration shouldn't make any difference with output method text: there shouldn't be an XML declaration anyway.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 12th, 2006, 09:42 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Arthur and Micheal. Arthur's setting OMIT_XML_DECLARATION did the trick

Cheers
Thomas

 
Old April 12th, 2006, 09:47 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there any way to enhance the xsl file, I need to display about 150 element values in one row. The values are not distributed sequentially.Anyway to better the xsl.

eg:
1,No,286401...150 such fields
1,No,286357..150 such fields

Thanks
Thomas








Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
redirect:write printing xml header in output csv jon.london XSLT 4 October 1st, 2007 05:47 AM
How to output dataset to .txt file not to .xml? nesrine C# 1 March 8th, 2007 11:34 AM
How to output dataset to .txt file not to .xml? nesrine ASP.NET 2.0 Professional 0 March 8th, 2007 05:36 AM
XML Output file Neal Crystal Reports 0 October 24th, 2006 07:02 AM





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