User's Guide
CLASSPATH
Here's a list of what must be in your CLASSPATH.
- box.jar
- xerces.jar
- xalan.jar
- log4j.jar or lumberjack.jar
BOX Details
See example.
Usage Code Examples
To encode a DOM document into BOX,
Document doc = ...;
OutputStream os = ...;
boolean useASCII = true or false;
boolean trimWhitespace = true or false;
BOXDOMEncoder encoder = new BOXDOMEncoderImpl();
encoder.encode(doc, os, useASCII, trimWhitespace);
To decode BOX into a DOM document,
InputStream is = ...;
BOXDOMDecoder decoder = new BOXDOMDecoderImpl();
Document doc = decoder.decode(is);
To decode BOX into a series of SAX events,
InputStream is = ...;
ContentHandler contentHandler = ...;
LexicalHandler lexicalHandler = ...;
BOXSAXDecoder decoder = new BOXSAXDecoderImpl();
Document doc = decoder.decode(is, contentHandler, lexicalHandler);
The ContentHandler is required.
The Lexical Handler can be null if you do not wish to process comments.
To encode BOX without a DOM Document,
OutputStream os = ...;
boolean useASCII = true or false;
boolean trimWhitespace = true or false;
BOXEmitter be = new BOXEmitter(os, useASCII, trimWhitespace);
// Now make lots of calls like the following.
be.emitComment(text);
be.emitProcessingInstruction(target, value);
be.emitNamespaceDeclaration(prefix, uri);
be.emitAttribute(name);
be.emitElementStart(name);
be.emitText(text);
be.emitElementEnd();
Make sure that emitNamespaceDeclaration and
emitAttribute are called
before calling emitElementStart
for the element to which they belong!