|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to change xsl:param from a javascript function or
I have taken on a project of reformatting the backend of a webpage. More or
less just trying to find out what XML and XSL are all about. So, I am still
new at some of this. I want the data to be stored in an xml file, but
accessed via the web. My XML is something like this.
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="myXSL.xsl"?> <company> <affiliate> <title>Affiliate Title</title> <location> <title>Location Titles</title> <equipment> <title>First Equip Title</title> <login>admin</login> <pass>admin</pass> <enable>admin</enable> <mfg>Cisco</mfg> </equipment> .... //More Equipment </location> ... // More Locations </affiliate> ... // More Affiliates </company> I want my page to initially be blank with only a Heading and a list of the Alphabet. If you click on the Alphabet, the page should list the Affiliates/Title starting with the corresponding letter. I have this working using the DOM only in Firefox, but XSL allows the code to look much cleaner and simpler to me. I have a parameter that I can hard code and this works on IE and Firefox (my main concerns). Suppose the parameter is 'M', then all the 'M' affiliates show up in tables. I want this parameter to be selectable and not just hardcoded. Here is most of my XSL file. <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited with XML Spy v4.2 --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/">
<html>
<head><title>Test Page</title></head>
<body>
<h1><center>Setup</center></h1>
<center>
<a href="javascript:void(0)">A</a>|
<a href="javascript:void(0)">B</a>|
<a href="javascript:void(0)">C</a>|
</center>
<xsl:call-template name="loadTables">
<xsl:with-param name="letter" select="'M'" />
</xsl:call-template>
</body>
</html>
</xsl:template><xsl:template name="loadTables"> <xsl:param name="letter" select="''" /> <xsl:for-each select="company/affiliate"> <xsl:if test="translate(substring(title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') = $letter"> <h2><center><xsl:value-of select="title" /></center></h2> <xsl:for-each select="location"> <center><table border="1" align="center" bgcolor="#c0c0c0" frame="border"> <thead> <tr> <th colspan="5" bgcolor="#99ccff"><tt><xsl:value-of select="title" /></tt></th> </tr> <tr> <td>Title</td> <td>Login</td> <td>Password</td> <td>Enable</td> <td>Manuf.</td> </tr> </thead> <tbody> <xsl:for-each select="equipment"> <tr> <td width="175" bgcolor="#DCDCDC"><tt><center><xsl:value-of select="title" /></center></tt></td> <td width="175" bgcolor="#DCDCDC"><tt><center><xsl:value-of select="login" /></center></tt></td> <td width="175" bgcolor="#DCDCDC"><tt><center><xsl:value-of select="pass" /></center></tt></td> <td width="175" bgcolor="#DCDCDC"><tt><center><xsl:value-of select="enable" /></center></tt></td> <td width="175" bgcolor="#DCDCDC"><tt><center><xsl:value-of select="mfg" /></center></tt></td> </tr> </xsl:for-each> </tbody> </table></center> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> I have had a hard time finding any helpful sites that incorporate this type of setup. I would like to stick with javascript as the scripting language or either some other XSL functions. I have tried passing the parameters through the URL, and by call-templates from a javascript function. There is something I am missing and I cannot find it?..Any help would be nice. -daniel.
|
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
|

Cart








