[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

passing a regex matched substring to the result-docume

Subject: passing a regex matched substring to the result-document
From: Manuel Souto Pico <manuel.souto@xxxxxxxxxxxxxx>
Date: Fri, 04 Sep 2009 19:10:26 +0200
 passing a regex matched substring to the result-docume
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
Terminrleg / Responsable de servei thcnic
manuel.souto@xxxxxxxxxxxxxx <mailto:manuel.souto@xxxxxxxxxxxxxx>

*STAR Servicios Ling|msticos*
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 artmculos 21 y 22 de la Ley 34/2002, de 11 de julio, de Servicios de la Sociedad de Informacisn y Comercio Electrsnico (LSSI) y las disposiciones de la Ley Organica 15/1999, de 13 de diciembre de Proteccisn de Datos de Caracter Personal (LOPD) le informamos que procederemos al archivo y tratamiento de sus datos exclusivamente con fines de promocisn de los productos y servicios ofrecidos por STAR Servicios Ling|msticos, S.L. Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede contener informacisn confidencial o legalmente protegida, siendo para uso exclusivo del destinatario. No hay renuncia a la confidencialidad o secreto profesional por cualquier transmisisn defectuosa o errsnea, y queda expresamente prohibida su divulgacisn, copia o distribucisn a terceros sin la autorizacisn expresa de STAR Servicios Ling|msticos, S.L. Si ha recibido este mensaje por error, se ruega lo notifique a STAR Servicios Ling|msticos enviando un mensaje al remitente o al correo electrsnico info@xxxxxxxxxxxxxx y proceda inmediatamente al borrado del mensaje original y de todas sus copias. Gracias por su colaboracisn. Si desea mas informacisn sobre sus derechos en lo que respecta al tratamiento de sus datos de caracter personal, visite http://www.star-spain.com/es/inicio/lopd.php

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.