[xsl] Transform xhtml to xhtml, convert one tag to another, while preserving rest of file

Subject: [xsl] Transform xhtml to xhtml, convert one tag to another, while preserving rest of file
From: "Peter O." <xolox@xxxxxxx>
Date: Mon, 07 Feb 2005 20:38:56 +0100
First off all sorry for the long subject, but it seemed better then 'question' or 'plz help' ;-). If this is a lame question, sorry, I've been searching the list for at least two hours now, and haven't found anything helpful. And of course, I've been looking on the web as well, but to no avail.

I want to use XHTML as input and output, and in the process convert one tag from one format to another, while keeping the rest of the file intact. Is this possible?

More specific:
I use a custom hyper link format in my source XML files, which allows me to generate tool tips and status bar messages onmouseover. It works like a charm, except that the hyper links I add through the style sheet (the navigation hyper links for example) don't get to feature the sweet tool tips. So I thought I'd just output the pages as XHTML, but keep the custom hyper link format intact, and add the navigation links in the custom format as well. Then, I'd run another transform, which would leave the XHTML intact, and only process the custom hyper links.

But it seems this is more difficult then I initially thought.

For example, this was my first attempt:


<?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="xml" version="1.0" omit-xml-declaration="yes" />

<xsl:template match="reference">
Lots of nested choose when/otherwise elements. "reference" is the custom element I want to transform to regular hyper links.

<xsl:template match="text()">
<xsl:value-of select="."/>

<xsl:template match="*">
<xsl:copy-of select="."/>



I was hoping that, since the reference template is the first from top to bottom, it would get processed first, and after that, the other two templates would apply, copying the file. But it seems that the third template copies the <html> root element before the <reference> elements are processed, thus not getting processed at all.

I hope I've been able to explain my situation well enough. Sorry for the long read, but I wanted to make sure that I didn't leave out any information. Any help on this topic = greatly appreciated!

I already asked this question at an online forum, but have not gotten any response. I hope you folks have some idea's on this.

Thanks in advance,

- Peter Odding

To see the tooltips at work, currently only in the content <div>, because of this problem:

Current Thread