XPL Automatic Special Character Preprocessing for XML
You can now process XML data structures that contain special characters without escaping or defining CDATA. This makes files containing program logic and other special entities much easier to create and maintain.
Note: XML is used extensively in the HLL Project, sometimes in innovative ways that can make complex systems easier to create, understand, and maintain. XPL resulted from the project's use of XML to store source code that is read and processed by other system components. XML has been fantastic. XPL simply makes files containing source code easier to create, view, and maintain. Experience indicates that this is a very useful feature.
It is not a trivial issue. Many projects that rely on storing code as data start out using XML only to turn to alternatives later. It's a great idea. But what seemed like a small problem in the beginning simply creates too much mess and inconvinience. (Seriously, this happens in the real world.) The right answer is a preprocessor that allows you to store code as text in exactly the same form that you normally write code and without any extra elements that make the code harder to read.
Write and store your code as XPL.
<?xpl version="1.0" encoding="utf-8"?> <mycode xmlns="http://xmlns.hll.nu/rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <state name="dum1" type="int" value="3" /> <state name="dum21" type="String" value="dum11" /> <!-- My first rule --> <rule> <if> dum1 <5 && dum1 > 1 || dum1 < 200</if> <then> dum21 = "Unescaped special characters like '<' can be used." </then> </rule> </mycode>Either use the data directly through the StAX-PL reader or transform it into valid XML.
We have entered a new age in software technology in which logic needs to be treated as data. XML technology provides strong support for organizing, storing, communicating, and processing data. But as its name implies, eXtensible Markup Language was developed for "markup"; preparing text for presentation and not for processing logic. A variety of symbols common to the representation of logic in computer programs are reserved as special characters in XML, creating a barrier to its extended use. Although surmountable, this inconvenience has resulted in a migration to other alternatives.
What is needed is a convenient way to take advantage of all the properties and technology available for XML by removing the barrier that makes it inconvenient for logic processing. Faced with this demand in the High Level Logic (HLL) Project, a new parser was developed that allows XML's special characters to be included in what otherwise is an XML structure. This means that programmers, mathematicians, and anyone interested in storing logic in XML can do so easily; by, for example, simply copy-pasting source code into an XPL file.
XPL can be used instead of XML or as a preprocessor into XML. XML has a long history and software languages have a great deal of support built-in. XPL was not developed to compete with XML but rather to support its wider use. The XPL transformer, which is included in this release, removes the inconvenience barrier by producing valid XML, which can then be processed using existing technology that supports the complete XML standard. The XPL processing software can handle tags, attributes, and content on its own. Namespace attributes are passed through as attributes and can then be handled normally by XML processes. It is possible to handle namespaces by modifying the source code provided.
You control the number of spaces used for pretty-print.
All components are written in Java for v7 and v8 and have been tested on Windows and Linux.
The software download includes:
- Quick start documention that will quickly orient you to everything that is included.
- The XPL StAX-PL parser, which reads your XPL files and returns parsing events (Java 7 and 8 versions included).
- Quick Start Source Code for StAX-PL, for processing XPL events.
- Quick Start Source Code for XPL->XML transformation, using StAX-PL with write to XML handler.
- Quick Start Source Code for XML StAX processing.
- Quick Start Source Code for XML SAX that uses Java concurrency for simultaneous XPL preprocessing.
- Quick Start Source Code for XML DOM.
- Batch and shell files for compiling and running the source code on Windows and Linux.
About StAX and StAX-PL:
Once a file has been transformed to XML, you can use any processing method in any language for your application. The components in this release of XPL are written in Java 8.
Streaming API for XML (StAX) is an application programming interface (API) to read and write XML documents, originating from the Java programming language community. A StAX reader "pulls" events (start tags, attributes, content, end tags .) as it is ready to process the next. It is an extremely fast and light weight process. It differs from the older SAX method by pulling data rather than having it pushed into the application by the parser. It differs a great deal from DOM processing, which stores entire files and keeps the data available for random access.
Streaming API for XPL (StAX-PL) is designed in the same way as the XML StAX program included with this release. It pulls data from the XPLP parser rather than an XML parser. Both the StAX and StAX-PL implementations have an abstract reader class that pulls events from the parser and a subclass for handling the events.