Mailinglist Archive: yast-devel (129 mails)

< Previous Next >
[yast-devel] SCR Agent: any-XML Parser
  • From: Lukas Ocilka <lukas.ocilka@xxxxxxx>
  • Date: Fri, 16 Nov 2007 18:34:25 +0100
  • Message-id: <473DD4A1.9020905@xxxxxxx>
Hi,

I'd like to announce moving the *anyxml* SCR agent to *yast2.rpm*. This
has been done because not only yast2-packager but also yast2-users found
it suitable for parsing generic XML (see bugzilla #332187).

What is this XML parser good for?
It uses Perl module XML::Bare so it can parse every valid XML content,
not only YaST-specific formats.

Where can I find it?
In yast2-2.16.11.rpm and later.

How can I use it?
See
http://forgeftp.novell.com/yast/doc/SL10.3/scr/2.anyxml.html

Is that new feature? Do we use it anywhere else?
No, anyxml is in openSUSE since 10.3. We use it for Online Repositories.

Example:
--- anyxml.ycp ---
{
any xml = SCR::Read (.anyxml, "any.xml");

y2milestone ("XML: %1", xml);
}
--- anyxml.ycp ---

--- any.xml ---
<?xml version="1.0"?>
<book>
<author>
<firstname>John</firstname>
<surname>Fish</surname>
</author>
<copyright>2007</copyright>
<content>
<chapter>
<title>Learn YCP in 20 Minutes</title>
<para>hahaha</para>
</chapter>
</content>
</book>
--- any.xml ---

Run: `/sbin/yast2 ./anyxml.ycp`
and see the result in y2log...

--- result in y2log ---
test/anyxml.ycp:4 XML: $[
"book":$[
"author":$[
"firstname":$[
"pos":0,
"value":"John"
],
"pos":0,
"surname":$[
"pos":1,
"value":"Fish"
],
"value":"\n\t"
],
"content":$[
"chapter":$[
"para":$[
"pos":1,
"value":"hahaha"
],
"pos":0,
"title":$[
"pos":0,
"value":"Learn YCP in 20 Minutes"
],
"value":"\n\t "
],
"pos":2,
"value":"\n\t"
],
"copyright":$[
"pos":1,
"value":2007
],
"pos":0,
"value":"\n "
],
"value":""
]
--- result in y2log ---

author_firstname = foo["book","author","firstname","value"]:"Unknown";

Have a nice day
Lukas

--

Lukas Ocilka, YaST Developer (xn--luk-gla45d)
-----------------------------------------------------------------
SUSE LINUX, s. r. o., Lihovarska 1060/12, Praha 9, Czech Republic

< Previous Next >
This Thread
  • No further messages