473,698 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1488
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::Namespace Support' 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.n et>,
bugbear <bugbear@trim_p apermule.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::PureP erl, which is slow, and I do not know if it
handles namespaces. According to its documentation, XML::SAX will use
XML::SAX::PureP erl 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
2685
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 reason why something similar hasn't been implemented in Python, a limitation of the language or libraries perhaps? I briefly scanned through the perl source for Net::MySQL, and there doesn't seem to be anything that couldn't be done in Python, but...
31
4792
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 great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
1
1320
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 parsers.) My understanding of a default namespace is that all unprefixed names get assigned to the default namespace at and below the level of the element in
36
4038
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) <DOM Element: href at 0x1443e68> >>> document.toxml() '<?xml version="1.0" ?>\n<href/>' Note that the namespace wasn't emitted. If I have PyXML,
5
2426
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 setting up on our in-house library. Currently I use REXX for my scripting needs, but I understand that Python and Perl are popular for XML work, and I know that Perl is popular for CGI. At the risk of starting some kind of religious war, which one...
2
3738
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 that both eventually call the same code that imports xml.parsers.expat. Both give me different results... The code that gets called is (print statements have been added for debugging):
4
1796
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" /> </head>
8
2827
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 WebService156 { ... }
0
3370
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 article. As you will see shortly, the implementation of the parsers is an almost one-to-one translation of those grammar rules. Recursive descent parsing The grammar rules are highly recursive, i.e. one rule mentions another rule
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7732
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.