Data::Sofu::SofuML - Interface to various binary drivers
This Module is used to convert Sofu Trees to XML Tree.
This is mostly for convertig Sofu data via XSLT or similar.
You don't need to use this module directly.
use Data::Sofu; my $sofu = readSofu("file.sofu"); writeSofuML("file.xml",$sofu,getSofucomments()); #And back my $xml = readSofu("file.xml"); #readSofu can detect SofuML files. writeSofu("file.sofu",$xml,getSofucomments());
Using the Sofu OO syntax:
require Data::Sofu; my $s = Data::Sofu::new(); my $sofu = $s->read("file.sofu"); $s->writeML("file.xml",$sofu,$s->comments()); #And back my $xml = $s->read("file.xml"); #read also detects SofuML files. $s->write("file.sofu",$xml,$s->comments());
Using scalars instead of files:
require Data::Sofu; my $s = Data::Sofu::new(); my $sofu = $s->read("file.sofu"); my $xmlstring = $s->packML($sofu,$s->comments()); #Contains now the xml files content my $xml = $s->unpack($xmlstring); $s->write($xml,$s->comments());
But: $scalar=packML() is not the same as writeML(\$scalar), packML will not indent the file.
This Module is pure OO, exports nothing
Most of these Methods (except pack()) are ony for internal use.
Creates a new Data::Sofu::SofuML and returns it.
Data::Sofu::SofuML
XMLescape(STRING,LEVEL)
Returns the (quite badly) escaped form of STRING
XMLKeyescape(KEY)
Returns the (quite badly) escaped form of KEY
Returns a new unqiue ID
Returns the indentation for LEVEL
Returns the packed comment of OBJECT
Returns the packed comment of the object reference by TREE
packElement(ELEMENT,OBJECT,LEVEL,ID)
Returns the ELEMENT for OBJECT
packItem(ELEMENT,LEVEL,ID,TREE)
Returns the an XML item
packObjectData(OBJECT,LEVEL)
Converts one Data::Sofu::Object into its XML representation
packData(DATA,LEVEL,TREE)
Converts one perl structure into its XML representation
packObject(OBJECT,[HEADER])
packs TREE to XML using Comments
Perl datastructure to pack. Can be a hash, array or scalar (or array of hashes of hashes of arrays or whatever). Anything NOT a hash will be converted to TREE={Value=>TREE};
It can also be a Data::Sofu::Object or derived (Data::Sofu::Map, Data::Sofu::List, Data::Sofu::Value, Data::Sofu::...). Anything not a Data::Sofu::Map will be converted to one (A Map with one attribute called "Value" that holds TREE).
Comment hash (as returned by Data::Sofu::getSofucomments() or Data::Sofu->new()->comments() after any file was read).
These are ignored if TREE is a Data::Sofu::Object or derived. Data::Sofu::Object's store their comments in themselves. See Data::Sofu::Object->importComments() to import them.
Can be undef or {}.
Unpacks a SofuML string to perl datastructures
Don't use this, use readSofu("file.xml") instead.
Unpacks SofuML string to Data::Sofu::Object's from STRING
Reading SofuML files need XML::Parser.
Data::Sofu, Data::Sofu::Object, http://sofu.sf.net
To install Data::Sofu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Sofu
CPAN shell
perl -MCPAN -e shell install Data::Sofu
For more information on module installation, please visit the detailed CPAN module installation guide.