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

Re: too many columns

Subject: Re: too many columns
From: "Gabi Bucataru" <gabi@xxxxxxxxxxxxxxxxx>
Date: Thu, 24 Oct 2002 10:30:18 -0500
bucataru
Thanks a lot, Jarno & Mike,

Awsome!
However I have 2 questions here:

1.
See,  the thing is that i will never know how many of those A1, A2 elements
(and so on)  I will have. Once it might be only 2, 4, who knows. So is there
a way that I can make the template dynamic? I mean this one (now I have 6
A's there):

<xsl:template match="A1|A2|A3|A4|A5|A6">
    <td valign="top">
    <xsl:attribute name="style">color:#<xsl:choose>
    <xsl:when test="@color">
    <xsl:value-of select="@color" />
    </xsl:when>
    <xsl:otherwise>000000</xsl:otherwise>
    </xsl:choose>;background-color:#<xsl:choose>
    <xsl:when test="@fond">
    <xsl:value-of select="@fond" />
    </xsl:when>
    <xsl:otherwise>FFFFFF</xsl:otherwise>
    </xsl:choose>;</xsl:attribute>
    <xsl:value-of select="." />
    </td>
</xsl:template>

2.
The second question is that I would like to start look into XSLT 1.0... Can
you please point me to a resource to learn that? I would like to make this
move.


Thanks a lot !!!
Gabi.






----- Original Message -----
From: "Mike Brown" <mike@xxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, October 24, 2002 3:03 AM
Subject: Re:  too many columns


> Jarno.Elovirta@xxxxxxxxx wrote:
> > > I have a xml/xsl duet where i would like to render multiple
> > > tables with the
> > > info that is between the <Page></Page> tags as seen in the
> > > XML (source) here
> > > http://65.104.178.73/print.xml
> >
> > For future reference, it would probably be better if you posted a sample
from your source that shows the problem, instead of pointing to a file on
the net, so people won't have to wget it.
>
> There's nothing wrong with posting a URL to the source. It's a not a large
> file at all, but is larger than ought to be posted to the list.
>
> One problem with the source, offhand, is that there are elements named
> 'XMLData' and 'XMLNodeName'. While this doesn't break well-formedness, it
is
> in violation of the XML 1.0 spec, because it starts with 'XML' yet isn't a
> name standardized upon by the W3C. Choose a different name that does not
start
> with 'XML' (case-insensitive).
>
> > > However, my column headers are rendered perfectly fine, but I
> > > have more columns that I need instead of having the first
> > > <Page></Page>table content
> > > in the first table and the second <Page></Page> in the second table.
> > >
> > > It is hard to explain but I guess seeing it will help you understand.
> > >
> > > The stylesheet is here:
> > > http://65.104.178.73/print.xsl
> >
> > Anyhow, it seems that you're using the
Microsoft-XSL-dialect-that-has-nothing-to-do-with-XSLT-1.0. Thus, you should
either ask Microsoft for assistance or e.g. see Microsoft XSL FAQ
<http://www.netcrucible.com/xslt/msxml-faq.htm>, or rewrite you stylesheet
in XSLT 1.0, and come back if you're having problems with that.
>
> I wasn't going to attempt to reproduce the VBScript's functionality, but
it
> looks like most of it wasn't even needed. The following does not use any
> pre-XSLT-1.0-specific constructs, and will probably produce output very
close
> to what was expected. It seems to work in IE, but I can't test with MSXML2
> (IE5.0), myself.
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>
>   <xsl:template match="/">
>     <html>
>       <head>
>         <style type="text/css">
>      p.page {page-break-after: always}
>      body {background-color:#cccccc; margin:0
>            font:MessageBox;
>            font:Message-Box;}
>     .TableBody {background: white;
>        font-family: arial;
>        font-size: 9px}
>     .TableHeading  {border-top-width:1;
>        border-left-width:1;
>        border-bottom-width:1;
>        border-right-width:1;
>        border-right-color:black;
>        border-bottom-color:black;
>        border-style:outset;
>        font-family:verdana;
>        font-size:10px;
>        background-color:#cccccc}
>         </style>
>         <!-- rest of head here -->
>       </head>
>       <body>
>         <xsl:apply-templates select="XMLData/Page" />
>       </body>
>     </html>
>   </xsl:template>
>
>   <xsl:template match="Page">
>     <p class="page">
>       <table style="background: black" cellspacing="1" width="600">
>         <thead>
>           <xsl:apply-templates select="Columns/Column" mode="thead" />
>         </thead>
>         <tbody class="TableBody">
>           <xsl:apply-templates select="People/Person" />
>         </tbody>
>       </table>
>     </p>
>   </xsl:template>
>
>   <xsl:template match="Caption">
>     <xsl:value-of select="." />
>   </xsl:template>
>
>   <xsl:template match="Column" mode="thead">
>     <th nowrap="yes" class="TableHeading">
>       <xsl:apply-templates select="Caption" />
>     </th>
>   </xsl:template>
>
>   <xsl:template match="Person">
>     <tr>
>       <xsl:apply-templates select="Data/*" />
>     </tr>
>   </xsl:template>
>
>   <xsl:template match="A1|A2|A3|A4|A5|A6">
>     <td valign="top">
>       <xsl:attribute name="style">color:#<xsl:choose>
>           <xsl:when test="@color">
>               <xsl:value-of select="@color" />
>           </xsl:when>
>           <xsl:otherwise>000000</xsl:otherwise>
>         </xsl:choose>;background-color:#<xsl:choose>
>           <xsl:when test="@fond">
>               <xsl:value-of select="@fond" />
>           </xsl:when>
>           <xsl:otherwise>FFFFFF</xsl:otherwise>
>         </xsl:choose>;</xsl:attribute>
>       <xsl:value-of select="." />
>     </td>
>   </xsl:template>
>
> </xsl:stylesheet>
>
> If you change the namespace, it should work as XSLT 1.0.
>
> Note that I did circumvent the logic for finding which 'A' element to
process
> (A1, A2, A3, etc.) by looking at the Column specifications. The example
data
> had them all in order. If they will not really be in order, and since
MSXML2
> does not permit the XPath functions that would be needed to sort them,
you'll
> have to ask in an MSXML specific forum.
>
> Anyway, I hope this helps at least with sorting out the colors and number
> of columns, and helps reduce the stylesheet to a more manageable size.
> There was a lot of unnecessary stuff in it. In general, any time you do
>
> <xsl:template match="foo">
>   <xsl:for-each select="bar">
>     ...
>   </>
> </>
>
> you probably could have changed the xsl:apply-templates to select
> "foo/bar", and then made a template that matches bar instead of foo.
>
>    - Mike
>
____________________________________________________________________________
>   mike j. brown                   |  xml/xslt: http://skew.org/xml/
>   denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/
>
>  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

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.