This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

<xsl:import> / <xsl:include> Q


Hi,

I have a design Q on how to implement the <xsl:import>/<xsl:include> in my
XSL. The situation is as following.

I have 10 different XSL files (not necessarily in the same dir). All files
use some common Javascript when rendered as HTML. I have written a XSL for
the Javascript as follows:

MainJS.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="config" select="document('config.xml')/MESSAGE/CONFIG"
/>

<xsl:template match="/">
     <head>

<script language="Javascript"><![CDATA[<!--

var fileserver = "]]><xsl:value-of select="$config" /><![CDATA[";

...

several JS functions (common to all the XSL files...) ... I use the
variable *fileserver* within my JS here.

//-->
]]>
</script>
</head>
</xsl:template>
</xsl:stylesheet>


Similarly, I have another JS.xsl with other functions common to only 3 of
the 10 XSL files mentioned above.

Now, here is an example of one of the XSL files that uses MainJS.xsl

Test1.xsl

<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="MainJS.xsl" />

     <xsl:template match="/">
          <html>
          <head>
          <script language="Javascript"><![CDATA[<!--
//reference to the same variable defined in MainJS.xsl

var fileserver = "]]><xsl:value-of select="$config" /><![CDATA[";

...some customized additional JS only for this file...I use the variable
*fileserver* within my JS here.
...
//-->
]]>
</script>
</head>

<body>

more XSLT processing...

</body>
</html>
</xsl:template>
</xsl:stylesheet>

Now, here is an example of one of the XSL files that uses both MainJS.xsl
and JS.xsl

Test2.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="MainJS.xsl" />
<xsl:include href="JS.xsl" />

     <xsl:template match="/">
          <html>
          <head>
          <script language="Javascript"><![CDATA[<!--
//reference to the same variable defined in MainJS.xsl

var fileserver = "]]><xsl:value-of select="$config" /><![CDATA[";

...some customized additional JS only for this file...I use the variable
*fileserver* within my JS here.
...
//-->
]]>
</script>
</head>
<body>

more XSLT processing...
</body>
</html>
</xsl:template>
</xsl:stylesheet>


The problem I am having with this design is that the <xsl:include> does not
work. Both MainJS.xsl and JS.xsl are in the same directory. What am I
missing? ANy help is appreciated.

Thanks,

Maulik


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]