[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xslt filtering question

Subject: RE: xslt filtering question
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Mon, 17 May 2004 12:45:37 -0400
xslt filtering
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.