XSLT and the DTD callout in the source XML file

J

jopaki

Hello all,

I am relatively new to XSLT. I am attempting to transform XML and
everyting is cool until I introduce these top lines in the source XML
(really XHTML):

---------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-----------

as opposed to just:

----------
<html>
....
----------

It seems that the combination of the DTD reference and the html tag
attributes affect the output. The output with the DTD callout blindly
outputs all element values within the source seemingly regardless of
the XSL file. And when they are out I get the desired result xml
structure. I want to keep the DTD callout (and xmlns attrib) because
1) the source is XHTML and 2) this DTD defines &nbsp; and the like.

What is going on?

Any input would warrant a free ice cream payable from my account.

I am using Java xalan v2.6.2

tia!

(e-mail address removed)
The Logic Lab Consulting
 
D

David Carlisle

This is a faq (especially on xsl-list which is probably better suited to
xsl qns than c.t.x).

The XHTML DTD defaults a namespace declaration for xhtml so the elements
are no longer in no-namespace and are in the xhtml namespace, this means
that <xsl:template match="html"> no longer matches, you need
<xsl:template match="h:html"> and add
xmlns:h="http://www.w3.org/1999/xhtml" to your xsl:stylesheet.
Simmilarly prefix every other element name in XPath expressions and
match patterns.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top