Subject: RE: [xsl] xslt filtering question From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx> Date: Mon, 17 May 2004 12:45:37 -0400 |
The problem is that you are only looking at the first occurrence of fieldinfo node. You need to change to a document wide match or you need to do a for-each select="xml/resultset/resultinfo/fieldinfo" and then do your logic. Here is an example of the template based pattern matching: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="xml/resultset/resultinfo/fieldinfo"> <xsl:choose> <xsl:when test="contains(@permissions, 'w')"> <a> <xsl:attribute name="href">http://url</xsl:attribute> Edit </a> </xsl:when> <xsl:otherwise> Edit </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Hope this helps. Regards, Kenny Akridge -----Original Message----- From: davekennedy@xxxxxxxxxxxx [mailto:davekennedy@xxxxxxxxxxxx] Sent: Monday, May 17, 2004 11:31 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] xslt filtering question Hey, I'm having trouble writing an expression to match any occurance of 'w' in a 'permission' attribute within a block of xml. There can be n-many 'fieldinfo' elements, and if any has a permissions attribute with a 'w' in it, I need to take one action, and another if there are no 'w's. In the code snippet below the xml block, the xpression im feeding 'contains' isnt properly written, I'm fairly new and having trouble with it, any help would be appreciated. <xml> <resultset> <resultinfo> <fieldinfo displayname="" name="userid" permissions=""/> <fieldinfo displayname="" name="username" permissions="rw"/> <fieldinfo displayname="" name="password" permissions="r"/> <fieldinfo displayname="" name="userlevel"permissions="rw"/> </resultinfo> .. </xml> <xsl:choose> <xsl:when test="contains(/xml/resultset/resultinfo/fieldinfo/@permissions, 'w')"> <a> <xsl:attribute name="href">http://url</xsl:attribute> Edit </a> </xsl:when> <xsl:otherwise> Edit </xsl:otherwise> </xsl:choose> --- David Kennedy Program Manager, Alescere LLC. 630.968.8950 x311 Find us on the web at http://www.alescere.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xslt filtering question, davekennedy | Thread | [xsl] copying empty svg nodes (no c, ah49 |
RE: [xsl] killing xslt, Pieter Reint Siegers | Date | [xsl] copying empty svg nodes (no c, ah49 |
Month |