Re: [xsl] redirect

Subject: Re: [xsl] redirect
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Sun, 4 Mar 2007 23:58:39 +0530
I think, you would get prompt answers for Xalan-J related questions on
xalan-j-users@xxxxxxxxxxxxxxx

You could consider moving to XSLT 2.0. It has an instruction
xsl:result-document for this requirement.

On 3/4/07, Mike Hirst <mike.hirst@xxxxxxxxxxxxxxxx> wrote:
I'm having problems with xalan redirect extension. I have an xml file
from which I am extracting info to create a set of cue files to use in
audio editing. I need the output to be plain text, so use the following:

<xsl:output method="text" omit-xml-declaration="yes"/>

The xslt works fine if I use it to produce individual files. However, if
I use redirect:write to produce multiple files:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">

<xsl:output method="text" omit-xml-declaration="yes"/>

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

   <xsl:template match="//person">
       <redirect:write
select="concat(translate(substring-after(anumber, '200'), '.', '_'),
'._q')">

<!-- code to produce output -->

       </redirect:write>
   </xsl:template>
</xsl:stylesheet>

I get an XML declaration at the head of my output files. I've had a
quick read through xalan docs and cn't find anything to help. Has anyone
out there any advice that might help me solve this issue?

I have included the full xslt below.

Best wishes

Mike Hirst

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">

<xsl:output method="text" omit-xml-declaration="yes"/>

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

   <xsl:template match="//person">
       <redirect:write
select="concat(translate(substring-after(anumber, '200'), '.', '_'),
'.cue')">
           <xsl:value-of select="concat('FILE &quot;g:\',
translate(substring-after(anumber, '200'), '.', '_'), '.wav&quot; WAVE')"/>
           <xsl:value-of select="'&#xA;'"/>
           <xsl:for-each select="clip">
               <xsl:value-of select="concat('TRACK ',
format-number(qnumber, '00'), ' AUDIO')"/>
               <xsl:value-of select="'&#xA;'"/>
               <xsl:value-of select="concat('TITLE ', '&quot;',
../name, ' - ', format-number(qnumber, '00'), '&quot;')"/>
               <xsl:value-of select="'&#xA;'"/>
               <xsl:if test="substring(start,2,1) = 1">
                   <xsl:value-of select="concat('INDEX 01 ',
substring(start,4,2) + 60,':',substring(start,7),':00')"/>
               </xsl:if>
               <xsl:if test="substring(start,2,1) = 0">
                   <xsl:value-of select="concat('INDEX 01 ',
substring(start,4),':00')"/>
               </xsl:if>
               <xsl:value-of select="'&#xA;'"/>
               <xsl:if test="substring(end,2,1) = 1">
                   <xsl:value-of select="concat('INDEX 01 ',
substring(end,4,2) + 60,':',substring(end,7),':00')"/>
               </xsl:if>
               <xsl:if test="substring(end,2,1) = 0">
                   <xsl:value-of select="concat('INDEX 01 ',
substring(end,4),':00')"/>
               </xsl:if>
               <xsl:value-of select="'&#xA;'"/>
           </xsl:for-each>
       </redirect:write>
   </xsl:template>
</xsl:stylesheet>


-- Mike Hirst Mike Hirst - Digital Audio http://www.mikehirst-digitalaudio.com

tel: 0191 289 3186
mailto:mike.hirst@xxxxxxxxxxxxxxxx


--
Regards,
Mukul Gandhi

Current Thread