[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: <xsl:import> / <xsl:include> Q
Thanks a bunch for your help. This works! However, I am greedy and want to make this as generic as possible. In the <xsl:include> statement, I want to pass the href as an <xsl:attribute> and thereby generate the URL dynamically depending on how the user got there. Here is the sample XSL: <xsl:stylesheet version="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name="config" select="document ('http://sdangel03/com/energytrading/net/tms/TMSconfig.xml')/MESSAGE/CONFIG" /> <xsl:include><xsl:attribute name="href"><xsl:value-of select="$config" />Read/MainJS.xsl</xsl:attribute></xsl:include> <xsl:template match="/"> <html> <head> <xsl:call-template name="MainJS" /> ....more customized JS... </head> <body> ... </body> </html> </xsl:template> </xsl:stylesheet> Can I do this? I ran it against saxon and it gave the following error: At xsl:include on line 3 : Element must have a "href" attribute I also tried to use the concat() function within href and that also gave me an error like the following: <xsl:include href="concat($config,'Read/MainJS.xsl')" /> I am not sure what I am trying to do can be done. Any help is appreciated. Maulik Jeni Tennison <mail@xxxxxxxxxxxxxxxx>@mulberrytech.com on 11/14/2000 04:13:24 AM Please respond to xsl-list@xxxxxxxxxxxxxxxx Sent by: owner-xsl-list@xxxxxxxxxxxxxxxx To: mxmodi@xxxxxxxxxxxxxxx cc: xsl-list@xxxxxxxxxxxxxxxx Subject: Re: <xsl:import> / <xsl:include> Q Maulik, > I have a design Q on how to implement the <xsl:import>/<xsl:include> in my > XSL. I think that you've misunderstood how xsl:import/xsl:include work. xsl:import and xsl:include are about using templates (and other constructs) defined in one stylesheet within another stylesheet. You seem to be talking about importing Javascript functions embedded in HTML in one stylesheet into another stylesheet: that's something that XSLT can't do automatically, because as far as XSLT is concerned Javascript functions are just a piece of text, nothing more. The best solution to your problem is probably to have an external Javascript file and recast the functions so that they take as arguments the various information that you need to pass into them and that you are currently coding within the XSLT. For example: --- MainJS.js --- function usesFileserver(fileserver) { ... } --- and in your XSLT: usesFileserver('<xsl:value-of select="$config" />') If the Javascript is so dependent on XSLT variables that this is impossible, you should probably have a named or moded template within MainJS.xsl that includes the text representing certain Javascript functions whenever it is called. For example: <xsl:template match="insertMainJS"> ... var fileserver = "<xsl:value-of select="$config" />"; ... </xsl:template> Then, import this MainJS.xsl into whichever other stylesheets need this bit of code, and at the point where the code needs to be introduced, call the template: <xsl:include href="MainJS.xsl" /> <xsl:template match="/"> <html> <head> <script language="Javascript"> <!-- standard Javascript --> <xsl:call-template name="insertMainJS" /> <!-- customised Javascript --> ... </script> </head> <body> ... </body> </html> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|