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

Subject: Re: [xsl] Transform xhtml to xhtml, convert one tag to another, while preserving rest of file
From: "Peter O." <xolox@xxxxxxx>
Date: Tue, 08 Feb 2005 17:57:38 +0100
Lots of questions about namespaces and behavior related to it that I don't understand, but if you don't feel like explaining the namespace thing and think I should just look it up: ok, you're right. I will. :-)

Thanks to both Wendell Piez & Joris Gillis for pointing out that elements inherit parent elements' namespaces. (is this the correct way of defining this behavior?)

Because you both mentioned namespaces, I looked through my source and I discovered that I hadn't even included the XHTML namespace in my (X)HTML documents root tag (<html>)... Quickly added it, to be sure I was correct and on line with both your expectations :-).

Then I thought, 'Hey, wait a sec, if there was no namespace before, the template should have matched...' Right? The XHTML documents did include the doctype definition, but for as far as I know this doesn't mean that all elements are in the XHTML namespace, or is this infact the case? Hehe, nevermind, getting off-topic here, guess I should just read about namespaces some more.

Anyways, added namespace, adjusted template, as you both suggested, but things did not work out ok. :(

The document stays the same (well, not exactly: read on), except of course the added namespace in the source xhtml documents root (<html>) appears.

But there's something else. Almost all of the elements in my page now appear with the empty attribute xmlns, like:

<p xmlns=""></p>

for example. Why is this? Doesn't seem logical at all. But the strangest thing -to me anyway- is that some elements do, and some elements don't get the attribute. Every <p> element does, but for example <em> does not. I got so far (with help of the XHTML Recommendation) that it seems block elements (h1-h6, div, etc) do, and inline (em, strong, etc) don't include this empty attribute, and empty elements (hr) don't get it either. Why does Xalan do this? Never seen/heard about this behavior before.

Ok, sorry about all the namespace stuff, back to the original subject: it still doesn't work. The XHTML namespace is now present in both the XHTML source files and the XSL file that processes them. I've also changed the template to match "xhtml:reference". Anything I could have missed?

Maybe I should post the files on the web so someone (with a lot of time on his/her hands and a very helpful attitude) could take a look at them.

Sorry for the long text, I'm not that good at summarising. And thanks a lot for your attention and help so far! I really appreciate it! Don't think I could have solved this on my own. Seems I'm still a total newbie in the land of XSL :-).

- Peter Odding

Current Thread