Re: XML::LibXML search path for DTDs

Roger Pepitone <[email protected]> Thu, 13 Sep 2012 10:04:24 -0700 (PDT)
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Let me rephrase:  I can work out where the DTDs will be.  I'm having trouble giving that path to LibXML.
- I can't put a path to the DTD into the XML file, because it will differ for various users.
- I can't put in a line like   $parser->parse_file ($xml_location, dtd_search_path => [ $dtd_location ]); 
     into my Perl code because, AFAICT, there is no 'dtd_search_path' option.

I've been using this kludge:
    my $xml_line = "<?xml version='1.0' encoding='utf-8'?>";
    my $dtd_line = "<!DOCTYPE pre SYSTEM '${dtd_location}/${type}.dtd'>";
    my $doc = $parser->parse_string ($xml_line . $dtd_line . $text);

but that has the side effect that any errors in the .xml are reported without the filename.


________________________________
 From: Shlomi Fish <[email protected]>
To: Roger Pepitone <[email protected]> 
Cc: "[email protected]" <[email protected]> 
Sent: Thursday, September 13, 2012 10:53 AM
Subject: Re: XML::LibXML search path for DTDs
 
Hi Roger,

sorry for the late response.

On Tue, 11 Sep 2012 09:52:16 -0700 (PDT)
Roger Pepitone <[email protected]> wrote:

> Setup:
> 
> My project involves a number of XML files, spread over multiple
> directories.  They also use a custom DTD.  Because everything is
> distributed over SVN, I can't put in an absolute path for the DTD.
>  How do I tell XML::LibXML where to find them?

you can try using a combination of File::Spec (namely rel2abs), File::Basename (with
its dirname() function), the __FILE__ constant, $0 (see perlvar), etc. to
find the absolute path for the DTDs. Will this help?

Regards,

    Shlomi Fish 

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Free (Creative Commons) Music Downloads, Reviews and more - http://jamendo.com/

He says “One and one and one is three”.
Got to be good‐looking ’cause he’s so hard to see.
    — The Beatles, “Come Together”

Please reply to list if it's a mailing list post - http://shlom.in/reply .

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs