On 29/04/2008, Jiří Suchomel <[EMAIL PROTECTED]> wrote:
> Hi hackers,
>
>  since yast2-2.16.57 you can use a new agent for reading and writing XML files
>  from YaST. The SCR path is .anyxml -

Finally, :)

Only thing I noticed in testing .anyxml is that it is easy to write
invalid XML if you don't consider the XML when creating the YCP data
structure. For example, the following will generate invalid XML:

{
        map xml =
        $[
                "xmltest": $[
                        "123one" : $[
                                "alpha": "alphavalue",
                                "beta": "betavalue",
                                "content": "onecontent"
                        ]
                ]
        ];

        SCR::Write
        (
                .anyxml,
                $[
                        "file": "/tmp/anyxmltest.xml",
                        "xml" : xml
                ]
        );
}

Since an XML node name must start with a letter. I don't know if
there's a way for you to work around this. In other platforms XML
marshalling/unmarshalling facilities usually take care that valid XML
is always produced, and can be read back into the same structure.

I was using Perl XML simple originally for handling XML with
metapackage-handler, but changed to Perl XML XPath as dealing with
large structures of nested lists of maps of lists of maps became
rather verbose and difficult to follow. Even with ForceArray=1 it is
possible for two valid instances of the same schema to generate
different map/list structures.

It would be nice to switch to using an SCR agent for
metapackage-handler, but I think it may be impractical to use the
XML::Simple based agent. Perhaps I should look at making an XML::XPath
agent sometime after 11.0.

--
Benjamin Weber

Reply via email to