 |
| 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
|
|
|
|

April 1st, 2010, 01:33 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Sir,
the error is unknown method position().
|
|

April 1st, 2010, 01:46 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
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
|
|

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

April 1st, 2010, 03:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
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:
|
|
|

April 1st, 2010, 04:00 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 1st, 2010, 04:02 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
>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
|
|

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

April 1st, 2010, 04:34 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Sir,
I run the program but in IE, only table is display with no value in that table.
Regards/Thanks,
Dhrumil
|
|

April 1st, 2010, 04:48 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
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..
|
|

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