SleepXomXML

Xml parsing functions for Sleep

Read more info and documentation

 

Current Release: SleepXomXml-B2.tgz

 

Older releases:

SleepXomXml-B1.tgz

 

Version History

Beta 1. November 2008

Beta 2. November 2008

 

  • Sleep [http://sleep.dashnine.org/] is a multi-paradigm scripting language for the Java Platform
  • easy to learn with Perl and Objective-C inspired syntax
  • executes scripts fast with a small package size (~250KB)
  • excels at data manipulation, component integration, and distributed communication
  • seamlessly uses Java objects and 3rd party libraries

Sleep source and binaries are released under the GNU Lesser General Public License


Dependencies

XOM [http://xom.nu] open source (LGPL), tree-based API for processing XML with Java

 

QuickStart

Add sleepxomxml.jar xom-1.1.jar to Sleep's classpath

Or use:


import * from: ./lib/xom-1.1.jar;
import gr.altsol.sleepxomxml.XomXML from: ./dist/sleepxomxml.jar;

Then you can use the following script as a template for your own scripts:


use(^gr.altsol.sleepxomxml.XomXML);

$handle = openf("./test-attributes.xml");
$doc = xomBuild($handle);
closef($handle);
$root = xomGet($doc,"root");

Library Funtions


   xomBuild($handler)                  : $document
   
   createXomBuilder(%hash)             : $builderClosure
   
   createXomSerializer(%hash, $handler): $serializerClosure 
   
   xomStripMarkap("text")              : $string
   
   xomEncodeEntitites("text")          : $string                
   
   omIsNodeType($node,"nodeType")      : $int (boolean)
                          
   xomQuery($node,"xpath")             : @nodes                 

   xomGet($node, "propertyName", ...)  : $scalar     

xomGet

For information on properties and node types look at node-properties.txt


   xomGet($node, "propertyName", ...)
   The number of parameters depends on propertyName.

createXomBuilder

For more information look at xom Documentation of nu.xom.Builder


  create a builder closure look at ./doc/examples/builder.sl
  
  hash initialization parameters: 
    validate    : (0,1) check validity with dtd
    nodeFactory : nu.xom.NodeFactory (look at xom Documentation)

createXomSerializer

For more information look at xom Documentation of nu.xom.Serializer


  create a serializer closure, look at ./doc/examples/serializer.sl

  hash initialization parameters: 
     displayDocTypeInternalDTDSubset : (0,1) display DTD
     encoding
     indent
     lineSeparator
     maxLength
     preserveBaseURI