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 September 11th, 2006, 02:17 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL table to HTML

Hi guys,

I am using a XSL to display a XML data.
The output data is in a form of HTML table.The table is dynamically generated through XSL.The data in the table is displaying the store name.
What I want is when I click the store name the data of that particular store should be displayed in another page.But the problem is I cant get the value of the row selected in the table.
Can anybody help me on this

Thanks in advance

 
Old September 11th, 2006, 02:27 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't see that this is an XML/XSLT question, seems more HTML/JavaScript to me. Can you show the source XML, your current XSLT and the desired HTML output that you need?

--

Joe (Microsoft MVP - XML)
 
Old September 11th, 2006, 02:42 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First let me Thank you for ur interest

What i mean is I have a XML file which is formatted into a HTML table form using a XSL file.
The display is exactly what I need.But the problem is when user selects a row of table how can i know which row the user has selected.
Here is the part of the XSL file.

<html>
<h2><medium>Store Details</medium></h2>
<table border="2" align="center">
<tr bgcolor="pink">
<th align="left">Store Name</th>
<th align="left">Store Address</th>
</tr>
<xsl:for-each select="NewDataSet/tbl">

<tr >
<td align="left"><xsl:value-of select="Store"/></td>
<td align="left"><xsl:value-of select="Address"/></td>
<td>

 
Old September 11th, 2006, 03:22 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you need to add an onclick to the table row, something like:
Code:
<tr onclick="alert('{Store}');">
<td align="left"><xsl:value-of select="Store"/></td>
<td align="left"><xsl:value-of select="Address"/></td>
<td>
Obviously your actual onclick will probably call a custom function rather than alert, alternatively turn the Store cell into a link:
Code:
<tr >
<td align="left"><a href="pathToStorePage?store={Store}"><xsl:value-of select="Store"/></a></td>
<td align="left"><xsl:value-of select="Address"/></td>
<td>
If you try these examples and you're still struggling then post the original XML and the complete stylesheet.

--

Joe (Microsoft MVP - XML)
 
Old September 11th, 2006, 03:53 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,

Thank you very very much.
It works absolutely fine the way I wanted.If I do have any problems regarding the same I will let you know.
Can i have ur email ID if u dont mind?

Thanks once again for all ur help..!

 
Old September 11th, 2006, 04:01 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I'm glad I could help. I rarely answer problems by email unless I'm being paid ;)

--

Joe (Microsoft MVP - XML)
 
Old September 11th, 2006, 04:12 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok joe as u say

I have one last doubt.I will be very very glad if u can help me in this to.
Now since I have the value of the store is there any way that can pass the value back to the web page I mean can I tk the value into a variable on the web page.

Thanks in advance.



 
Old September 11th, 2006, 04:27 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Basically like this, assuming Store's parent is the context node:
Code:
var sStore = "<xsl:value-of select="Store"/>";
But to really answer I'd need to see your desired output and XML input.

--

Joe (Microsoft MVP - XML)
 
Old September 11th, 2006, 06:32 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,
This is the XML file.I hv already shown u the xsl file.

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <tbl>
    <Store>Eric the Read Books</Store>
    <Address>788 Catamaugus Ave.</Address>
    <City>Seattle</City>
    <State>WA</State>
    <Zip>98056</Zip>
  </tbl>
  <tbl>
    <Store>Barnum</Store>
    <Address>567 Pasadena Ave.</Address>
    <City>Tustin</City>
    <State>CA</State>
    <Zip>92789</Zip>
  </tbl>
  <tbl>
    <Store>News &amp; Brews</Store>
    <Address>577 First St.</Address>
    <City>Los Gatos</City>
    <State>CA</State>
    <Zip>96745</Zip>
  </tbl>
  <tbl>
    <Store>Doc-U-Mat: Quality Laundry and Books</Store>
    <Address>24-A Avogadro Way</Address>
    <City>Remulade</City>
    <State>WA</State>
    <Zip>98014</Zip>
  </tbl>
  <tbl>
    <Store>Fricative Bookshop</Store>
    <Address>89 Madison St.</Address>
    <City>Fremont</City>
    <State>CA</State>
    <Zip>90019</Zip>
  </tbl>
  <tbl>
    <Store>Bookbeat</Store>
    <Address>679 Carson St.</Address>
    <City>Portland</City>
    <State>OR</State>
    <Zip>89076</Zip>
  </tbl>
</NewDataSet>

U hd said that I shud use this

var sStore = "<xsl:value-of select="Store"/>";

but i dont know hw to implement this.I mean hw to tk that value into a variable on a web form.I am using ASP.NET scripting in VB.
I know I am asking for spoon feeding but I will be gratefull if u jst clear this doubt.

Regards.



 
Old September 11th, 2006, 06:38 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Sorry I don't understand, waht exactly is the output you want given that XML file?

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
very urgent:cals table to indesign table using xsl franklinclinton XSLT 1 December 16th, 2009 03:48 PM
Transform html table to add ids/headers using xsl kapy_kal XSLT 2 February 21st, 2007 10:12 AM
xml to html with xsl boblavinsky XSLT 4 January 5th, 2007 05:30 AM
HTML to PDF via XSL-FO NEO1976 XSLT 2 September 8th, 2006 06:47 AM
Re: Dynamic html tables with xsl? purple XSLT 0 November 2nd, 2005 12:01 PM





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