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 1st, 2010, 01:33 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Sir,
the error is unknown method position().
 
Old April 1st, 2010, 01:46 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

How do you run the xslt code. Which processor do you use. If possible post your whole xslt code (if small). We shall try to find the actual error.
You can call me Rummy.
__________________
Rummy
 
Old April 1st, 2010, 02:48 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Sir,
I am totally new in XML and XSLT world. First of all, I write my code in simple notepad file and store it as a .xml extension. Similar thing i am doing with my XSLT sylesheet. And then in the Internet Explorer, I run my xml file.

Is there any special software ya command to run the xslt code?

Regards/Thanks,
Dhrumil
 
Old April 1st, 2010, 03:17 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

With the below xml sample
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="Test.xsl" type="text/xsl"?>
<Lineage>
   <sample_001>
      <time>06:03:09.750000</time>
      <date>2009/05/26</date>
      <X>4025.0784</X>
      <Y>4488.9818</Y>
      <Z>3925.5985</Z>
      <X1>3.6739</X1>
....
</Lineage>
and input xslt code (Test.xsl)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output  method="html"/>
<xsl:template match="Lineage">
<html><body>
<table border="1">
<tr><td>Samples No.</td><td>Time</td><td>Date</td><td>X</td><td>Y</td><td>Z</td><td>X1</td><td>Y1</td><td>Z1</td><td>R</td><td>P</td><td>Ya</td><td>Side Angle</td></tr>
<xsl:for-each select="*">
<tr>
<td><xsl:value-of select="position()"/></td>
<xsl:for-each select="*">
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I could view the required output, when I open the xml file in IE.
__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
dhrumil (April 1st, 2010)
 
Old April 1st, 2010, 04:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The method is called position() not Postition().

(As a programmer, you really can't afford to be so careless with your spelling)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 1st, 2010, 04:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>And then in the Internet Explorer, I run my xml file.

Trying to develop and debug XSLT code using nothing but a text editor and a browser is the worst possible thing to do for a beginner. It's OK as a deployment environment, but hopeless for development and diagnostics. Get yourself a proper development tool like Oxygen or Stylus Studio.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 1st, 2010, 04:16 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thank you Michael Sir for suggestion.
 
Old April 1st, 2010, 04:34 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Sir,

I run the program but in IE, only table is display with no value in that table.

Regards/Thanks,
Dhrumil
 
Old April 1st, 2010, 04:48 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Thats why I asked yo to post your xslt code. Please post it.
__________________
Rummy

Last edited by mrame; April 1st, 2010 at 04:52 AM..
 
Old April 1st, 2010, 05:33 AM
Authorized User
 
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Post

Rummy Sir,

I used the same code as you given to me. I create a new XML and XSLT for this only. In this files I put only this informations and then run my xml file. If you the code then i will give you.

XML file: TP.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="Test.xsl" type="text/xsl"?>
<Lineage>
   <sample_001>
      <time>06:03:09.750000</time>
      <date>2009/05/26</date>
      <X>4025.0784</X>
      <Y>4488.9818</Y>
      <Z>3925.5985</Z>
      <X1>3.6739</X1>
      <Y1>3.6666</Y1>
      <Z1>8.2536</Z1>
      <Side_angle>145.3256</Side_angle>
   </sample_001>
   <sample_002>
.
.
.
</Lineage>
XSLT file: TP.xsl
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output  method="html"/>
<xsl:template match="Lineage">
<html><body>
<table border="1">
<tr><td>Samples No.</td><td>Time</td><td>Date</td><td>X</td><td>Y</td><td>Z</td><td>X1</td><td>Y1</td><td>Z1</td><td>R</td><td>P</td><td>Ya</td><td>Side Angle</td></tr>
<xsl:for-each select="*">
<tr>
<td><xsl:value-of select="position()"/></td>
<xsl:for-each select="*">
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>





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.