[xml] A modified version of libxml2 supporting SML
- From: jf larvoire free fr
- To: xml gnome org
- Subject: [xml] A modified version of libxml2 supporting SML
- Date: Mon, 9 Apr 2018 10:28:38 +0200 (CEST)
Hello,
I've released at https://github.com/JFLarvoire/libxml2/releases a fork of libxml2 with experimental support for parsing and generating SML.
For information about SML, a Simpler representation of XML, see the presentation starting at page 137 of:
http://archive.xmlprague.cz/2018/files/xmlprague-2018-proceedings.pdf
This version of libxml2 can parse both XML and SML, and save either kind.
By default, it reads and writes XML, and should be perfectly compatible with the standard libxml2 library.
A new program called sml2 can convert XML to SML, or SML to XML.
Run it with option -? or -h to display help about all options.
I'm particularly proud of the -f option, to reformat and reindent canonically the output. (Whether XML or SML)
This makes sml2 particularly useful to study complex XML files.
Thanks to the fundamental identity between XML and SML, the changes to the library are relatively small.
For example, for the parser.c file:
- The initial parser.c had 15576 lines.
- The modified parser.c has 16156 lines.
- The diff shows 323 lines deleted, and 903 added.
- Of these, 168 lines are just debug macros that can eventually be removed.
For detailed information about how to invoke the new libxml2 SML parsing and output capabilities, and about the current limitations, see the README file in the project root.
As an example, see the sml2.c source file, which uses all the new capabilities.
The release includes a pre-built version of sml2.exe for Windows.
Example of use:
C:\JFL\Temp>type doc.xml
<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>
C:\JFL\Temp>type doc.xml | sml2
catalog {book id="bk101" {author "Gambardella, Matthew";title "XML Developer's Guide";genre Computer;price 44.95;publish_date 2000-10-01;description "An in-depth look at creating applications with XML."}}
C:\JFL\Temp>type doc.xml | sml2 | sml2
<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book></catalog>
C:\JFL\Temp>type doc.xml | sml2 -f
catalog {
book id="bk101" {
author "Gambardella, Matthew"
title "XML Developer's Guide"
genre Computer
price 44.95
publish_date 2000-10-01
description "An in-depth look at creating applications with XML."
}
}
C:\JFL\Temp>type doc.xml | sml2 -f -x
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
C:\JFL\Temp>
Any comment welcome.
Enjoy!
Jean-François
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]