[XML-SIG] validating xhtml
Steve Barlow
barlow@t-online.de
Mon, 18 Mar 2002 17:26:15 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_00A8_01C1CEA2.02307B00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello Everyone,=20
I think this post maybe should be sent to a different (xhtml) =
newsgroup but I just wanted to check here first. Sorry if this is the =
wrong place.
I have a small python function that I use to validate xml, which I =
saved in the module "tools.py":
from xml.sax import sax2exts
from xml.dom.ext.reader import Sax2
from xml.dom.ext import PrettyPrint
def validateXML(filename):
p =3D sax2exts.XMLValParserFactory.make_parser()
reader =3D Sax2.Reader(parser=3Dp)
dom_object =3D reader.fromUri(filename)
PrettyPrint(dom_object)
This seems to work fine - and I use it as a quick "stupidity" check when =
I am messing with my XML documents.
from tools import validateXML
validateXML('myfile.xml')
Assuming that code is o.k. - here is where the question gets off topic. =
The problem arises when I try to check XHTML documents. =20
For example: "test.html" Which is more or less taken from the W3C =
spec:
<?xml version=3D"1.0" ?>
<!DOCTYPE html=20
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en" =
lang=3D"en">
<head>
<title>Virtual Library</title>
</head>
<body>
<p>Moved to <a href=3D"http://vlib.org/">vlib.org</a>.</p>
</body>
</html>
Dies a horrible death with messages about "xml:space must have exactly =
the values 'default' and 'preserve'" Am I correct that this is just my =
lack of understanding about XHTML and has nothing to do with python? If =
so - thanks for the verification and sorry about the post - I will look =
elsewhere. Otherwise, what did I screw up?
Thanks
Steve Barlow
------=_NextPart_000_00A8_01C1CEA2.02307B00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello Everyone, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> I think this post maybe should =
be sent to a=20
different (xhtml) newsgroup but I just wanted to check here first. =
Sorry=20
if this is the wrong place.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> I have a small python function =
that I use to=20
validate xml, which I saved in the module "tools.py":</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> from xml.sax import=20
sax2exts<BR> from xml.dom.ext.reader import=20
Sax2<BR> from xml.dom.ext import =
PrettyPrint</FONT><BR></DIV>
<DIV><FONT face=3DArial size=3D2> def=20
validateXML(filename):<BR>  =
;p =3D=20
sax2exts.XMLValParserFactory.make_parser()<BR> &nb=
sp; =20
reader =3D =
Sax2.Reader(parser=3Dp)<BR> =20
dom_object =3D=20
reader.fromUri(filename)<BR> =20
PrettyPrint(dom_object)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>This seems to work fine - and I use it =
as a quick=20
"stupidity" check when I am messing with my XML documents.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> from =
tools import=20
validateXML</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
validateXML('myfile.xml')</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Assuming that code is o.k. - here is =
where the=20
question gets off topic. The problem arises when I try to check =
XHTML=20
documents. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> For example: "test.html" Which =
is more or=20
less taken from the W3C spec:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> <?xml =
version=3D"1.0"=20
?><BR> <!DOCTYPE html=20
<BR> PUBLIC "-//W3C//DTD =
XHTML 1.0=20
Strict//EN"<BR> "<A=20
href=3D"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3.=
org/TR/xhtml1/DTD/xhtml1-strict.dtd</A>"><BR> =20
<html xmlns=3D"<A=20
href=3D"http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>"=20
xml:lang=3D"en" lang=3D"en"><BR> =20
<head><BR> =
<title>Virtual=20
Library</title><BR> =20
</head><BR> =
<body><BR> =20
<p>Moved to <a href=3D"<A=20
href=3D'http://vlib.org/">vlib.org</a>.</p'>http://vlib.org/">vlib.org=
</a>.</p</A>><BR> =20
</body><BR> </html></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dies a horrible death with messages =
about=20
"xml:space must have exactly the values 'default' and 'preserve'" =
Am I=20
correct that this is just my lack of understanding about XHTML and =
has=20
nothing to do with python? If so - thanks for the verification and =
sorry=20
about the post - I will look elsewhere. Otherwise, what did I =
screw=20
up?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Steve =
Barlow</FONT></DIV></BODY></HTML>
------=_NextPart_000_00A8_01C1CEA2.02307B00--