Forum Moderators: open

Message Too Old, No Replies

Displaying contents of xsl, xml using <a> tag

         

sachinl

10:41 am on Jan 7, 2008 (gmt 0)

10+ Year Member



Hello,

I have 1 XSL which is as follows,
i having 5 <a> tags wich is Home, Company, Products, Customers, ContactUs.
bydefault it shows home tag contents, but i want to display seperate content for each <a> tags(Home, Company, Products, Customers, ContactUs)

so please help me.....

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="website">
<html>
<head>
<title>Web Title</title>
<link href="../CSS/Default.css" rel="stylesheet" type="text/css"></link></head>
<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<a id="Home" target="_self" class="nav1">Home</a>
</td>
<td align="center">
<a id="Company" target="_self" class="nav1">Company</a>
</td>
<td align="center">
<a id="Products" target="_self" class="nav1">Products</a>
</td>
<td align="center">
<a id="Customers" target="_self" class="nav1">Customers</a>
</td>
<td align="center">
<a id="ContactUs" target="_self" class="nav1">Contact Us</a>
</td>
</tr>
</table>
</div>
<div>
<table cellpadding="0" cellspacing="2" width="100%">
<xsl:for-each select="SectionTitles/SectionTitle">
<tr>
<td width="100%" valign="top">
<div>
<b class="TitleHD">
<xsl:value-of select ="TitleName"/>
</b>
</div>
<div>
<ul>
<xsl:value-of select ="Detail"/>
</ul>
</div>
</td>
<td>
<xsl:if test="Img[.!='']">
<img border="0" id="Img">
<xsl:attribute name="SRC">
<xsl:value-of select="Img"/>
</xsl:attribute>
</img>
</xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks,

Sachin.

cmarshall

11:27 am on Jan 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Sachin, and Welcome to WebmasterWorld!

I'm not sure that I understand exactly what it is that you're trying to do.

It looks like you're displaying a navbar, but I don't see how there is any bias towards any of the nav items. I'm also not exactly sure how you determine the contents. Is this some kind of sort filter? I don't see any filtering going on, so I guess the XML comes in already filtered.

sachinl

1:58 pm on Jan 7, 2008 (gmt 0)

10+ Year Member



Hey Thanks cmarshall,

Here, "Home, Company, Products, Customers, ContactUs" is nothing but Header of my page which is in 1st table.

In 2nd table i am showing content.

if i click home link i want to show home content,
if i click Company link i want to show Company content, so on....

but i am not able to do this....

thanks 1s again..

sachin

cmarshall

2:28 pm on Jan 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now I see.

You can do this 3 ways:

1) Send all information in the XML. This is EVERYTHING, including home, company, etc. The XSL can have an <xsl:param... that says what will be displayed, and the XSLT can display only that. The XML does not need to be re-sent, but you need to do a new transform for a newly selected tab.

2) Have the PHP/Java/Whatever pre-sort the XML, so it only sends the information that is necessary for the selected tab. When a new tab is selected, the XML query is re-sent for the new tab.

3) Like 1, send ALL information. However, have the XSLT create JSON objects that will be used in a JavaScript navigation to dynamically switch. This will mean that there will be no new XML dumps or transforms. Everything is already on the browser.

1 is good if you are sending XSLT to the browser. The XML is only transmitted once. However, browser-executed XSLT can have compatibility issues. It is also not efficient for slow internet connections or mobile devices.

2 is probably the most efficient and compatible, as the XSLT can be done on the server. However, if the XML is sent from a remote server that may be slow, then it might not be so responsive. The pages should load fairly quickly. This is a good solution for mobile, slow internet connections or older browsers. If the XML can be very large, then this is the best solution

3 gives a highly responsive user experience. However, it requires a fairly modern browser (it will work on just about all current host browsers, but not so many mobile browsers). It also will result in a lot of data being sent to the browser, so is not so good for slow internet connections.