[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>&nbsp; I think this post maybe should =
be sent to a=20
different (xhtml) newsgroup but I just wanted to check here first.&nbsp; =
Sorry=20
if this is the wrong place.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; I have a small python function =
that I use to=20
validate xml, which I&nbsp;saved in the module "tools.py":</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; from xml.sax import=20
sax2exts<BR>&nbsp;&nbsp;&nbsp; from xml.dom.ext.reader import=20
Sax2<BR>&nbsp;&nbsp;&nbsp; from xml.dom.ext import =
PrettyPrint</FONT><BR></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; def=20
validateXML(filename):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;p =3D=20
sax2exts.XMLValParserFactory.make_parser()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
reader =3D =
Sax2.Reader(parser=3Dp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
dom_object =3D=20
reader.fromUri(filename)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
PrettyPrint(dom_object)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; from =
tools import=20
validateXML</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
validateXML('myfile.xml')</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Assuming that code is o.k. - here is =
where the=20
question gets off topic.&nbsp; The problem arises when I try to check =
XHTML=20
documents.&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; For example: "test.html" Which =
is more or=20
less taken from the W3C spec:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;?xml =
version=3D"1.0"=20
?&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;!DOCTYPE html=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  PUBLIC "-//W3C//DTD =
XHTML 1.0=20
Strict//EN"<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "<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>"&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;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"&gt;<BR>&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;head&gt;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&lt;title&gt;Virtual=20
Library&lt;/title&gt;<BR>&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/head&gt;<BR>&nbsp;&nbsp;&nbsp; &nbsp; =
&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &lt;p&gt;Moved to &lt;a href=3D"<A=20
href=3D'http://vlib.org/">vlib.org</a>.</p'>[XML-SIG] Article on Intel Developer Journal that covers PySAX/minidom

	
  • Next message: [XML-SIG] validating xhtml
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]