[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Displaying one section of XML file at a time -- p

Subject: Re: Displaying one section of XML file at a time -- posting again
From: Gowri Ratakonda <gratakonda@xxxxxxxxx>
Date: Mon, 27 Mar 2006 14:27:20 -0800 (PST)
xml xlt
--- Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:
> The easiest way to figure out how to do it is to 
> start by mocking up a 
> functioning HTML/Javascript page with the behavior,
> and then to 
> determine how to write the XSLT to generate it.
> 
> We can help with the second part,  I'd 
> recommend looking in an HTML or Javascript forum to
> find your 
> example, and then coming back if you can't figure
> out how to compose XSLT to create it. 

Wendell, Jon,
Sorry to bother you, but have been working on this one
for a few days and couldn't make it work in XSLT. The
display/hide function works well in the
HTML/Javascript example page that I built, but having
problems in XLT. The problem is that it displays only
one table.
Will appreciate if you could take a look at my
XML/XSLT/JS code and let me know what is missing or
where I am going wrong.

My XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>

<catalog>
<cd id="1">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
<year>1985</year>
</cd>
<cd id="2">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
---------------------------------------------------------
My XSLT style sheet looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:template match="/">

<html>
<head>
<script type='text/javascript'
src="expand.js"></script>
</head>

<body>
<h2>My CD Collection</h2>
<xsl:apply-templates select="catalog/cd"/>
</body>
</html>
</xsl:template>

<xsl:template match="cd">
<xsl:variable name="id" select="@id"/>
<h2>
<a href='javascript:void(0);' onClick="toggle('$id')">
<xsl:value-of select="title"/>
</a>
</h2>

<div style="display:none" id="$id">
<table border="1">
<tr>
<th>Artist</th>
<th>Price</th>
<th>Year</th> 
</tr>

<tr>
<td> <xsl:value-of select="artist"/> </td>
<td> <xsl:value-of select="price"/> </td>
<td> <xsl:value-of select="year"/> </td>
</tr>
</table>
</div>
</xsl:template>

</xsl:stylesheet>
---------------------------------------------------

Here is my JavaScript function:

// Show/hide document sections

function toggle(currentVdd) {
 if (document.getElementById){
	 thisTable =
document.getElementById(currentVdd).style;
   if(thisTable.display == "block"){
		 thisTable.display = "none"
   }
	 else{
		 thisTable.display = "block"
   }
	 return false
 }else{
  return true
 }

}
----------------------------------------------------

Thanks,
Gowri



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.