473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Is this possible from an XSL?

Hello all,
I'm a newbie to the world of XML, XSL stylesheets and transformation
etc. and wonder if the following is possible?

I have an XML file of the following sort and I want to HTML-ize it
using an XSL.

XML:

================================================== ========
<target name="one">
<task>
<message> Some Message Text1 </message>
<message> Some Message Text2 </message>
</task>

<task>
<message> Some Message Text3 </message>
</task>
</target>

<target name="two">
<task>
<message> Some Message Text1 </message>
</task>
</target>

and so on.
================================================== =======

After transformation, in my .html file, I'd like to create a top-area
of just the target names and clicking on the links would get me to
their details (i.e., the tasks and messages info) somewhere down
below.

Something along the lines...

<a href="#TargetOneInfo"> Target One </a>
<a href="#TargetTwoInfo"> Target Two </a>
..
..
..
<a name="TargetOne"> Target One Details </a>
<a name="TargetTwo"> Target Two Details </a>
and so on.

Is it possible to achieve this in XSL?
How do I specify in XSL to collect all 'targets' and put the href tags
around them and similarly put the name tags around the details
section?
Could someone please give me some pointers on how to go about doing
this?

Thanks for your time,
Prabh
Jul 20 '05 #1
1 1066
It's off course possible with XSL. here's one way to do it.

The stylesheet you need looks like this:
(some additional styling can be added with CSS)

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>

<xsl:template match="/">
<html><body>
<p title="targets">
<xsl:for-each select="//target">
<a href="#Task{@name}">Target <xsl:value-of select="@name"/></a><br/>
</xsl:for-each>
</p>
<p title="details">
<xsl:for-each select="//target">
<a name="#Task{@name}">
Target <xsl:value-of select="@name"/> Details</a>
<ul><xsl:apply-templates/></ul>
</xsl:for-each>
</p>
</body></html>
</xsl:template>

<xsl:template match="task">
<li>Task <xsl:value-of select="position()"/>
<ul><xsl:apply-templates/></ul>
</li>
</xsl:template>

<xsl:template match="message">
<li><xsl:value-of select="."/></li>
</xsl:template>

</xsl:stylesheet>

Hope this helps,

Joris Gillis
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
1
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it...
25
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
7
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.