Re: [xsl] variable comparison

Subject: Re: [xsl] variable comparison
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 18 Jan 2001 14:05:48 -0700 (MST)
kapil wrote:
> the problem is that if in database if in project field 
> if there are more or three same name projects then in
> report i want single repeated name(means project name)
> in report and the details of all repeated projects in a order.
> means it needs variable comparison and after comparison
> i need ther records in order 

XSLT is generally for XML-to-XML conversion. When you speak of databases,
fields and reports, you are not talking about XML directly. To answer
your question, we will need to see your XML, and an example of the
output you want.

Your question sounds very much like a grouping FAQ, but the requirement
of only doing the grouping when there are 3 of the same name, rather than
2, makes it much more complicated. Is it really necessary?

Let's say you have XML like this:

<?xml version="1.0" encoding="utf-8"?>
   <project id="p1">
   <project id="p2">
   <project id="p3">

And you want to produce output that is an HTML fragment like this:


Then you would need a stylesheet like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl=""; version="1.0">

        <xsl:output method="html" indent="yes"/>

        <xsl:template match="projects">
           <xsl:for-each select="project/project_name[not(. = preceding::project_name)]">
                 <xsl:value-of select="."/>
                 <xsl:for-each select="/projects/project[project_name = current()]/record">
                       <xsl:value-of select="."/>


Re: variable comparison,

How to write a comparision of 2 objects represented by variables is
just something like

  $var1 = $var2

Whether this evaluates to true or false depends on what type of objects
$var1 and $var2 represent. The operator (=, !=, <, <=, >, >=) also
affects the outcome.

   - Mike
Mike J. Brown, software engineer at            My XML/XSL resources: in Denver, Colorado, USA    

 XSL-List info and archive:

Current Thread
  • [xsl] variable comparison
    • kapil - Wed, 17 Jan 2001 12:28:48 +0530
      • <Possible follow-ups>
      • kapil - Thu, 18 Jan 2001 14:46:08 +0530
        • Mike Brown - Thu, 18 Jan 2001 14:05:48 -0700 (MST) <=