Trouble with variable not declared

Having trouble installing Oxygen? Got a bug to report? Post it all here.
graphy
Posts: 2
Joined: Sun Mar 19, 2006 10:09 am

Trouble with variable not declared

Post by graphy »

I just try Oxygen on eclipse with a a project which use lot of xsl:include

Even if the transformation work well whithout any error or warning, Ive got errors in the Problems view : "Variable not declared". But it's normal that these variables aren't declared because the xslt is included in another xslt which contain the variable declaration.

Is it a way to avoid these errors messages ?

Another mystery : I can see nothing in the Browser view wathever the file i edit ... Is there something particular to do for seeing something ?

Thanks
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

Indeed, stylesheets can be invalid by themselves but the same code can be valid when included/imported from other stylesheets. There is not very much you can do about that now, you can eventually use the Clear validation markers action to remove the errors manually.
I rised this issue on the XSL list some time ago and we will probably implement the result of that discussion in the future - allow specifying a main document for a module stylesheet:
http://www.oxygenxml.com/archives/xsl-l ... 00050.html

Best Regards,
George
graphy
Posts: 2
Joined: Sun Mar 19, 2006 10:09 am

Post by graphy »

Hi,

Thank for you answer. When thinking about it, it's logical that the compiler can't know which file will import or include the file which is compiled...

Here is the solution that I use to bypass this trouble :

In the main xslt

Code: Select all


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="include.xsl"/>
<xsl:variable name="filesPath" select="main/@path"/>
<xsl:template match="body">
<a href="{$filesPath-header}{@link}">link from body</a>
<xsl:apply-templates select="header"/>
</xsl:template>
</xsl:stylesheet>
In the included xslt

Code: Select all


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="filesPath-header" select="main/@path"/>
<xsl:template match="header">
<a href="{$filesPath-header}{@link}">link from header</a>
</xsl:template>
</xsl:stylesheet>
It's not very elegant but ... it's work
Post Reply