LISTSERV mailing list manager LISTSERV 16.0

Help for XML-L Archives


XML-L Archives

XML-L Archives


XML-L@LISTSERV.HEANET.IE


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

XML-L Home

XML-L Home

XML-L  November 2002

XML-L November 2002

Subject:

Re: XML with XSLT stylesheet embedded

From:

"G. Ken Holman" <[log in to unmask]>

Reply-To:

General discussion of Extensible Markup Language <[log in to unmask]>

Date:

Sat, 9 Nov 2002 16:52:42 -0500

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (541 lines)

At 2002-11-09 11:06 -0600, MARTIN, TINA wrote:
>Thanks for all the information Ken... here is an example XML document:

Your example revealed a lot, Tina ... there are some basics you need to
know and I'm not confident that any browser supports embedded
stylesheets.  The behaviour you were seeing was just the entire content of
the file as an HTML file without any interpretation of XSL whatsoever.

I moved your stylesheet out of your data file into a standalone instance
and made the following observations.

(1) - no template rules
     - when you are writing a stylesheet that isn't a "simplified
stylesheet", then you at least need a template rule for the root node:
match="/" or a template rule that assumes the built-in one was used

(2) - improper XPath expressions
     - to address nodes in the source node tree, you will need more
complete addresses ... where you had select="MONTHLY_DOWNLOAD_FILE" you
will need select="doc/MONTHLY_DOWNLOAD_FILE"
     - alternatively you could just remove the doc wrapper in the XML
instance and use MONTHLY_DOWNLOAD_FILE as the document element

(3) - accommodating nesting
     - you had sibling for-each statements and the typical approach is to
nest them, though if you only had one MONTHLY_DOWNLOAD_FILE per doc the
answer would have coincidentally been correct

(4) - improper HTML
     - <colgroup> and <col> are for column specifications, not for column data
     - use <td> for a table data cell

I've modified your example and added it below ... hopefully you can see the
nature of some of the changes and decide what to do from here.  I'm sure
what I've done isn't complete, but I think it is enough to point you in the
right direction.

Read up some of the free resources (for examples the FAQ or the free
preview of our XSLT book) and you will learn a few more of the basics.

Future questions should be posted to

   http://www.mulberrytech.com/xsl/xsl-list

If anyone on the list is familiar with browsers that do support embedded
stylesheets, I would be very interested to know which ones have this ability.

I hope this helps.

................. Ken


T:\ftemp>type tina.xml
<?xml-stylesheet href="#style" type="text/xsl"?>
<doc>
         <xsl:stylesheet id="style" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:template match="/">
                 <HTML>
                         <BODY>
                                 <h1>
                                    <b>
                                         <c>Monthly Data Download</c>
                                    </b>
                                 </h1>
                                 <p>Test: <xsl:value-of
select="name(child::*)"/>x</p>
                                 <xsl:for-each
select="/doc/MONTHLY_DOWNLOAD_FILE">
                                         <h2>
                                            <b>Lines Of Accounting for
Period Ending: <xsl:value-of select="PERIOD"/>
                                            </b>
                                         </h2>
                                 <TABLE BORDER="1" bgcolor="yellow"
cellspacing="1" cols="10">
                                   <thead>
                                                 <TR>
                                                         <th>
                                                                 <strong>Business
Day</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Status</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Accounting
Data</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Amount</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Document</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Contract</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Spiin</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Clin</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Reg</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Lot</strong>
                                                         </th>
                                                 </TR>
                                         </thead>
                                         <tbody>
                                           <xsl:for-each
select="/doc/MONTHLY_DOWNLOAD_FILE/ROWSET">
                                                         <TR align="left">

                                                                         <td>
                                                                                 <xsl:value-of
select="BUSINESS_DAY"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="STATUS"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="ACCOUNT_DATA"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="AMOUNT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="DOCUMENT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="CONTRACT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="SPIIN"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="CLIN"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="REGISTER"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="LOT"/>
                                                                         </td>

                                                         </TR>
                                                 </xsl:for-each>
                                         </tbody>
                                 </TABLE>
                               </xsl:for-each>
                         </BODY>
                 </HTML>
               </xsl:template>
         </xsl:stylesheet>
         <MONTHLY_DOWNLOAD_FILE>
                 <PERIOD>PERIOD ENDING 2002/09/30 00:00:00</PERIOD>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>8</STATUS>
                         <ACCOUNT_DATA>AC2134930.SUBHOBJBCNSAAAPAACOSTCD</ACCOUNT_DATA>
                         <AMOUNT>55.55</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>8</STATUS>
                         <ACCOUNT_DATA>2194578.</ACCOUNT_DATA>
                         <AMOUNT>134.34</AMOUNT>
                         <DOCUMENT>NAVYDOCNUMBER</DOCUMENT>
                         <CONTRACT>NAVYCONTRACTNUM</CONTRACT>
                         <SPIIN>NAVYSP</SPIIN>
                         <CLIN>NACL</CLIN>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>6</STATUS>
                         <ACCOUNT_DATA>1754234.</ACCOUNT_DATA>
                         <AMOUNT>34.43</AMOUNT>
                         <DOCUMENT>navdocnbr</DOCUMENT>
                         <CONTRACT/>
                         <SPIIN>123456</SPIIN>
                         <CLIN>6543</CLIN>
                         <REGISTER/>
                         <LOT>AA</LOT>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>8</STATUS>
                         <ACCOUNT_DATA>CC1234567.</ACCOUNT_DATA>
                         <AMOUNT>344.45</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>0</STATUS>
                         <ACCOUNT_DATA>1210809.</ACCOUNT_DATA>
                         <AMOUNT>900</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS/>
                         <ACCOUNT_DATA>VV3134503.</ACCOUNT_DATA>
                         <AMOUNT>199.34</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER>13</REGISTER>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS/>
                         <ACCOUNT_DATA>1224234.</ACCOUNT_DATA>
                         <AMOUNT>-999.99</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER>14</REGISTER>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS/>
                         <ACCOUNT_DATA>2342342.</ACCOUNT_DATA>
                         <AMOUNT>99999.99</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>8</STATUS>
                         <ACCOUNT_DATA>2165464.</ACCOUNT_DATA>
                         <AMOUNT>177.77</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS/>
                         <ACCOUNT_DATA>2108290.</ACCOUNT_DATA>
                         <AMOUNT>88.77</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>4</STATUS>
                         <ACCOUNT_DATA>2325425.</ACCOUNT_DATA>
                         <AMOUNT>77.66</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>8</STATUS>
                         <ACCOUNT_DATA>ACCC2134930.SUBHOBJBCNSAAATTPAACOSTCD</ACCOUNT_DATA>
                         <AMOUNT>123.12</AMOUNT>
                         <DOCUMENT>121423423534587</DOCUMENT>
                         <CONTRACT>ADFKJASDF498273</CONTRACT>
                         <SPIIN>12143</SPIIN>
                         <CLIN>2342</CLIN>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>4</STATUS>
                         <ACCOUNT_DATA>1232234.DFLAJDF09809</ACCOUNT_DATA>
                         <AMOUNT>45454.45</AMOUNT>
                         <DOCUMENT>111121321434234</DOCUMENT>
                         <CONTRACT>345345-38093098</CONTRACT>
                         <SPIIN>039485</SPIIN>
                         <CLIN>2341</CLIN>
                         <REGISTER>07</REGISTER>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>6</STATUS>
                         <ACCOUNT_DATA>1731810.</ACCOUNT_DATA>
                         <AMOUNT>33.33</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>4</STATUS>
                         <ACCOUNT_DATA>3212234.234</ACCOUNT_DATA>
                         <AMOUNT>99.88</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>6</STATUS>
                         <ACCOUNT_DATA>2424234.</ACCOUNT_DATA>
                         <AMOUNT>66.66</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>4</STATUS>
                         <ACCOUNT_DATA>2342314.</ACCOUNT_DATA>
                         <AMOUNT>44.44</AMOUNT>
                         <DOCUMENT/>
                         <CONTRACT/>
                         <SPIIN/>
                         <CLIN/>
                         <REGISTER/>
                         <LOT/>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>0</STATUS>
                         <ACCOUNT_DATA>1721804.11XJ00000161006882DPAPAPA</ACCOUNT_DATA>
                         <AMOUNT>15.33</AMOUNT>
                         <DOCUMENT>111111111111111</DOCUMENT>
                         <CONTRACT>222222222222222</CONTRACT>
                         <SPIIN>333333</SPIIN>
                         <CLIN>4444</CLIN>
                         <REGISTER>05</REGISTER>
                         <LOT>12</LOT>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>0</STATUS>
                         <ACCOUNT_DATA>ACC1721804.11L0OC001600688922DCOSTCODECOST</ACCOUNT_DATA>
                         <AMOUNT>100.55</AMOUNT>
                         <DOCUMENT>111111111111111</DOCUMENT>
                         <CONTRACT>222222222222222</CONTRACT>
                         <SPIIN>333333</SPIIN>
                         <CLIN>4444</CLIN>
                         <REGISTER>05</REGISTER>
                         <LOT>11</LOT>
                 </ROWSET>
                 <ROWSET>
                         <BUSINESS_DAY>2002/09/03 00:00:00</BUSINESS_DAY>
                         <STATUS>6</STATUS>
                         <ACCOUNT_DATA>ACCC1721453.2201OCC14600S0000222DPAAPAACOSTCODECOST</ACCOUNT_DATA>
                         <AMOUNT>22.22</AMOUNT>
                         <DOCUMENT>DOCUMENTNUMBERD</DOCUMENT>
                         <CONTRACT>CONTRACTNUMBERC</CONTRACT>
                         <SPIIN>SPIINS</SPIIN>
                         <CLIN>CLIN</CLIN>
                         <REGISTER>05</REGISTER>
                         <LOT>LO</LOT>
                 </ROWSET>
         </MONTHLY_DOWNLOAD_FILE>
</doc>

T:\ftemp>type tina.xsl
         <xsl:stylesheet id="style" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:template match="/">
                 <HTML>
                         <BODY>
                                 <h1>
                                    <b>
                                         <c>Monthly Data Download</c>
                                    </b>
                                 </h1>
                                 <xsl:for-each
select="/doc/MONTHLY_DOWNLOAD_FILE">
                                         <h2>
                                            <b>Lines Of Accounting for
Period Ending: <xsl:value-of select="PERIOD"/>
                                            </b>
                                         </h2>
                                 <TABLE BORDER="1" bgcolor="yellow"
cellspacing="1" cols="10">
                                   <thead>
                                                 <TR>
                                                         <th>
                                                                 <strong>Business
Day</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Status</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Accounting
Data</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Amount</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Document</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Contract</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Spiin</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Clin</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Reg</strong>
                                                         </th>
                                                         <th>
                                                                 <strong>Lot</strong>
                                                         </th>
                                                 </TR>
                                         </thead>
                                         <tbody>
                                           <xsl:for-each
select="/doc/MONTHLY_DOWNLOAD_FILE/ROWSET">
                                                         <TR align="left">

                                                                         <td>
                                                                                 <xsl:value-of
select="BUSINESS_DAY"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="STATUS"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="ACCOUNT_DATA"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="AMOUNT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="DOCUMENT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="CONTRACT"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="SPIIN"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="CLIN"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="REGISTER"/>
                                                                         </td>
                                                                         <td>
                                                                                 <xsl:value-of
select="LOT"/>
                                                                         </td>

                                                         </TR>
                                                 </xsl:for-each>
                                         </tbody>
                                 </TABLE>
                               </xsl:for-each>
                         </BODY>
                 </HTML>
               </xsl:template>
         </xsl:stylesheet>

T:\ftemp>saxon -o tina.htm tina.xml tina.xsl

T:\ftemp>start tina.htm


--
Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO:
-                             North America:  Feb 3 - Feb 7,2003

G. Ken Holman               mailto:[log in to unmask]
Crane Softwrights Ltd.        http://www.CraneSoftwrights.com/l/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                     Definitive XSLT and XPath
ISBN 0-13-140374-5                             Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1             Practical Formatting Using XSL-FO
Next conference training:                    2002-12-08,03-03,06

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

February 2017
August 2016
June 2016
March 2016
January 2016
July 2014
April 2014
January 2014
July 2013
February 2013
September 2012
August 2012
October 2011
August 2011
June 2011
January 2011
November 2010
October 2010
July 2010
June 2010
March 2010
February 2010
January 2010
November 2009
September 2009
August 2009
July 2009
May 2009
March 2009
December 2008
October 2008
August 2008
May 2008
March 2008
February 2008
January 2008
December 2007
October 2007
August 2007
June 2007
March 2007
January 2007
December 2006
September 2006
July 2006
June 2006
April 2006
February 2006
January 2006
November 2005
September 2005
August 2005
July 2005
June 2005
May 2005
March 2005
January 2005
October 2004
August 2004
July 2004
June 2004
May 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000
January 2000
December 1999
November 1999
October 1999
September 1999
August 1999
July 1999
June 1999
May 1999
April 1999
March 1999
February 1999
January 1999
December 1998
November 1998
October 1998
September 1998
August 1998
July 1998
June 1998
May 1998
April 1998
March 1998
February 1998
December 1997
November 1997
October 1997

ATOM RSS1 RSS2



LISTSERV.HEANET.IE

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager