I'm attempting to read an XHTML 1.1 file[1], perform some DOM manipulation,
then write the results to a different file.
I've found myself rather stuck at the first hurdle.
I have the following:
from xml.dom.ext.rea der import Sax2
reader = Sax2.Reader()
f = open('dorward.m e.uk/sitemap.html', 'r')
doc = reader.fromStre am(f)
(dorward.me.uk/sitemap.html being a local copy of http://dorward.me.uk/sitemap.html)
.... which outputs the following:
Traceback (most recent call last):
File "x.py", line 4, in ?
doc = reader.fromStre am(f)
File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py",
line 372, in fromStream
self.parser.par se(s)
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line
109, in parse
xmlreader.Incre mentalParser.pa rse(self, source)
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/xmlreader.py", line
123, in parse
self.feed(buffe r)
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line
220, in feed
self._err_handl er.fatalError(e xc)
File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py",
line 340, in fatalError
raise exception
xml.sax._except ions.SAXParseEx ception: http://www.w3.org/TR/xhtml-modulariz...s-1.mod:115:0:
error in processing external entity reference
I'm not sure where I should proceed from here. Is it a bug in my code? In
PyXML? In the DTD itself? What should I do next?
Thanks.
[1] Actually, lots of files, but one at a time.
--
David Dorward <http://dorward.me.uk/> 2 3521
David Dorward wrote: I'm attempting to read an XHTML 1.1 file[1], perform some DOM manipulation, then write the results to a different file.
I've found myself rather stuck at the first hurdle.
I have the following:
from xml.dom.ext.rea der import Sax2 reader = Sax2.Reader() f = open('dorward.m e.uk/sitemap.html', 'r') doc = reader.fromStre am(f)
(dorward.me.uk/sitemap.html being a local copy of http://dorward.me.uk/sitemap.html)
... which outputs the following:
Traceback (most recent call last): File "x.py", line 4, in ? doc = reader.fromStre am(f) File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py", line 372, in fromStream self.parser.par se(s) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line 109, in parse xmlreader.Incre mentalParser.pa rse(self, source) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/xmlreader.py", line 123, in parse self.feed(buffe r) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line 220, in feed self._err_handl er.fatalError(e xc) File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py", line 340, in fatalError raise exception xml.sax._except ions.SAXParseEx ception: http://www.w3.org/TR/xhtml-modulariz...s-1.mod:115:0: error in processing external entity reference
I'm not sure where I should proceed from here. Is it a bug in my code? In PyXML? In the DTD itself? What should I do next?
Thanks.
[1] Actually, lots of files, but one at a time.
I think you need a parser import xml.sax parser = xml.sax.make_pa rser() file = "dorward.me .uk/sitemap.html" parser.parse (file)
How furder I don't now, I'am stuck to!
Try the 'http://pyxml.sourcefor ge.net/topics/howto/xml-howto.html'site .
Bennie,
David Dorward <do*****@yahoo. com> wrote in message news:<c1******* ************@ne ws.demon.co.uk> ... I'm attempting to read an XHTML 1.1 file[1], perform some DOM manipulation, then write the results to a different file.
I've found myself rather stuck at the first hurdle.
I have the following:
from xml.dom.ext.rea der import Sax2 reader = Sax2.Reader() f = open('dorward.m e.uk/sitemap.html', 'r') doc = reader.fromStre am(f)
(dorward.me.uk/sitemap.html being a local copy of http://dorward.me.uk/sitemap.html)
... which outputs the following:
Traceback (most recent call last): File "x.py", line 4, in ? doc = reader.fromStre am(f) File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py", line 372, in fromStream self.parser.par se(s) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line 109, in parse xmlreader.Incre mentalParser.pa rse(self, source) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/xmlreader.py", line 123, in parse self.feed(buffe r) File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py" , line 220, in feed self._err_handl er.fatalError(e xc) File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py", line 340, in fatalError raise exception xml.sax._except ions.SAXParseEx ception: http://www.w3.org/TR/xhtml-modulariz...s-1.mod:115:0: error in processing external entity reference
I'm not sure where I should proceed from here. Is it a bug in my code? In PyXML? In the DTD itself? What should I do next?
The bug is with the W3C. Through a chain of parameter entity refs, it http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd references http://www.w3.org/TR/xhtml-modulariz...11-model-1.mod,
which gives 404 (and yes XML heads, it is in an INCLUDE section so the
URI must be traversed unless there's a resoltion through pubID).
I'm actually rather amazed at such carelessness by the W3C, but I
don't have time to dig further to see if I can figure out how things
got broken.
I can tell you that you can use minidom or OK with this because it
does not even read the external DTD subset: from xml.dom import minidom doc = minidom.parse(' sitemap.html') doc
<xml.dom.minido m.Document instance at 0x400635ec>
Also, 4Suite's cDomlette makes it easy for you to avoid the DTD
problem:
from Ft.Xml.Domlette import NoExtDtdReader doc = NoExtDtdReader. parseUri("file: sitemap.html") doc
<cDocument at 0x0x403ab42c>
http://4suite.org http://uche.ogbuji.net/tech/akara/no...1-01/domlettes
Good luck.
--Uche http://uche.ogbuji.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ittay.dror |
last post by:
Hi,
I have a build.xml with the following header:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project >
When I launch ant, the jar that holds common.ent is in the classpath
(by setting it in LOCALCLASSPATH variable).
I get:
|
by: Robert Lintner |
last post by:
Hi,
I woult like to switch from DTD to XML-Schema and am looking for an equivalent
to external ENTITY for composition of an xml file from modules
--- my.dtd --
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ENTITY module1 SYSTEM "module1.xml">
<!ENTITY module2 SYSTEM "module2.xml">
.....
|
by: Geiger Ho |
last post by:
Hi all,
I have a DOM tree which is implemented by glib N-ary tree. I serialize
the tree to give back an xml document. However, how should I deal with the
external entity. Is there any tool or library that can accept a symbol and
an entity dtd to return me the entity?
Thanks in advance.
Regards,
|
by: Douglas Reith |
last post by:
Hi There,
Can someone please tell me why the XML spec states that an attribute
value with an external entity is forbidden? Or point me to the
appropriate document? Or better still, perhaps you know of a work
around?
It is a little frustrating that the normally powerful external
entities are limited in this fashion.
Example (myextent.txt contains just one word without a CR):
|
by: Joris Gillis |
last post by:
Hi everyone,
I have this 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"/>
<xsl:template match="/">
<node>'</node>
| |
by: Razvan |
last post by:
Hi
What is the difference between an internal and an external entity ?
The first one is defined in the internal subset (not in a separate DTD
file, but in the XML file itself - in DOCTYPE) while the second one is
defined in the external subset (in a separate DTD file) ? Or an
|
by: Aravind |
last post by:
we have two files:
1. rc4.c (defines one function "create_pin()")
2. MyImpl.c(calling the function "create_pin()"),This implements JNI
method.
1.When I am trying to create .dll file with one file rc4.obj(rc4.c),it
is creating the .dll file without any error.
Command : ILINK32 rc4.obj
2.But,when we are trying to create .dll file with two .obj files with
following errors.
|
by: punjabinezzie |
last post by:
I am developing an Application which currently has two XML files. One
XML file with some nodes and an external entity reference to another
XML file. The source XML file is being parsed using Xerces (DOM
Parser), upon reaching an external entity reference node the external
file being referenced does not get parsed. Instead an empty node or the
current node name is substituted in place and the remaining nodes
parsed from original source file...
|
by: xxxtriplerxxx |
last post by:
//my testing.h code
#ifndef TESTING_H
#define TESTING_H
#include <iostream.h>
class TestingLink
{
public:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |