xsl-list
[Top] [All Lists]

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

2007-11-30 05:32:54

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(_at_)bolsabilbao(_dot_)es] 
Sent: 30 November 2007 12:20
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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[Última 
actualización:]]></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[Última 
actualización:]]></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[(_at_)l
ang=$language]"/>

or

<xsl:value-of 
select="document('')/xsl:stylesheet/local:footer/copyright[(_at_)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 información 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 está 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.
**************************************************************
************

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>