[Home] [By Thread] [By Date] [Recent Entries]

  • From: Matt Sergeant <matt@s...>
  • To: Tim Bray <tbray@t...>
  • Date: Fri, 30 Mar 2001 23:03:31 +0100 (BST)

On Fri, 30 Mar 2001, Tim Bray wrote:

> At 08:26 AM 30/03/01 -0500, Simon St.Laurent wrote:
> >Is there some kind of processing advantage for _parsers_ (not applications) 
> >to report attribute values in any sequence other than their original sequence?
> 
> Only instance I can think of is in perl, in one of the interfaces
> through XML::Parser to expat, you can arrange to get a callback
> for each start tag where the attributes are passed in as a hash
> keyed by name in the obvious way.  So the order isn't changed,
> but it's effectively lost. -Tim

Not true actually, XML::Parser passes them through as an array, it's just
that assigning that to a hash loses the order. Try:

sub parse_start {
  my ($e, $tag, @attribs) = @_;
  print "Tag: $tag\n";
  while (@attribs) {
    my ($key, $value) = splice(@attribs, 0, 2);
    print "Attrib: $key=$value\n";
  }
}

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member