Page 1 of 1
Generate an output string modified by a catalog
Posted: Wed Feb 02, 2022 3:45 pm
by FJJCENT
Because I want to pass a string containing an absolute route to a file as parameter to a Xslt Template which open the document specified in the parameter, I need a way of converting such string into a route using a catalog
I explain in Code
currently I have an Uri like this
"https://www.bancaonline/banco_santander"
I need convert it into
"file:/c:/bancos/santander/clientes.xml"
so I introduce the change in catalog
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
<rewriteURI uriStartString="https://www.bancaonline/banco_santander"
rewritePrefix="file:/c:/bancos/santander/clientes.xml" />
</catalog>
later I create in XSLT file a variable
route with the first URI in order to use
"$route" as parameter
<xsl:variable name="route" select="https://www.bancaonline/banco_santander" />
but I receive the following error
Unexpected token ":" beyond end of expression I think that the Uri is not normalized, could you help me to get the variable route working and receiving the correct Uri by the catalog.
Best Regards
Francisco
Re: Generate an output string modified by a catalog
Posted: Thu Feb 03, 2022 9:07 am
by Radu
Hi Francisco,
How about if you post a small sample (XSLT + XML + XML catalog) to better exemplify the situation? Because I have no idea at what line in the stylesheet the error "Unexpected token ":" beyond end of expression " occurs.
Regards,
Radu
Re: Generate an output string modified by a catalog
Posted: Thu Feb 03, 2022 11:52 am
by FJJCENT
I Detail the Error
XSLT File
<xsl:template match="/">
<xsl:variable name="route" select="https://www.bancaonline/banco_santander/clientes.xml" />
<!-- here yields the error Unexpected token ":" beyond end of expression -->
<xsl:result-document href="{$rutaDocumentoSalida}" method="xml" encoding="UTF-8" indent="yes" >
<xsl:apply-templates select="document($rutaDocumentoEntrada)" >
<xsl:with-param name="uriPuntoEntrada" select="
$route" tunnel="yes" />
</xsl:apply-templates>
</xsl:result-document>
</xsl:template>
The Catalog
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
<rewriteURI uriStartString="https://www.bancaonline/banco_santander" rewritePrefix="file:/c:/bancos/santander/" />
</catalog>
Regards
Re: Generate an output string modified by a catalog
Posted: Thu Feb 03, 2022 11:55 am
by Radu
Hi,
When you want to have an XSLT variable which has as value a string literal you need to surround the literal with extra simple quotes like this:
Code: Select all
<xsl:variable name="route" select="'https://www.bancaonline/banco_santander/clientes.xml'" />
Regards,
Radu
Re: Generate an output string modified by a catalog
Posted: Thu Feb 03, 2022 6:51 pm
by FJJCENT
Thanks Radu, now it works, but I see that the catalog only works when using
document
so
<xsl:variable name="route" select="document('https://www.bancaonline/banco_santander/clientes.xml"')" />
is transformed into
file:/c:/bancos/santander/clientes.xml
but
<xsl:variable name="route" select="'http://www.animales/domesticos/europa/perros.xml'" /> is not transformed
and my question is if
document function is allways required for the transformation or there are
other XSL commands or functions that can be used too
for the catalog transformation.
Regards
Re: Generate an output string modified by a catalog
Posted: Fri Feb 04, 2022 9:13 am
by Radu
Hi,
Good question.
I've used in the past quite a lot the capabilities of the document() function to automatically resolve through the XML catalog, but from what I know the XSLT resolve-ur() function does not although maybe it should, I asked a question about this on the Saxonica (XSLT Processor) issues list:
https://saxonica.plan.io/issues/5277
I'm not sure why you want to pass that URL reference through the XML catalog and keep it as a plain string, maybe you can elaborate.
Anyway you could probably do something like this as a workaround:
Code: Select all
<xsl:variable name="abc" select="base-uri(document('http://some/link/here'))"/>
Also some resources about XSLT training:
https://blog.oxygenxml.com/topics/xslt_training.html
Regards,
Radu