Connecting Tech Pros Worldwide Forums | Help | Site Map

XML namespaces in (pure) perl parsers?

bugbear
Guest
 
Posts: n/a
#1: Feb 16 '06
I need to do some fairly simple processing
of XML files; I would like to be able to do this
in perl.

However, the XML I'm handling uses namespaces.

In practice, the tags do not overlap,
so I could achieve the functionality I need
by simply stripping namespace information.

Question: what XML parsers, callable from perl
support namespaces (either properly, or by
carefully ignoring them)?

And, of these, which (if any) of them do not require
compilation to install (i.e. which are "pure" perl).

The reason for the latter restriction is ease
of installation on some nasty, obscure, old
hardware (don't ask, you DON'T want to know ;-)

BugBear

Joe Kesselman
Guest
 
Posts: n/a
#2: Feb 16 '06

re: XML namespaces in (pure) perl parsers?


I don't use perl, so I can't recommend specific packages, but any modern
XML parser *should* support namespaces...
bugbear
Guest
 
Posts: n/a
#3: Feb 16 '06

re: XML namespaces in (pure) perl parsers?


Joe Kesselman wrote:[color=blue]
> I don't use perl, so I can't recommend specific packages, but any modern
> XML parser *should* support namespaces...[/color]

You're right, and yet wrong. Many modern perl parsers don't.

Hence my question.

BugBear
Joseph Kesselman
Guest
 
Posts: n/a
#4: Feb 16 '06

re: XML namespaces in (pure) perl parsers?


bugbear wrote:[color=blue]
> You're right, and yet wrong. Many modern perl parsers don't.[/color]

OK, we can quibble about whether they can claim to be "modern" in that
case as opposed to just "obsolete but still in use" (<sigh/>)...

Unfortuately I don't know the perl toolspace, so I can't offer opinions
on which ones you should be switching to; I'd have to start with a
websearch, and you can do that just about as effectively yourself.

Hopefully someone else can point you in the right direction.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Bart Van der Donck
Guest
 
Posts: n/a
#5: Feb 16 '06

re: XML namespaces in (pure) perl parsers?


bugbear wrote:
[color=blue]
> I need to do some fairly simple processing
> of XML files; I would like to be able to do this
> in perl.
>
> However, the XML I'm handling uses namespaces.
>
> In practice, the tags do not overlap,
> so I could achieve the functionality I need
> by simply stripping namespace information.[/color]

Yes, quite possible, and a common strategy for this kind of stuff.
[color=blue]
> Question: what XML parsers, callable from perl
> support namespaces (either properly, or by
> carefully ignoring them)?[/color]

You can find a bunch of modules on CPAN that handle XML namespaces,
see.e.g.
http://cpan.uwinnipeg.ca/search?query=xml+namespace
[color=blue]
> And, of these, which (if any) of them do not require
> compilation to install (i.e. which are "pure" perl).[/color]

'XML::NamespaceSupport' and 'XML::Writer' are available by default on
my FreeBSD machine with perl v5.8.3.
[color=blue]
> The reason for the latter restriction is ease
> of installation on some nasty, obscure, old
> hardware (don't ask, you DON'T want to know ;-)[/color]

Well, maybe you have nasty, obscure, old hardware but with the latest
perl version on it :-)

As a general rule, the older an XML module, the less chance it will
support namespaces.

Summarized, there are two possible solutions for your problem:
(1) use a module
or
(2) regexp out the colons (only inside XML tags) and regexp them back
after parsing

--
Bart

Jim Gibson
Guest
 
Posts: n/a
#6: Feb 17 '06

re: XML namespaces in (pure) perl parsers?


In article <43f45c07$0$82661$ed2619ec@ptn-nntp-reader03.plus.net>,
bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
[color=blue]
> I need to do some fairly simple processing
> of XML files; I would like to be able to do this
> in perl.
>
> However, the XML I'm handling uses namespaces.
>
> In practice, the tags do not overlap,
> so I could achieve the functionality I need
> by simply stripping namespace information.
>
> Question: what XML parsers, callable from perl
> support namespaces (either properly, or by
> carefully ignoring them)?
>
> And, of these, which (if any) of them do not require
> compilation to install (i.e. which are "pure" perl).
>
> The reason for the latter restriction is ease
> of installation on some nasty, obscure, old
> hardware (don't ask, you DON'T want to know ;-)[/color]

There is XML::SAX::PurePerl, which is slow, and I do not know if it
handles namespaces. According to its documentation, XML::SAX will use
XML::SAX::PurePerl if nothing else if available, and XML::Simple will
use XML::SAX for a parser if XML::Parser is not available. Confusing,
no?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Closed Thread