RE: What's So Great about SAX? (ie. Future Indecisions)
by Morbus Iff other posts by this author
Oct 7 2002 9:55PM messages near this date
view in the new Beta List Site
RE: What's So Great about SAX? (ie. Future Indecisions)
|
What's So Great about SAX? (ie. Future Indecisions)
> SAX is a huge advance over the XML::Parser Handler API for a
Thanks for the expose. I'll wax a bit.
> - pluggable - if your code is written to the SAX API you
> can use any SAX parser without changing your code
Not immediately useful to me, since expat is the only library currently
ported (and bundle-able) to every OS I need it to be in (my software is one
of the rare few that turns into a "don't need Perl installed" application
for Mac and Windows).
> - flexible - your data source does not even need to be an
> XML document (eg: you can drive your SAX pipeline from
> a database query
That's kinda neat, although I do some pre-processing before sending to
XML::Simple - enough so that I'm always sending a string of XML, not a file.
> I'm not entirely clear on what you're trying to do with
> namespaces. Do you want your hashref keys to be in Clarkian
> notation eg: '{http://purl.org/dc/elements/1.1/}date' or
> do you want to normalise the prefixes used eg: 'dc:date'?
Nope, not really. The biggest problem is:
- I assume my data is going to be in one data structure, but
if someone prefixes the data with a namespace besides the
implied default, I get a different structure that breaks
my assumption:
assuming:
<item> <dc:title>boo</dc:title></item>
== $item-> {dc:title}
breaks my thingy:
<item> <dublincore:title>boo</dublincore:title></item>
!= $item-> {dc:title} but rather $item->{dublinecore:title}
In my case, my plan was to preparse the list of
namespaces in an XML document. So, if I had:
xmlns:crazymother="http://purl.org/dc/elements/1.1/"
I'd store it as $namespaces{http://purl.org/dc/elements/1.1/} =
"crazymother" or some such. There'd be a subroutine that'd return the
prefix (pseudo):
sub get_namespace_prefix {
my ($url) = @_; return $namespaces{$url} || undef;
}
With that, I'd be able to then do, in my code:
my $dc_prefix = get_ns_url("http://purl.org/dc/elements/1.1/");
if ($dc_prefix) {
print "Dublin Core Title: $item-> {"$dc_prefix:title"};
}
--
Morbus Iff ( i'm the droid you're looking for )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Please Me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
|