ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xml-sig
xml-sig
[XML-SIG] Problem using schema instead of DTD
by Tim van Erven other posts by this author
Jan 14 2005 2:40AM messages near this date
Re: [XML-SIG] Re: Re: Re: cElementTree 0.8 (january 11, 2005) | Re: [XML-SIG] Problem using schema instead of DTD
& XSLT Dear all,

I'm using pyxml to read an xml file from stdin, modify it a bit, and
write it out again to stdout. In the process a doctype is added
automatically. In the output a <!DOCTYPE ...>  line is added. I'm using a
schema to validate my output, but it won't validate when the !DOCTYPE is
present, so I think I'd like to get rid of that.

I'm doing something like:

import sys
from xml.dom.ext.reader import Sax2
from xml.dom.ext import PrettyPrint
reader = Sax2.Reader()
doc = reader.fromStream(sys.stdin)
# modify doc
PrettyPrint(doc)

The xml files I'm using look like this:

<?xml version="1.0" encoding="ISO-8859-1"?> 
 
<ltp xmlns="http://www.example.org/info"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/info someschema.xsd"> 
 
<text> This is some sample text.</text>
</ltp> 

And the output of my program looks like this, which won't validate:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE ltp>  
<ltp xmlns="http://www.example.org/info"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/info someschema.xsd"> 
 
<text> This is some modified sample text.</text>
</ltp> 

Does anyone know how to get rid of the !DOCTYPE line? Is that the right
thing to do anyway?

I'm rather new to xml, so any conceptual corrections would be much
appreciated as well.

Regards,
Tim

-- 
Tim van Erven <tve@[...].net> 
_______________________________________________
XML-SIG maillist  -  XML-SIG@[...].org
http://mail.python.org/mailman/listinfo/xml-sig
Thread:
Tim van Erven
Andrew Clover
Mike Brown
Tim van Erven
Tim van Erven

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved