RE: [xsl] Problem accessing nodes from xsl:import

Subject: RE: [xsl] Problem accessing nodes from xsl:import
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 30 Nov 2007 12:32:23 -0000
Personally, I don't like this technique of putting data in the stylesheet at
all. Put it in a separate data.xml file, which makes it accessible from
anywhere.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Aitor San Juan [mailto:asanjuan@xxxxxxxxxxxxxx]
> Sent: 30 November 2007 12:20
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Problem accessing nodes from xsl:import
>
> Hi List,
>
> I'm using Xalan-J from a Unix shell session.
>
> My main XSL file (main.xsl) used to convert an XML file to
> HTML imports another stylesheet (main-loc.xsl) which defines
> some nodes containing texts for localization (i18n). Both
> stylesheets are in the same directory.
>
> --------   main.xsl ---------
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> 	xmlns:local="http://www.mydom.es/2007/HTML/BBI-Miembros";
> 	exclude-result-prefixes="local">
>
> 	<xsl:param name="language"/>
>
> 	<xsl:output method="html" indent="yes"
> omit-xml-declaration="yes"
> 		doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
> 		doctype-system="http://www.w3c.org/TR/html4/loose.dtd";
> 		encoding="ISO-8859-1"/>
>
> 	<xsl:strip-space elements="*"/>
>
> 	<!-- <xsl:include href="main-loc.xsl"/> --> (1) see below
>
> 	<local:footer>
> 		<last-modif lang="en"><![CDATA[Last
> updated:]]></last-modif>
> 		<copyright lang="en"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
>
> 		<last-modif lang="es"><![CDATA[Zltima
> actualizacisn:]]></last-modif>
> 		<copyright lang="es"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
>
> 		<last-modif lang="fr"><![CDATA[Mise `
> jour:]]></last-modif>
> 		<copyright lang="fr"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
> 	</local:footer>
>
> ...
>
> </xsl:stylesheet>
>
>
> --------  main-loc.xsl ---------
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> 	xmlns:local="http://www.mydom.es/2007/HTML/BBI-Miembros";>
>
> 	<local:footer>
> 		<last-modif lang="en"><![CDATA[Last
> updated:]]></last-modif>
> 		<copyright lang="en"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
>
> 		<last-modif lang="es"><![CDATA[Zltima
> actualizacisn:]]></last-modif>
> 		<copyright lang="es"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
>
> 		<last-modif lang="fr"><![CDATA[Mise `
> jour:]]></last-modif>
> 		<copyright lang="fr"><![CDATA[Copyright ) The
> Enterprise]]></copyright>
> 	</local:footer>
> ... (more <local:*> nodes)
> </xsl:stylesheet>
>
> In main.xsl, when I want to access those texts depending on
> the "language" parameter, I do:
>
> <xsl:value-of
> select="document('')/xsl:stylesheet/local:footer/last-modif[@l
> ang=$language]"/>
>
> or
>
> <xsl:value-of
> select="document('')/xsl:stylesheet/local:footer/copyright[@la
> ng=$language]"/>
>
> When the contents of main-loc.xsl are explicitly
> declared/defined in main.xsl, no problem: it works fine.
> However, I've decided to take those out of the main XSL for
> flexibility/modularity reasons. Thus I substituted/replaced
> all the <local:*> nodes with (1), and have put them into
> another .xsl file. Although there is no error message and the
> transformation gets done, it seems as if main.xsl didn't
> *find* the imported nodes.
>
> I suspect this is related to (relative) path, but does
> anybody know what's going on?
> Any hint or suggestion or even another approach would be
> highly appreciated.
>
> Thanks in advance,
> Aitor.
>
>
> ************ LEGEZKO OHARRA / AVISO LEGAL / LEGAL ADVICE
> ************* Mezu honek isilpeko informazioa gorde dezake,
> edo jabea duena, edota legez babestuta dagoena. Zuri zuzendua
> ez bada, bidali duenari esan eta ezabatu, inori berbidali edo
> gorde gabe, legeak debekatzen duelako mezuak erabiltzea
> baimenik gabe.
> --------------------------------------------------------------
> ------------
> Este mensaje puede contener informacisn confidencial, en
> propiedad o legalmente protegida. Si usted no es el
> destinatario, le rogamos lo comunique al remitente y proceda
> a borrarlo, sin reenviarlo ni conservarlo, ya que su uso no
> autorizado esta prohibido legalmente.
> --------------------------------------------------------------
> ------------
> This message may contain confidential, proprietary or legally
> privileged information. If you are not the intended recipient
> of this message, please notify it to the sender and delete
> without resending or backing it, as it is legally prohibited.
> **************************************************************
> ************

Current Thread