in reply to XML::Mini problem

Why is the order of attributes in the header important? XML modules generally do not attempt to preserve or manage attribute order. If you require that the attributes be in a particular order you may be best to post process the XML document to generate the order you require.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: XML::Mini problem
by herveus (Prior) on May 25, 2007 at 12:02 UTC
    Howdy!

    It appears that the XML recommendation defines that XMLSpec with the version first. If XML::Mini is emitting the XMLSpec with the encoding first, it's notionally broken.

    yours,
    Michael
Re^2: XML::Mini problem
by Peamasii (Sexton) on May 25, 2007 at 10:27 UTC
    Ah, I don't know it's some XML parser that requires it that way. Anyway, I was able to fix it in Header.pm, there is a sort on the attributes in the sub toString() which can be removed.
    foreach my $atName (sort keys %{$self->{'_attributes'}})
    Now it works great.

      That's a rather fragile fix that most likely ultimately depends on the order the keys/values are returned for a hash. Were it me I'd be more inclined to edit the XML document after it's been generated by XML::Mini to avoid issues that may arise with different versions of Perl, the module, other modules that may be used, the specific attributes that are used or even the manipulation history of the hash used to store the attributes.

      If there is any requirement for reliability in the system that uses your code I'd seriously consider alternative solutions that don't rely on implementation details of code that you have no control over (such as Perl's hash management).


      DWIM is Perl's answer to Gödel
Re^2: XML::Mini problem
by pgor (Beadle) on May 25, 2007 at 15:53 UTC

    They're not attributes, even though they look like them. '<?' denotes a processing instruction, where everything after the first word is freeform data, although most PIs specify their format to look like attributes.

    As noted by herveus, the XML spec requires 'version' to be the first pseudo-attribute of the xml declaration.

    pg