473,395 Members | 1,401 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,395 software developers and data experts.

[XSLT] Valid XHTML

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:output 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
Jul 20 '05 #1
5 2385
Change:
<html>
to:
<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" <gf*****@enib.fr> wrote in message
news:3f***********************@news.free.fr... 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:output 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

Jul 20 '05 #2
"Dimitre Novatchev" <dn********@yahoo.com> a écrit dans le message de news:
bl************@ID-152440.news.uni-berlin.de...
Change:
<html>
to:
<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=ht...Fcdcatalog.xml

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

[SNIP]
Jul 20 '05 #3
I forgot to tell you to add:

encoding="ASCII"

to your xsl:output
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" <gf*****@enib.fr> wrote in message
news:3f***********************@news.free.fr...
"Dimitre Novatchev" <dn********@yahoo.com> a écrit dans le message de news: bl************@ID-152440.news.uni-berlin.de...
Change:
<html>
to:
<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=ht...Fcdcatalog.xml
Like if the doctype-system/public won't work...?

[SNIP]

Jul 20 '05 #4
> I forgot to tell you to add:

encoding="ASCII"

to your xsl:output
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?
Jul 20 '05 #5
> 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
Jul 20 '05 #6

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

Similar topics

20
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
13
by: Tjerk Wolterink | last post by:
Hello i've an xsl stylesheet that must support xhtml entities, my solution: ---- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xsl:stylesheet > <xsl:stylesheet version="1.0"...
3
by: rush | last post by:
I have a DTD that defines new elements "mytextfield" and "mysn", and does it as an extension to XHTML. The idea is that my XML markup is actually valid XHTML according to my DTD. This all works...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
2
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
3
by: Grant Harmeyer | last post by:
I have an XSL file that is being applied to an RSS feed, and it works great except for 2 things: 1.) XSL doesn't close the <img> tag for xhtml even though I have it being closed in the XSL file...
6
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a...
7
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.