[XSLT] Valid XHTML

Greg (51)

Usenet Archive
Joined
Sep 26, 2003
Messages
3
Reaction score
0
Hi everybody,

so, I would like to use XML files for some parts of my website. I would like to respect W3C XHTML 1.1 recommendation. Then, I have these two docs :
o My XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>

<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>

[...]

<cd>
<title>Unchain my heart</title>
<artist>Joe Cocker</artist>
<country>USA</country>
<company>EMI</company>
<price>8.20</price>
<year>1987</year>
</cd>
</catalog>

o My XSL stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:eek:utput method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

As it's writen in W3C website
(http://www.w3.org/TR/xslt#section-XML-Output-Method):
"If the doctype-system attribute is specified, the xml output method should output a document type declaration immediately before the first element."

But W3C validator (http://validator.w3.org/) tells me that my XML file is not valid:
Fatal Error: No DOCTYPE specified!

My question is: What did I do or what I did not do ?

You can find those two exemple at that address:
http://bimyou.free.fr/xmltest/cdcatalog.xml

Thanks

Greg
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
Change:

<html xmlns="http://www.w3.org/1999/xhtml">

but then you'll find other errors -- e.g. no "head" is present in the output of the transformation.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Greg said:
Hi everybody,

so, I would like to use XML files for some parts of my website. I would like to respect W3C XHTML 1.1 recommendation. Then, I have these two docs :
o My XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>

<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>

[...]

<cd>
<title>Unchain my heart</title>
<artist>Joe Cocker</artist>
<country>USA</country>
<company>EMI</company>
<price>8.20</price>
<year>1987</year>
</cd>
</catalog>

o My XSL stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:eek:utput method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

As it's writen in W3C website
(http://www.w3.org/TR/xslt#section-XML-Output-Method):
"If the doctype-system attribute is specified, the xml output method should output a document type declaration immediately before the first element."

But W3C validator (http://validator.w3.org/) tells me that my XML file is not valid:
Fatal Error: No DOCTYPE specified!

My question is: What did I do or what I did not do ?

You can find those two exemple at that address:
http://bimyou.free.fr/xmltest/cdcatalog.xml

Thanks

Greg
 

Greg (51)

Usenet Archive
Joined
Sep 26, 2003
Messages
3
Reaction score
0

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
I forgot to tell you to add:

encoding="ASCII"

to your xsl:eek:utput

Then I pass the result to the validater and get:

This page is not Valid XHTML 1.0 Transitional!
Below are the results of attempting to parse this document with an SGML parser.

1.. Line 4, column 5: document type does not allow element "body" here (explain...). <body> ^2.. Line 21, column 6: end tag for "html" which is not finished (explain...). </html> ^Source Listing Below is the source input I used for this validation:

1: <?xml version="1.0" encoding="ASCII"?>
2: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3: <html xmlns="http://www.w3.org/1999/xhtml"> 4: <body> 5: <h2>My CD Collection</h2> 6: <table border="1"> 7: <tr bgcolor="#9acd32"> 8: <th align="left">Title</th> 9: <th align="left">Artist</th> 10: </tr> 11: <tr> 12: <td>Empire Burlesque</td> 13: <td>Bob Dylan</td> 14: </tr> 15: <tr> 16: <td>Unchain my heart</td> 17: <td>Joe Cocker</td> 18: </tr> 19: </table> 20: </body> 21: </html> ===== Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Greg said:
"Dimitre Novatchev" a écrit dans le message de ]
bl1t9h$6qf57$...

<html xmlns="http://www.w3.org/1999/xhtml">

but then you'll find other errors -- e.g. no "head" is present in the output of the transformation.

Thanks, but after changing it, I still get the same error: "Fatal Error: No DOCTYPE specified!". http://validator.w3.org/check?uri=http://bimyou.free.fr/xmltest/cdcatalog.xml

Like if the doctype-system/public won't work...?

[SNIP][/QUOTE]
 

Greg (51)

Usenet Archive
Joined
Sep 26, 2003
Messages
3
Reaction score
0
I forgot to tell you to add:
encoding="ASCII"

to your xsl:eek:utput
Done.

Then I pass the result to the validater and get:
[SNIP]

Below is the source input I used for this validation:

[SNIP]

Maybe that's the problem. I use my XML file directly, but you seem to use a XHTML file resulting from my two files, or am I totally wrong. Does the validator can validate XML files directly?
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
Maybe that's the problem. I use my XML file directly, but you seem to use a
XHTML file resulting from my two files, or am I totally wrong. Does the validator can validate XML files directly?

Why do you intednd to XHTML-validate *any* xml???

The idea behind XHTML validation is to see whether or not the input is valid according to the XHTML schema.

Obviously, feeding the XHTML validator with *any* xml will return "invalid" -- therefore it's waste of time to do it.

What may only be useful is to check whether the result of your xslt transformation (which is supposed to generate XHTML) is really valid XHTML.

Remember, validation is checking against a schema -- it is not just checking to see if some text is well-formed xml. A valid document must be well-formed but not every well-formed document is valid.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

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
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top