multivalent.std.adaptor
Class XML
java.lang.Object
multivalent.VObject
multivalent.Behavior
multivalent.MediaAdaptor
multivalent.std.adaptor.ML
multivalent.std.adaptor.XML
- public class XML
- extends ML
An ever-closer approximation to the XML specification, which itself is a moving target.
Handles "xinclude:include".
Note: This may be replaced with Sun's XML Parser to pick up namespaces and all the little points of the spec.
XML is used as the storage format for hubs and annotations.
- Version:
- $Revision: 1.6 $ $Date: 2002/10/31 03:12:30 $
Fields inherited from class multivalent.MediaAdaptor |
HINT_DEFAULTS, HINT_EXACT, HINT_FAST, HINT_METADATA_ONLY, HINT_NO_IMAGE, HINT_NO_INTERACTIVE, HINT_NO_LAYOUT, HINT_NO_SHAPE, HINT_NO_SHOW, HINT_NO_STYLE, HINT_NO_TEXT, HINT_NO_TRANSCLUSION, HINT_NONE, HINT_NORMALIZE |
Constructor Summary |
XML()
|
Method Summary |
static void |
encode(java.lang.String str,
java.lang.StringBuffer sb,
boolean q)
Encode characters from str as entity references (e.g., "<" => "<") and write to sb,
optionally surrounded by quotes (single quotes if no embedded single quote, else double quotes). |
static void |
indent(int level,
java.lang.StringBuffer sb)
Write out attribute names in this table first, in this order. |
java.lang.Object |
parse(INode parent)
Parses a document's data format and constructs a document tree. |
static ESISNode |
parseDOM(java.net.URI uri)
XML can be also be treated not as a media adaptor but as an XML parsing utility. |
static void |
write(java.lang.String name,
java.util.Map<java.lang.String,java.lang.Object> attrs,
java.lang.StringBuffer sb,
int level)
Write opening tag with generic identifier name and attributes attrs
into StringBuffer sb. |
Methods inherited from class multivalent.std.adaptor.ML |
close, eatComment, eatSpace, getEntity, getReader, getTag, getTag, pairsWith, readChar, readString, readString, readString, readString, readStringInternal, setEntity |
Methods inherited from class multivalent.MediaAdaptor |
buildBefore, destroy, getHints, getInputUni, getURI, getZoom, isAuthorized, isStopped, parseHelper, semanticEventAfter, setHints, setInput, setInput, setPassword, setZoom, stop |
Methods inherited from class multivalent.Behavior |
buildAfter, checkRep, clipboardAfter, clipboardBefore, createUI, eventAfter, eventBefore, formatAfter, formatBefore, getBrowser, getDocument, getInstance, getInstance, getLayer, getLogger, getName, getPreference, getRoot, isEditable, paintAfter, paintBefore, putPreference, redo, restore, restoreChildren, save, semanticEventBefore, setName, toString, undo |
Methods inherited from class multivalent.VObject |
attrEntrySetIterator, attrKeysIterator, clearAttributes, getAttr, getAttr, getAttributes, getGlobal, getValue, hasAttributes, putAttr, removeAttr, setAttributes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
XML
public XML()
parse
public java.lang.Object parse(INode parent)
throws java.lang.Exception
- Description copied from class:
MediaAdaptor
- Parses a document's data format and constructs a document tree.
Structure is represented in internal nodes and content (text, images, video, ...) at the leaves.
Before using, invoke MediaAdaptor.setInput(InputUni)
.
The newly constructed document tree should attach to parent.
The parent is usually but not necessarily a Document
.
Paginated documents should build the current page only, as indicated by the attribute Document.ATTR_PAGE
, and report their page count to Document.ATTR_PAGECOUNT
.
Metadata, such as author and dates, should be stored in the closed containing Document
.
If encountering an unfixable/unrecoverable parsing error, usually due to an invalid data format, throws a ParseException
.
(This does not supercede IOException
.)
When media adaptor is done or has thrown an exception, the client must MediaAdaptor.close()
it.
Subclasses should not rely on being able to obtain a Root
, Browser
, or Multivalent
;
in such cases it is acceptable to reduce functionality.
- Specified by:
parse
in class MediaAdaptor
- Returns:
- whatever Object is appropriate to the media adaptor.
For HTML it is the root of the HTML tree (which has name "html"),
for documents with no single root it can be parent,
for an image constuctor it could be an
Image
.
However, the primary job of a media adaptor is to add content to the document tree.
- Throws:
java.lang.Exception
- See Also:
for a convenient way to attach spans
parseDOM
public static ESISNode parseDOM(java.net.URI uri)
throws java.io.IOException
- XML can be also be treated not as a media adaptor but as an XML parsing utility.
For general XML parsing instead use
javax.xml.parsers.SAXParser
or javax.xml.parsers.DocumentBuilder
.
- Throws:
java.io.IOException
write
public static void write(java.lang.String name,
java.util.Map<java.lang.String,java.lang.Object> attrs,
java.lang.StringBuffer sb,
int level)
- Write opening tag with generic identifier name and attributes attrs
into
StringBuffer
sb. Indent according to nesting level.
Does not write a final ">" so client can add more attributes, close tag and add content, or write as empty ("... />").
encode
public static void encode(java.lang.String str,
java.lang.StringBuffer sb,
boolean q)
- Encode characters from str as entity references (e.g., "<" => "<") and write to sb,
optionally surrounded by quotes (single quotes if no embedded single quote, else double quotes).
indent
public static void indent(int level,
java.lang.StringBuffer sb)
- Write out attribute names in this table first, in this order. Should be a parameter.