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

Re: Incrementing a Global variable

Subject: Re: Incrementing a Global variable
From: Rajendra S Rawat <rajsrawat@xxxxxxxxx>
Date: Tue, 26 Aug 2003 21:59:40 -0700 (PDT)
xml global variable
Hi! Mukul

Perhaps nobody understood my problem

XSL/XPath have failed to do a trivial thing!!

Here are some more detail...

This is an database(Oracle9i)
generated complex xml, which is validated by some
standard schemas.Which I am transforming to XSL:FO
using XSLT to get a PDF output.

It would be not possible to post 4000 lines complete
xslt code. I've formulated sample files to illustrate
the problem(now I've made it a pure XSL problem and
not a FO problem, but FO Solution is also welcome ):
************************************************

Input XML file:(sample.xml)
---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Students>
      <Student>
            <Name>SAM</Name>
            <TOption>English </TOption>
      </Student>
      <Student>
            <Name>RAJ</Name>
            <TOption>English </TOption>
      </Student>
      <Student>
            <Name>RON</Name>
            <TOption>English </TOption>
      </Student>
      <Student>
            <Name>JON</Name>
            <TOption>German  </TOption>
      </Student>
      <Student>
            <Name>DON</Name>
            <TOption>German  </TOption>
      </Student>
      <Student>
            <Name>MON</Name>
            <TOption>Hebrew  </TOption>
      </Student>
      <Student>
            <Name>GON</Name>
            <TOption>Hebrew  </TOption>
      </Student>
</Students>
**********************************************

PDF/HTML Output:( I'm Getting)
--------------------------
|1 |SAM        |English  |
|--|-----------|---------|
|2 |RAJ        |English  |
|--|-----------|---------|
|3 |RON        |English  |
|--|-----------|---------|
|4 |           |         |
|--|-----------|---------|
|4 |JON        |German   |
|--|-----------|---------|
|5 |DON        |German   |
|--|-----------|---------|
|6 |           |         |
|--|-----------|---------|
|6 |MON        |Hebrew   |
|--|-----------|---------|
|7 |GON        |Hebrew   |
|--|-----------|---------|
|10| Total = 7 |         |
|--|-----------|---------|
|11|           |         |
|--|-----------|---------|
|12|           |         |
|--|-----------|---------| 
|13|           |         |
|--|-----------|---------|
|14|           |         |
|--|-----------|---------|
|15|           |         |
--------------------------
***********************************************

PDF/HTML Output:( I Require)
--------------------------
|1 |SAM        |English  |
|--|-----------|---------|
|2 |RAJ        |English  |
|--|-----------|---------|
|3 |RON        |English  |
|--|-----------|---------|
|4 |           |         |
|--|-----------|---------|
|5 |JON        |German   |
|--|-----------|---------|
|6 |DON        |German   |
|--|-----------|---------|
|7 |           |         |
|--|-----------|---------|
|8 |MON        |Hebrew   |
|--|-----------|---------|
|9 |GON        |Hebrew   |
|--|-----------|---------|
|10| Total = 7 |         |
|--|-----------|---------|
|11|           |         |
|--|-----------|---------|
|12|           |         |
|--|-----------|---------| 
|13|           |         |
|--|-----------|---------|
|14|           |         |
|--|-----------|---------|
|15|           |         |
--------------------------****************************************

XSLT File: (sample.xslt)
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" version="1.0"
encoding="UTF-8" indent="yes"/>
      <xsl:variable name="varRowLimit" select="15"/>
      <xsl:template match="Students">
            <xsl:variable name="Student_Count"
select="count(Student)"/>
            <xsl:variable name="BreakCount"
select="count(Student[not(TOption =
following-sibling::*/TOption)])"/>
            <html>
                  <table >
                        <xsl:for-each
select="Student">
                              <tr>
                                    <td>
                                          <xsl:choose>
                                               
<xsl:when test="position() mod
$varRowLimit=0">
                                                     
<xsl:value-of select="$varRowLimit "/>
                                               
</xsl:when>
                                               
<xsl:otherwise>
                                                     
<xsl:value-of select="(position()  mod
$varRowLimit)"/>
                                               
</xsl:otherwise>
                                         
</xsl:choose>
                                    </td>
                                    <td>
                                         
<xsl:value-of select="Name"/>
                                    </td>
                                    <td>
                                         
<xsl:value-of select="TOption"/>
                                    </td>
                              </tr>
                              <xsl:variable
name="CurrTOption"
select="TOption"/>
                              <xsl:variable
name="NextTOption"
select="following-sibling::*/TOption"/>
                              <xsl:if
test="not(position()=last())">
                                    <xsl:if
test="not($NextTOption=$CurrTOption)">
                                         
<xsl:call-template name="PrintBlankRows">
                                               
<xsl:with-param name="start_count"
select="position()+1"/>
                    From owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx  Wed Aug 27 01:52:05 2003
Received: (from majordom@localhost)
	by biglist.com (8.8.8/8.8.5/BL-2) id BAA22101;
	Wed, 27 Aug 2003 01:52:05 -0400 (EDT)
From: Jarno.Elovirta@xxxxxxxxx
X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0
content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Subject: RE:  Incrementing a Global variable
Date: Wed, 27 Aug 2003 08:51:47 +0300
Message-ID: <E392EEA75EC5F54AB75229B693B1B6A705290442@xxxxxxxxxxxxxxxxxxxxxx>
Thread-Topic:  Incrementing a Global variable
Thread-Index: AcNsWNd+Ca7I3etyQOGEc2PoxT2I4AABeAMg
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
X-OriginalArrivalTime: 27 Aug 2003 05:51:47.0255 (UTC) FILETIME=[4D634470:01C36C5F]
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by biglist.com id BAA22085
Sender: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Precedence: bulk
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
X-MailLoop: 1

Hi,

> Also i have Isolated Problem Page from  Actual output
> which contains multiple pdf pages. This part is
> conditionaly separated from other pdf pages ( which
> are
> further grouped using Muenchian Method)

Could you integrage this approach to your stylesheets?

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:variable name="varRowLimit" select="15"/>
  <xsl:variable name="Student_Count" select="count(Students/Student)"/>
  <xsl:template match="Students">
    <title></title>
    <table>
      <tbody>
        <xsl:apply-templates select="Student[1]"/>
      </tbody>
    </table>
  </xsl:template>
  <xsl:template match="Student" name="Student">
    <xsl:param name="counter" select="1"/>
    <tr>
      <td>
        <xsl:value-of select="$counter"/>
      </td>
      <td>
        <xsl:value-of select="Name"/>
      </td>
      <td>
        <xsl:value-of select="TOption"/>
      </td>
    </tr>
    <xsl:variable name="next" select="following-sibling::Student[1]"/>
    <xsl:choose>
      <xsl:when test="not($next)">
        <tr>
          <td>
            <xsl:value-of select="$counter + 1"/>
          </td>
          <td>
            <xsl:text/>Total = <xsl:value-of select="$Student_Count"/>
          </td>
          <td></td>
        </tr>
        <xsl:call-template name="empty">
          <xsl:with-param name="counter" select="$counter + 2"/>
          <xsl:with-param name="left" select="$varRowLimit - $Student_Count - 3"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="TOption = $next/TOption">
        <xsl:apply-templates select="$next">
          <xsl:with-param name="counter" select="$counter + 1"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="empty">
          <xsl:with-param name="counter" select="$counter + 1"/>
        </xsl:call-template>
        <xsl:apply-templates select="$next">
          <xsl:with-param name="counter" select="$counter + 2"/>
        </xsl:apply-templates>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="empty">
    <xsl:param name="counter" select="0"/>
    <xsl:param name="left" select="1"/>
    <xsl:if test="$left">
      <tr>
        <td>
          <xsl:value-of select="$counter"/>
        </td>
        <td></td>
        <td></td>
      </tr>
      <xsl:call-template name="empty">
        <xsl:with-param name="counter" select="$counter + 1"/>
        <xsl:with-param name="left" select="$left - 1"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

Cheers,

Jarno - Feindflug: Größenwahn (Life Cried Remix)

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.