473,406 Members | 2,378 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,406 software developers and data experts.

XLM & XSL - Links

Hi!

Working with only one xml file and one xsl, is it possible to make a link
through xsl to another tag in the same xml file?

Eg: i'm displaying the contents of a tag in a sinlge webpage. I want to make
a link to display only the contents of another tag.

Is it possible? Do you know where i can find examples?

Thx in advance!
Nov 12 '05 #1
6 1714
Paulo Guedes wrote:
Working with only one xml file and one xsl, is it possible to make a link
through xsl to another tag in the same xml file?

Eg: i'm displaying the contents of a tag in a sinlge webpage. I want to make
a link to display only the contents of another tag.

Is it possible? Do you know where i can find examples?


It's not clear what excatly do you mean. Elaborate please, some small
sample could help a lot.

btw, when programming in XSLT, forget about tags and think in nodes and
trees.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
Nov 12 '05 #2
I have a XML doc that looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xml" href="um.xsl"?>
<?xml-stylesheet type="text/xsl" href="um.xsl"?>
<MCI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schema.xsd">
<PAGE ID="INTRO">
<TITLE>Bla Bla</TITLE>
<BODY>Bla Bla</BODY>
</PAGE>
<PAGE ID="OBJECTIVES">
<TITLE>Bla Bla</TITLE>
<BODY>Bla Bla</BODY>
</PAGE>
<PAGE ID="COURSES">
<TITLE>Bla Bla</TITLE>
<BODY>Bla Bla</BODY>
</PAGE>

And XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="page-id" match="PAGE" use="@ID"/>
<xsl:output method="html"/>

<!--the first time, i load the page with contents of page id = intro-->

some html
<xsl:value-of select="key('page-id','INTRO')/TITLE"/>
some html
<xsl:value-of select="key('page-id','INTRO')/BODY"/>
some html

<!--now, i want to make a link to load another tag conter - objectives,
something like: (obsiously, it doesn't work....)-->

some html
<a href="#{'OBJECTIVES'}">
<xsl:value-of select="key('page-id','OBJECTIVES')/TITLE"/>
</a>

<!--the intention: pass the 'OBJECTIVES' parameter and load the tag
indicated by parameter, or something like that.. i know i sound a bit
confused, but i only started working with xml a very short time ago. Thx
for help-->

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Paulo Guedes wrote:
some html
<a href="#{'OBJECTIVES'}">
<xsl:value-of select="key('page-id','OBJECTIVES')/TITLE"/>
</a>

<!--the intention: pass the 'OBJECTIVES' parameter and load the tag
indicated by parameter, or something like that.. i know i sound a bit
confused, but i only started working with xml a very short time ago. Thx
for help-->


1. Declare parameter:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="page-id" match="PAGE" use="@ID"/>
<xsl:output method="html"/>
<xsl:param name="linkMe"/>
2. Pass parameter value (see XsltArgumentList class) at runtime.
3. Create link:
<a href="#'{$linkMe}'">
<xsl:value-of select="key('page-id',$linkMe)/TITLE"/>
</a>

--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
Nov 12 '05 #4

Now i've got XSL looking like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="page-id" match="PAGE" use="@ID"/>
<xsl:output method="html"/>
<xsl:param name="paramid"/>
...

->LINK: (not working)
<a href="#{$paramid}"> <xsl:value-of
select="key('page-id','OBJECTIVES')/TITLE"/>
</a>

->PRINT RESULTS:
<p align="center" class="titulo">
<xsl:value-of select="key('page-id',$paramid)/TITLE"/>
</p>

The printing part is working, cause when i specify a default variable,
the results are displayed correctly.

<xsl:param name="paramid" select="'ID'"/>
The problem is, i can't specify another $paramid value in the link,
cause when i do, i get the following error:

"The key word xsl:param cannot be used here" - or something like that,
since this is a direct portuguese translation.

Once again, many thx for your help.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Paulo Guedes wrote:
The printing part is working, cause when i specify a default variable,
the results are displayed correctly.

<xsl:param name="paramid" select="'ID'"/>
The problem is, i can't specify another $paramid value in the link,
cause when i do, i get the following error:

"The key word xsl:param cannot be used here" - or something like that,
since this is a direct portuguese translation.


Sorry, it's not clear to me what do you mean saying "specify another
$paramid value". Show your stylesheet please.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
Nov 12 '05 #6
I will try to explain with an example:

In any given momment, i'm watching the contents of

<PAGE id="intro">
<title>bla bla</title>
<body>bla bla</body>
</PAGE>

witch gives me one webpage displaying only the Intro part of the xml
document.

I have always present in a top menu, links to the other contents, for
instance:

<PAGE id="objectives">
<title>bla bla</title>
<body>bla bla</body>
</page>

and the correspondent XSL (not working) link: ::1::

<a href="#{$paramid(LINK)">
<xsl:value-of select="key('page-id','objectives')/title"/>
</a>

To print the contens of a page, with any given ID, i've got the
following:

<p align="center" class="title"> ::2::
<xsl:value-of select="key('page-id',$paramid(PASSED BY
LINK)/title"/>
</p>

and the same for the content (body).

What i want is:

When i follow the link: OBJECTIVES, in ::1::, the paramid parameter
assumes another value: in this case: OBJECTIVES, so when i do follow the
link, the contentes of

<PAGE id="objectives">

are displayed through ::2::, using the new paramid value passed by the
link followed!

I'm making a website for a school project, and can only use one XML
file, who holds the content of the entire website, but the html only
displays the contents that user want to see, folloing links, possibly...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7

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

Similar topics

1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
5
by: Qazz | last post by:
Yesterday morning, all the ASP Reference Pages were there, and then yesterday afternoon they were all gone!!! For example:...
0
by: Rudolph Araujo | last post by:
Hi, I needed to build a data grid in which the first column has hyperlinks rather than simple text. I found the following code on this newsgroup and it works fine except for one problem. When I...
3
by: akunal | last post by:
I'm trying to represent a linked relationship among between nodes as follows: <!-- Top level nodes --> <Cities> <City>Los Angeles</City> <City>San Francisco</City> <City>Seattle</City>...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, ...
3
by: KimberlyM | last post by:
This has been driving me crazy. I hope someone can help. The site displays perfectly in FF but all div's do not show in IE. Please help me find the problem! Thanks! Here is my css. ...
2
by: Freightliner | last post by:
As per W3C validator, I replaced all & that appeared into URL or links with "&amp;" in this webpage: www.roberto089.com/press_089.html I still get two similar errors: Line 50, Column 92:...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.