# Pyx

#### 1.1

Current release (1.1, unix)

## Overview

### Abstract

PYX is a document format based on XML; it is, in essence, extra-simple XML. PYX is ideal for grepping and parsing, and for very basic markup. Many XML documents can be converted to and from PYX format without any loss of information. PYX records basic tag structure, attributes, text, and processing instructions.

The files in this distribution provide extremely lightweight parsers, generators, and converters for PYX documents, for Java and Ruby.

### Introduction

PYX is is a hyper-simplified XML. Each node is occurs on a line, and PYX documents are very easy to parse. Consider:

XML

    <sometag attribute="value" att2="value2">
      Some text
      <subtag/>
    </sometag>

This translates into PYX as:

PYX

    (sometag
    Aattribute value
    Aatt2 value2
    -\n
    -  Some text\n
    -\n
    -
    (subtag
    )subtag
    -\n
    )sometag

It doesn't look as nice as the XML, but it actually takes fewer characters (usually), and is much easier to parse. This means that Pyx parsers are much, much more lightweight than XML parsers, which is important for some applications, such as applets and embedded devices.

These Pyx utilities are not the first; unfortunately, all of the existing Pyx parsers for Java are, for some reason, based on SAX, and depend on the W3C SAX interfaces. This, in my humble opinion, is Stupid. Why use a lightweight mechanism and then weigh it down with a heavy interface? The Java Pyx parser supplied in this library is ~3.5KB. Very lightweight. All of the classes are independant, with no dependancies, so you use what you like.

### Features

- Parse Pyx files as streams

## Operation

### Unit tests

There are two unit test suites supplied with this package; one for the Ruby implementation, and one for the Java. Assuming you have Ruby install, running the Ruby test package is a matter of:

    ruby test.rb

If you have the JUnit test suite, you can run the Java unit test with:

    java -cp .:junit.jar junit.textui.TestRunner Tester

### Using the library

These Pyx libraries are fairly simple. Implement a `Pyx.Listener` object, instantiate a `Pyx` object, and call `pyx.parse( Reader )`.

The `Pyx.Listener` interface and the methods accepted by the Ruby listener mechanism, are similar to the SAX API. See the API documentation and the unit test source code for more information.

There is both Java API and Ruby API documentation.

## Status

### Change Log

1.1: Added xml2pyx.rb (requires REMXL

1.0: Initial release

### Known Bugs

- None

### To Do

- Add Pyx<->XML converter
- Add Pyx generator