Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: problem using XML::SAX::ParserFactory

by arturo (Vicar)
on Jul 21, 2005 at 13:17 UTC ( #476809=note: print w/ replies, xml ) Need Help??


in reply to problem using XML::SAX::ParserFactory

As is pointed out in the XML spec, DTDs aren't just for validation; they also tell you what the default value of attributes are, and potentially contain entity declarations. In a way, DTDs contain some of the document's information. So, because these things are needed to 'read' the document, conforming parsers are required to read them if they are declared -- whether or not the parser is validating.

If you're sure the document's valid, you could strip out the DOCTYPE declaration before siccing your parser on it.

update : an even better solution would be to get a local copy of the DTD and use catalog resolution to find it. A catalog resolver can tell a parser where to look for a DTD with a given public ID, irrespective of the system ID (the URL in the doctype declaration).

If not P, what? Q maybe?
"Sidney Morgenbesser"


Comment on Re: problem using XML::SAX::ParserFactory
Download Code
Re^2: problem using XML::SAX::ParserFactory
by amonroy (Scribe) on Jul 21, 2005 at 19:07 UTC

    Dana, I found something interesting in the documentation.

    The solution is along the lines of what the other poster suggested.

    I think you can redirect the DTD lookup to a local file by using the resolve_entity method. It says that you "can use this method to redirect external system identifiers to secure and/or local URIs, to look up public identifiers in a catalogue, or to read an entity from a database or other input source (including, for example, a dialog box)."

    From CPAN

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://476809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2014-12-28 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls