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 November 29th, 2006, 01:06 PM
Authorized User
 
Join Date: May 2006
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a .bat file with CR and linefeed

I wanted to create a DOS .bat file to test several documents based on information in a xml file.
Only everything line is created on one single line in the .bat file. I saw this problem on several forums but could not find the right answer. The thing is you have to have a carriage return and line feed for the line separation.
I wanted to drop a question about it here but I just found out how I could get it to work.

When I used <xsl:text> or codepoints-to-string() to convert carriage return and line feed and used the method 'html' output I got the output text on one line in my .bat file.
When I used output 'xml' I get for every return the text '#xD;'

But when I use the output method 'text' you get the right linefeed and carriage return pair for your MSDos .bat file.

syntax example: use <xsl:text>#13;#10;</xsl:text> or
<xsl:value-of select="codepoints-to-string((13,10))"/>

<xsl:output method="text"/>
<xsl:template match="/">
    <xsl:for-each select="myelement">
        <xsl:variable name="type" select="@testtype"/>
        <xsl:variable name="doc" select="@href"/>
        <xsl:text>#13;#10;</xsl:text>set test=<xsl:value-of select="$type"/>
        <xsl:text>#13;#10;</xsl:text>set doc=<xsl:value-of select="$doc"/>
        <xsl:text>#13;#10;</xsl:text>call test.bat<xsl:text>#13;#10;</xsl:text>
    </xsl:for-each>
</xsl:template>
 
Old November 29th, 2006, 01:38 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You should use xsl:output method="text" to generate a .bat file.

The spec doesn't say whether the processor should output line endings as NL characters or as CRLF. It might depend on the target platform, or it might depend on what you asked for in the stylesheet.

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
.exe or .bat file and VB.NET MARY9 Pro VB.NET 2002/2003 1 March 8th, 2007 08:08 AM
bat file doesn't work maroun BOOK: Beginning Cryptography with Java 1 October 25th, 2005 04:59 PM
Problem with reading BAT file rhysduk VB How-To 0 January 12th, 2005 09:53 AM
Writing to a .BAT file using VB6 rhysduk VB How-To 17 January 7th, 2005 09:06 AM





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