472,972 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 software developers and data experts.

How to get XML parser to recognize entities (eg. —)

I'm using PHP's XML parser to validate user-entered XHTML fragments (I
wrap them in a top-level element and send them through the parser). It
works a treat, except for handling entities:

— -- is fine, but
— -- throws an error, e.g:

"XML error: undefined entity at line 11, char 415"

(Making an entity handler didn't help, at it fails at the parsing stage.)

Obviously I could search and replace to turn entities into their
character values, but that's pretty ugly. How can I get the XML parser
to recognize XHTML's entity set? Do I need to wrap the text fragment in
a full-blown XHTML document, including the DTD specifier?

Thanks in advance,
Kalessin.

Jul 17 '05 #1
2 9311
On Wed, 17 Dec 2003 11:16:43 GMT, Kalessin
<try@http://jesus.com.au/html/email/kalessin> wrote:
I'm using PHP's XML parser to validate user-entered XHTML fragments (I
wrap them in a top-level element and send them through the parser). It
works a treat, except for handling entities:

— -- is fine, but
&mdash; -- throws an error, e.g:

"XML error: undefined entity at line 11, char 415"

(Making an entity handler didn't help, at it fails at the parsing stage.)

Obviously I could search and replace to turn entities into their
character values, but that's pretty ugly. How can I get the XML parser
to recognize XHTML's entity set? Do I need to wrap the text fragment in
a full-blown XHTML document, including the DTD specifier?


Possibly. If you look at the XML spec, there's only a limited set of entities
that XML parsers must accept without them being declared in a DTD:

http://www.w3.org/TR/REC-xml#sec-predefined-ent

The XHTML DTD imports the character references near the start:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

Could you make a mini-DTD that only imports the entities?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2
> The XHTML DTD imports the character references near the start:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

Could you make a mini-DTD that only imports the entities?


The real links for entities are:
http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
Jul 17 '05 #3

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

Similar topics

3
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory...
1
by: Bob | last post by:
I use saxon transformer as XSLT engine, but I have a problem: --- Error reported by XML parser: reference to entity "&{0};" not defined. ---- In the source document there are many entites...
1
by: Vineeth | last post by:
Hi, I am using xerces2.6.0 and am developing a program for converting an xml document to a text file. My program is extending the DefaultHandler. The first problem I am facing is that even...
11
by: Tjerk Wolterink | last post by:
I've a problem in an xsl transformation. My xml input: --- input.xml --- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xc:content > <xc:xcontent...
6
by: Jan Danielsson | last post by:
Hello all, I guess this is a question for people who have written a parser. Does an XML parser ever need to be recursive? I mean like: &fo&bar;o; I know this particular example is in the...
3
by: cr88192 | last post by:
for various reasons, I added an imo ugly hack to my xml parser. basically, I wanted the ability to have binary payload within the xml parse trees. this was partly because I came up with a binary...
2
by: Frantic | last post by:
I'm working on a list of japaneese entities that contain the entity, the unicode hexadecimal code and the xml/sgml entity used for that entity. A unicode document is read into the program, then the...
4
by: ChillyRoll | last post by:
Hello guys, I am looking for a parser in PHP that can return all the attributes of XML entities. I know how to read the XML Entities, but I have got a problem with reading attributes. So I will...
4
by: Paul Rubin | last post by:
I'm new to xml mongering so forgive me if there's an obvious well-known answer to this. It's not real obvious from the library documentation I've looked at so far. Basically I have to munch of a...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.