xsl-list
[Top] [All Lists]

Re: [xsl] redirect

2007-03-04 11:29:13
I think, you would get prompt answers for Xalan-J related questions on
xalan-j-users(_at_)xml(_dot_)apache(_dot_)org(_dot_)

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(_dot_)hirst(_at_)blueyonder(_dot_)co(_dot_)uk> 
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(_dot_)hirst(_at_)blueyonder(_dot_)co(_dot_)uk


--
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>