in xsl pattern matching $or$ and $and$ is not working


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: in xsl pattern matching $or$ and $and$ is not working

  1. #1
    kiran Guest

    in xsl pattern matching $or$ and $and$ is not working


    Dear all
    this is the code what i have written please help me

    Here is the XML file

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="familyxsl.xsl"?>
    <famalies>
    <family>
    <mummy>Gita</mummy>
    <daddy>Ram</daddy>
    </family>
    <family>
    <mummy>Rita</mummy>
    <daddy>Raju</daddy>
    </family>
    </famalies>

    Here is the XSL file

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <table border="10">
    <thead><th>mummy</th><th>daddy</th></thead>
    <xsl:for-each select="famalies/family">
    <tr>
    <xsl:attribute name="STYLE">color:
    <xsl:if test="daddy [. $eq$ 'ram'] $or$ mummy[. $eq$ 'Gita']">red</xsl:if>
    <xsl:if test="daddy [. $eq$ 'Raju' $or$ mummy $eq$ 'Rita']">green</xsl:if>
    </xsl:attribute>
    <td><xsl:value-of select="daddy"/></td>
    <td><xsl:value-of select="mummy"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:stylesheet>

    eagerly waiting for reply


  2. #2
    Piya Mahajan Guest

    Re: in xsl pattern matching $or$ and $and$ is not working


    "kiran" <kiran_vja@hotmail.com> wrote:
    >
    >Dear all
    >this is the code what i have written please help me
    >
    >Here is the XML file
    >
    ><?xml version="1.0"?>
    ><?xml-stylesheet type="text/xsl" href="familyxsl.xsl"?>
    ><famalies>
    ><family>
    ><mummy>Gita</mummy>
    ><daddy>Ram</daddy>
    ></family>
    ><family>
    ><mummy>Rita</mummy>
    ><daddy>Raju</daddy>
    ></family>
    ></famalies>
    >
    >Here is the XSL file
    >
    ><?xml version="1.0"?>
    ><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    ><xsl:template match="/">
    ><table border="10">
    ><thead><th>mummy</th><th>daddy</th></thead>
    ><xsl:for-each select="famalies/family">
    ><tr>
    ><xsl:attribute name="STYLE">color:
    ><xsl:if test="daddy [. $eq$ 'ram'] $or$ mummy[. $eq$ 'Gita']">red</xsl:if>
    ><xsl:if test="daddy [. $eq$ 'Raju' $or$ mummy $eq$ 'Rita']">green</xsl:if>
    ></xsl:attribute>
    ><td><xsl:value-of select="daddy"/></td>
    ><td><xsl:value-of select="mummy"/></td>
    ></tr>
    ></xsl:for-each>
    ></table>
    ></xsl:template>
    ></xsl:stylesheet>
    >
    >eagerly waiting for reply
    >



  3. #3
    Piya Mahajan Guest

    Re: in xsl pattern matching $or$ and $and$ is not working


    Try this XSL.. the difference is firstly use xslt rather than xsl and secondly
    remove $ from everywhere.

    Hope it works


    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <table border="10">
    <thead><th>mummy</th><th>daddy</th></thead>
    <xsl:for-each select="famalies/family">
    <tr>
    <xsl:attribute name="STYLE">color:
    <xsl:if test="daddy[. = 'ram'] or mummy[. = 'Gita']">red</xsl:if>
    <xsl:if test="daddy [. = 'Raju'] or mummy[.= 'Rita']">green</xsl:if>
    </xsl:attribute>
    <td><xsl:value-of select="daddy"/></td>
    <td><xsl:value-of select="mummy"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:transform>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center