|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Selecting an element in xsl sheet
Hi there,
I wanna select the for-each element in the below xsl sheet to write to the attribute select to evaluate an xpath. However when i do this i get "null error" path="/business/id[name='MER']/*" var filterNode = xsl.selectSingleNode("/xsl:stylesheet/xsl:template[@name='main']/xsl:for-each"); filterNode.setAttribute("select", "path"); ANy Ideas please i am really stuck trying to find a way to dynamically evaluate xpath expression and thats the only way i found reasonable. Thanks in Advance <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl aram name="sortby"></xsl aram><xsl:template name="main" match="/"> <html> <body> <h2>ALL RECORDS</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Busines Type</th> <th>Business Name</th> <th>Street Number</th> <th>Street Name</th> <th>Postcode</th> <th>Suburb</th> <th>Region</th> <th>Image</th> </tr> <xsl:for-each select=""> <xsl:sort select="type"/> <xsl:variable name="image"><xsl:value-of select="image"/></xsl:variable> <tr> <td><xsl:value-of select="type"/></td> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="stnumber"/></td> <td><xsl:value-of select="stname"/></td> <td><xsl:value-of select="postcode"/></td> <td><xsl:value-of select="suburb"/></td> <td><xsl:value-of select="region"/></td> <td> <img src="{image}"></img></td> </tr> </xsl:for-each> </table> <form name="print"> <input type="button" value="PRINT" onclick="javascript:window.print()"></input> </form> </body> </html> </xsl:template> </xsl:stylesheet> |
|
#2
|
|||
|
|||
|
If i understand well what you're doing, there's a syntax error in your code:
filterNode.setAttribute("select", "path"); This is wrong, you're passing the string "path" as second parameter.. what you're supposed to do is to path the content of the variable named path, so: filterNode.setAttribute("select", path); looks more appropriate. Let me know if this worked or not ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Selecting an element in xsl sheet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|