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

RE: Indifferenct behavoiur For XSL transform

Subject: RE: Indifferenct behavoiur For XSL transform
From: Hiren Shah <Hshah@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Nov 2002 10:52:59 +0530
child behavoiur
Thankx Vasu,
          I am going thru your suggestion.As per your suggestion I am
reviewing my current Xml format.

-----Original Message-----
From: Vasu Chakkera [mailto:vasucv@xxxxxxxxxxx]
Sent: Monday, November 25, 2002 10:40 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Indifferenct behavoiur For XSL transform

HI Hiren.

Is your XML decided?? because this doesnt look very structured to me.You are
giving columns and rows in a different element set. You requirement tells me
that  for example
"Gross" and "9 Million " are like name value pair . Your XML has these
information loosly held. when it was supposed to be together.
A better design ( if your xml is not decided ) would be,
<?xml-stylesheet type="text/xsl" href="CompetitorReport.xsl"?>
 <Header type = "reportheader">
  <Title>Corporate Info</Title>
    <competetor name = "competetor1">
     <gross>9 Million</gross>
     <net>9 Million USD </net>
    <competetor name = "competetor2">
     <gross>xx Million</gross>
     <net>xxx Million USD </net>
  <Footer type = "pageCount">
  Page X of Y
  <Footer type = "copyright">copyright</Footer>

The XML should contain as much information about the business as possible.
Your XML looks more HTML biassed.In the above XML , I have added one more
competetor2 to make things clear.
For the above XML , the XSL to produce your desired output will be..
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 <xsl:template match="Report">
   <h1 align="center">
    <xsl:value-of select="Header"/>
   <table border="0" width="75%" align="center">
     <th bgcolor="red" align="left" colspan="2">
      <xsl:value-of select="Body/Title"/>
       <th bgcolor="silver" align="left">
        Company Financials
       <th bgcolor="silver" align="left">
        <xsl:value-of select="@name"/>
       <xsl:for-each select="*">
         <th align="left">
          <xsl:value-of select="name()"/>
         <th align="left">
          <xsl:value-of select="."/>
   <table border="0" width="75%" align="center">
    <xsl:for-each select="Footers/Footer">
      <th align="center">
       <xsl:value-of select="."/>

This would print the HTML as you wanted.

If however you wanted to stick to your XML , Then
Do the following Changes
 Changes to your XSL :
1. First Template Match  "Report" instead of "/"
2. Change the line
<xsl:value-of select="//Header/Row/Column[@type]"/>
to <xsl:value-of select="Header/Row/Column[@type]"/>
( // would make the processor to search in the entire document )
3. Change the line <xsl:apply-templates select="//RowSet" /> to
<xsl:apply-templates select="Body/RowSet" />
( Your context node is Report. So match Body/Rowset. )
4. Change the line<xsl:apply-templates select="//Footer" />to
<xsl:apply-templates select="Footer" />
( You dont need a "//" here.)
to <br/><hr/><br/>
( you dont need to do <br></br> u can have  an empty element <br/>
6. line 43: Change <xsl:value-of
select="count(//RowSetHeader/Column)"></xsl:value-of> to
<xsl:value-of select="count(/RowSetHeader/Column)"></xsl:value-of>
7. line 47
Change <xsl:apply-templates select="child::*"/> to
<xsl:apply-templates select="RowSetBody"/>
You only need to match the child element called RowSetBody not the entire
child elements.
This is why the Title was getting printed again.
8. Line 50 Change
<xsl:template match="RowBody"> to
<xsl:template match="RowSetBody">
There is no RowBody Element in the XML file.

Changes 1,2,3,4,5 and 6 are to make your XSL efficient .
Changes 7,8 are to make your XSL work

Thaz it. It will work. I havent taken a deep look at the internals of how
you have dealt with getting the data onto HTML ..But these were the apparent
But as i had said before, Your XML doesnt show up data in a structured way.
This even causes an inefficient XSL. So If possible change your XML .
Gurus here may find more errors .I went as long as my patience took me ;)
Hope this helps.

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

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

Current Thread


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.
First Name
Last Name
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.