Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2010, 05:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your "XML" files are not in fact XML: they have two top-level elements, <def> and <Lineage>, which is not allowed. I'll pretend the <def> element is not there, because it only complicates matters.

Then you can replace this code:

Code:
<xsl:if test="//Lineage/sample_001">
  <tr>
    <td valign="top">
      <p class="intitule">1</p>
    </td>
    <td  width="200">
      <dir class="new"><xsl:value-of select="//Lineage/sample_001/time"/></dir>	
    </td>
with something like this:

Code:
<xsl:for-each select="Lineage/*">
  <tr>
    <td valign="top">
      <p class="intitule"><xsl:value-of select="position()"/></p>
    </td> 
    <td  width="200">
      <dir class="new"><xsl:value-of select="time"/></dir>	
    </td>  
    ... etc ...
(I assume "dir" is another typing mistake for "div", but that's a minor detail).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
dhrumil (April 7th, 2010)
 
Old April 6th, 2010, 01:30 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Please find the needed changes below:
1. Add a version (1.0 or 2.0) attribute to <xsl:stylesheet ...
2. Change xmlns:xsl="http://www.w3.org/TR/WD-xsl" to xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

Find the complete stylesheet (with Mike's ideas) below. Copy the whole below code and paste into your current TP.xsl, and then check:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/REC-html40">
 
<xsl:template match = "/">
<html>
 <head>
  <style type="text/css">
  .entete { color: #fff; font-style: italic; font-weight: bolder; font-size: 13px; font-family: Georgia, "Times New Roman" }
  .new { font-size: 8px; font-family: Verdana, Arial; }
  </style>
 </head>
 <body bgcolor="#dddddd">
 <div>
 <xsl:if test="//Lineage">
 <table border="3" bordercolor="#A9AB87" cellpadding="0" cellspacing="0" width="80%" bgcolor="#eeeeee">
  <tr>
   <td valign="middle" align="center"><br/>
    <table border="3" cellpadding="0" cellspacing="0" width="95%">
     <tr>
      <td valign="top">
      <table border="0" cellpadding="0" cellspacing="2" width="100%" bgcolor="#A9AB87">
      <tr>
       <td>
        <p><span class="entete">Lineage</span></p>
       </td>
      </tr>
      </table>
      <br/>
      <table border="0" cellpadding="0" cellspacing="0" bgcolor="#A9AB99"> 
      <tr>
       <td align="left" width="2">
        <p><span class="entete">No.</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Time</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Date</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">X</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Y</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Z</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">X'</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Y'</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Z'</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Raw</span></p>
       </td>
       <td align="center" width="200">
        <p><span class="entete">Pitch</span></p>
       </td>
       <td align="center" widhth="200">
        <p><span class="entete">Yaw</span></p>
       </td>
       <td align="right" width="150">
        <p><span class="entete">SiderealAngle</span></p>
       </td>
      </tr>
      </table>
      <div style="height:200px; overflow:auto;">
      <table border="0" cellpadding="0" cellspacing="0">
      <xsl:for-each select="//Lineage/*">
      <tr>
       <td valign="top">
        <p class="intitule"><xsl:value-of select="position()"/></p>
       </td>
       <td  width="200">
        <div class="new"><xsl:value-of select="time"/></div> 
       </td>
       <td width="200">
        <div class="new"><xsl:value-of select="date"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="X"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="Y"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="Z"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="X1"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="Y1"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="Z1"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="R"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="P"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="Ya"/></div>
       </td>
       <td>
        <div class="new"><xsl:value-of select="side_angle"/></div>
       </td>
      </tr>
      </xsl:for-each>
      </table>
      </div>
      </td>
     </tr>
    </table>
   </td>
  </tr>
 </table>
 </xsl:if>
 </div>
 </body>
</html>
</xsl:template>
</xsl:stylesheet>
Its because of xmlns:xsl="http://www.w3.org/TR/WD-xsl" you got that "Unknown method. -->position()" error. Try now.
__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
dhrumil (April 7th, 2010)
 
Old April 6th, 2010, 04:27 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>xmlns:xsl="http://www.w3.org/TR/WD-xsl

Sorry I failed to spot that. Until a few years ago that used to be one of the first things I looked for - but I haven't seen anyone make this mistake for a long time. This namespace was used by Microsoft's very first XSLT-like implementation, released in 1998 before the W3C spec came out the following year, and it has been obsolete for at least ten years. The language has many differences from XSLT (the absence of the position() function being one example) and it's impossible to obtain documentation for it any more. Because there is so little information about it, it's unusual these days for beginners to fall into the trap of using it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 9th, 2010, 01:21 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hello 2 all,

Thank you for posting this solution for me. I am getting my output but i want to do some enhancement. I want to create such type of file in which after clicking on some text the table will be show and whenever I click on the same text the table will be hide.

Also I want to run this XML file in Linux. And in Linux is not support IE. So how to run my XML file in Linux operating system.

Please give me suggestion.

Thanks,
Dhrumil
 
Old April 9th, 2010, 03:21 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

a) sounds like you want some javascript UI in your output. This has nothing to do with XSLT.

b) Have you tried running it in Firefox? Either that or move to some command line based XSLT processor (such as Saxon perhaps) that runs on any platform.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 12th, 2010, 10:28 PM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Sir,

a). ok. But i see one xml file in that this kind of function is used and they used xsl:eval for that.

b). yes sir. I tried it in Firefox and also I install the plug-in "xsl result" in Firefox with the hope that the xml file can run in Firefox. But still contain the error - "Error loading stylesheet: Parsing an XSLT stylesheet failed."
Can you just explain how to use this "Saxon" in XML file with a very small example.

Dhrumil.
 
Old April 13th, 2010, 04:43 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

> they used xsl:eval for that

As I explained, xsl:eval is not an XSLT instruction. It is an instruction in an obsolete Microsoft language dating from 1998, which I refer to as WD-xsl. "They" might have been using this language, but you are not.

> Can you just explain how to use this "Saxon"

Saxon doesn't work in the browser, it is a standalone product. The easiest way for someone with no experience to use it is to download kernow from http://kernowforsaxon.sourceforge.net/
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT recursive Additions raafishaafi XSLT 2 January 13th, 2009 11:41 AM
XSLT Loop? kwilliams XSLT 1 June 16th, 2008 06:04 PM
FOR LOOP IN XSLT im_himanshu2004 XSLT 0 October 10th, 2007 02:27 PM
transform in a loop vs recursive template ramarc XSLT 3 April 10th, 2006 04:40 PM
recursive XSLT Help boates XSLT 2 January 11th, 2006 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.