473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XML namespaces in (pure) perl parsers?

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
Feb 16 '06 #1
5 1470
I don't use perl, so I can't recommend specific packages, but any modern
XML parser *should* support namespaces...
Feb 16 '06 #2
Joe Kesselman wrote:
I don't use perl, so I can't recommend specific packages, but any modern
XML parser *should* support namespaces...


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

Hence my question.

BugBear
Feb 16 '06 #3
bugbear wrote:
You're right, and yet wrong. Many modern perl parsers don't.


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
Feb 16 '06 #4
bugbear wrote:
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.
Yes, quite possible, and a common strategy for this kind of stuff.
Question: what XML parsers, callable from perl
support namespaces (either properly, or by
carefully ignoring them)?
You can find a bunch of modules on CPAN that handle XML namespaces,
see.e.g.
http://cpan.uwinnipeg.ca/search?query=xml+namespace
And, of these, which (if any) of them do not require
compilation to install (i.e. which are "pure" perl).
'XML::NamespaceSupport' and 'XML::Writer' are available by default on
my FreeBSD machine with perl v5.8.3.
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 ;-)


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

Feb 16 '06 #5
In article <43***********************@ptn-nntp-reader03.plus.net>,
bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
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 ;-)


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
Feb 17 '06 #6

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

Similar topics

4
by: Ravi | last post by:
Hi, I did some googling, and found that there doesn't seem to be a pure python MySQL communication module. There is one for perl however, Net::MySQL. I was wondering if there was a specific...
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
1
by: Avi Kak | last post by:
Hello: This questions relates to the behavior of the Perl SAX 2.0 parser XML::LibXML::SAX. (This behavior is also shown by the XML::SAX::Expat parser and, possibly by all other Perl SAX 2.0...
36
by: Wilfredo Sánchez Vega | last post by:
I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element)...
5
by: James Owens | last post by:
I anticipate working with XML and XSL a lot over the next few years (I'm in technical documentation). I also happen to be looking for a new scripting language for some CGI interfaces I'll be...
2
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program...
4
by: VK | last post by:
Can well-formed but non-validated XHTML have extra namespaces? Say <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />...
8
by: Doogie | last post by:
You know they say there is no such thing as a dumb question? This might be the exception...I'm not sure. :) In VS.NET 2003, if you create a web service it is namespaced like so: namespace...
0
by: JosAH | last post by:
Greetings, this week's article part discusses the parsers used for our little language. We will implement the parsers according to the grammar rules we defined in the second part of this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...

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.