This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Output redirection in LotusXSL/xalan: using a variable?



Is it possible to use an xsl:variable for output redirection with
LotusXSL/xalan?

I am trying to compute the name of the output file in the
xslt-stylesheet. This works with xt, but not for LotusXSL:

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

<xsl:output method="xml" indent="yes"/>

<xsl:template match="mondial">
  <xsl:variable name="output_file_name">
    <xsl:choose>
      <xsl:when test="@restrictions">
        <xsl:variable name="restrictions" select="@restrictions"/>
        <xsl:value-of select="concat('mondial-',$restrictions,'-2.0.xml')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="'mondial-2.0.xml'"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <redirect:write select="{$output_file_name}">;
<!--                       ^^^^^^^^^^^^^^^^^^  
  the following works:    
   <redirect:write select="@restriction">;
  or, with xt:
   <xt:document href="{$output_file_name}">       -->

  <xsl:text disable-output-escaping="yes">
       &lt;!DOCTYPE mondial SYSTEM "mondial-2.0.dtd"&gt;
  </xsl:text>
  <mondial>
  <xsl:apply-templates select="*"/>
  </mondial>
  </redirect:write>
<!--   </xt:document> -->
</xsl:template>

*** the input file

<mondial restrictions="europe">

<continent id="europe">
   <name>Europe</name>
   <area>9562488</area>
</continent>

...

</mondial>

, so $output_file_name above should have the value
"mondial-europe-2.0.xml", but I get ...

*** the error message:

malta:~/tmp> java org.apache.xalan.xslt.Process -in mondial-europe-flat.xml -xsl mondial-2.0.xsl
========= Parsing file:/home/may/tmp/mondial-2.0.xsl ==========
Parse of file:/home/may/tmp/mondial-2.0.xsl took 1242 milliseconds
========= Parsing mondial-europe-flat.xml ==========
Parse of mondial-europe-flat.xml took 3871 milliseconds
=============================
Transforming...
XSL Error: Redirect extension: Could not get filename - file or select attribute must return vald string., style tree node: org.apache.xalan.xslt.ElemExtensionCall@1fa51967, source tree node: mondial
Call to extension function failed: method call/new failed: java.lang.reflect.InvocationTargetException target exception: 
<?xml version="1.0" encoding="UTF-8"?>

transform took 553 milliseconds
XSLProcessor: done
malta:~/tmp> 

THX,
Wolfgang

-- -----------------------------------------------------------------
Wolfgang May             E-mail: may@informatik.uni-freiburg.de   
Universitaet Freiburg    http://www.informatik.uni-freiburg.de/~may/
Institut fuer Informatik D-79110 Freiburg / Germany
Lehrstuhl fuer Datenbanken und Informationssysteme
Tel ++49 761 203-8131    Fax ++49 761 203-8122 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]