Problem in test project with Catalog

Here should go questions about transforming XML with XSLT and FOP.
FJJCENT
Posts: 25
Joined: Sun Apr 22, 2018 10:17 pm

Problem in test project with Catalog

Post by FJJCENT »

Hi everybody, with my short experience with Oasis Catalogs I have just created a really simple test in order to understand it's way of working, but inspite of the simplicity it doesn't work and I don't get why, being so simple, could you please have a look, sure tahat you find the reason:

the test start with an initial xls file called iniciador.xsl whic calls two external functions in other xsl files, the first file is imported to the project, and the second is accesde by a http Uri which the Catalog must solve to a file Uri, it's code is the following:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:xs ="http://www.w3.org/2001/XMLSchema"
xmlns:fart="http://www.pepito.es/remoto/Otracarpeta/Segundo/xsl"
xmlns:faux="http://www.tico.com/acceso_llamador">

<xsl:import href="llamador.xsl" />

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

<xsl:variable name="Datos_llamador" select="faux:dato_llamada('1')" />
<xsl:variable name="Datos_Segundo" select="fart:devuelveImporte('Euro')" />

<xsl:template match="/">
<xsl:value-of select="$Datos_llamador" />
<xsl:value-of select="$Datos_Segundo" />
</xsl:template>
</xsl:stylesheet>
- the Oasys Catalog is

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI uriStartString="http://www.tico.com/acceso_llamador"
rewritePrefix="file:///C:/Trabajo/Prueba_completa_XLS/llamador.xsl"/>
<rewriteURI uriStartString="http://www.pepito.es/remoto"
rewritePrefix="file:///C:/Trabajo/Prueba_completa_XLS"/>
</catalog>
- And the referenced file by the Uri is

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:xs ="http://www.w3.org/2001/XMLSchema"
xmlns:fart="http://www.pepito.es/remoto/Otracarpeta/Segundo/xsl"
xmlns:faux="http://www.tico.com/acceso_llamador">


<xsl:function name="fart:devuelveImporte">
<xsl:param name="divisa" as="xs:string" />
<xsl:sequence select="4500" />
</xsl:function>


</xsl:stylesheet>
And I receive the error: SystemID: C:\TRABAJO\Prueba_completa_XLS\Iniciador.xsl
Severity: fatal
Description: Cannot find a matching 1-argument function named {http://www.pepito.es/remoto/Otracarpeta ... lveImporte()
Start location: 13:0


In my understanding the Catalog should convert the uri --> http://www.pepito.es/remoto/Otracarpeta/Segundo.xsl in file:///C:/Trabajo/Prueba_completa_XLS/Otracarpeta/Segundo.xsl" which is the correct location, but it doesn't convert anything and try using the http Uri Why? could you please have a look.

Best Regards
adrian
Posts: 2853
Joined: Tue May 17, 2005 4:01 pm

Re: Problem in test project with Catalog

Post by adrian »

Hi,
In my understanding the Catalog should convert the uri --> http://www.pepito.es/remoto/Otracarpeta/Segundo.xsl in file:///C:/Trabajo/Prueba_completa_XLS/Otracarpeta/Segundo.xsl" which is the correct location, but it doesn't convert anything and try using the http Uri Why? could you please have a look.
It doesn't work that way. In XSL you first need to import the stylesheet, you can't just make references to functions from it via the namespace of the function.
So what you're missing is an import for "Segundo.xsl":

Code: Select all

  <xsl:import href="Segundo.xsl" />
If you want to use the catalog to resolve SystemIDs, you should also have a System entry:

Code: Select all

<rewriteSystem systemIdStartString="http://www.pepito.es/remoto" rewritePrefix="file:///C:/Trabajo/Prueba_completa_XLS"/>
However, you might as well use a relative reference for the import and thus not need the catalog at all.

While it is possible to do so, XML catalogs aren't that frequently used to resolve imports for stylesheets (unless you're importing a well known/public library of XSLs). When working with your own custom XSLs, it's generally good practice to use relative references for imports and keep the stylesheets in adjacent folders.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply