Dear all,
I've written a little stylesheet which takes as input an XML with
several <file> elements and spits out an output file per <file> element
containing that <file> element. This might be confusing, but hopefully
the problem doesnt' lie here.
I would like to name each one of these output files with the name of the
input file plus something else, for which I've used regular expressions
(to capture the common part of the name of the input file that I want to
reuse). However, I don't know how to give that common part to the
result-document function which writes the output files. I suspect it's
got to do with not declaring properly the parameter or not making the
$COMMON variable global (in capitals so you can see it right away).
Here's my code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" encoding="UTF-16" standalone="no"
name="xml" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:param name="COMMON"/>
<xsl:for-each select="//file">
<xsl:variable name="srcfilename" select="base-uri(/)"/>
<xsl:analyze-string select="$srcfilename"
regex=".+/([^/]+)\.(XLF|xlf)">
<xsl:matching-substring>
<xsl:variable name="COMMON" select="regex-group(1)"/>
<xsl:value-of select="$COMMON" /> <!-- Creating?? -->
</xsl:matching-substring>
</xsl:analyze-string>
<xsl:variable name="newfilename"
select="concat('output1/',$COMMON,_,@target-language,'.xlf')" />
<xsl:value-of select="$newfilename" /> <!-- Creating -->
<xsl:result-document href="{$newfilename}" format="xml">
<xliff version="1.0">
<newname><xsl:value-of select="$newfilename"
/></newname>
<xsl:copy-of select="."/>
</xliff>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Do you know what coudl be wrong??
Thanks a lot!
--
Manuel Souto Pico
Terminòleg / Responsable de servei tècnic
manuel(_dot_)souto(_at_)star-group(_dot_)net
<mailto:manuel(_dot_)souto(_at_)star-group(_dot_)net>
*STAR Servicios Lingüísticos*
C. Sardenya, 195-197 (baixos)
E-08013 Barcelona
Tel. +34 932 440 889
Fax: +34 932 471 273
http://www.star-spain.com
http://www.star-group.net <http://www.star-spain.com>
En cumplimiento con lo previsto en los artículos 21 y 22 de la Ley
34/2002, de 11 de julio, de Servicios de la Sociedad de Información y
Comercio Electrónico (LSSI) y las disposiciones de la Ley Orgánica
15/1999, de 13 de diciembre de Protección de Datos de Carácter Personal
(LOPD) le informamos que procederemos al archivo y tratamiento de sus
datos exclusivamente con fines de promoción de los productos y servicios
ofrecidos por STAR Servicios Lingüísticos, S.L. Este mensaje, y en su
caso, cualquier fichero anexo al mismo, puede contener información
confidencial o legalmente protegida, siendo para uso exclusivo del
destinatario. No hay renuncia a la confidencialidad o secreto
profesional por cualquier transmisión defectuosa o errónea, y queda
expresamente prohibida su divulgación, copia o distribución a terceros
sin la autorización expresa de STAR Servicios Lingüísticos, S.L. Si ha
recibido este mensaje por error, se ruega lo notifique a STAR Servicios
Lingüísticos enviando un mensaje al remitente o al correo electrónico
info(_at_)star-spain(_dot_)com y proceda inmediatamente al borrado del mensaje
original y de todas sus copias. Gracias por su colaboración. Si desea
más información sobre sus derechos en lo que respecta al tratamiento de
sus datos de carácter personal, visite
http://www.star-spain.com/es/inicio/lopd.php
--~------------------------------------------------------------------
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>
--~--