Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.core
Class Text

java.lang.Object
  extended by imp.core.Value
      extended by imp.core.Structure
          extended by imp.core.Text
All Implemented Interfaces:
Cloneable, Comparable<Value>

public class Text
extends Structure

Implements a textual value.

A textual-value is structured, annotated string with links.


Field Summary
 
Fields inherited from class imp.core.Value
NULL
 
Constructor Summary
Text()
          Constructs an empty textual value.
 
Method Summary
static Text create(String string)
          Creates a text from an HTML string and return this.
static String html2xhtml(String text)
          Converts an HTML text to UTF-8 XHTML.
 String htmlValue(String pattern)
          Returns this text as a XHTML string.
static Value latex2xml(String text)
          Converts some LaTeX text to a XML structure.
static void main(String[] arguments)
          Translates a textual document in this context.
static String xhtml2string(String text)
          Converts an HTML text to a raw text.
 
Methods inherited from class imp.core.Structure
clear, indexOf, setType, sort
 
Methods inherited from class imp.core.Value
cloneThis, get, getWrapping, isCyclic, isName, load, save, toString, wrappedObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Text

public Text()
Constructs an empty textual value.

Method Detail

create

public static Text create(String string)
Creates a text from an HTML string and return this.
Only the text contents and structure is extracted the style/presentation aspects are simply concatenated in the style field.

Parameters:
string - A string containing an HTML piece of text.

html2xhtml

public static String html2xhtml(String text)
Converts an HTML text to UTF-8 XHTML.


htmlValue

public String htmlValue(String pattern)
Returns this text as a XHTML string.

Parameters:
pattern - Optional target XHTML pattern of the form: <html><head>$head</head><body>$body</body><html> where the $head and $body variables must be inserted to allows the text to be properly inserted in the XHTML pattern.
Such pattern may contain a page header, border, trailer, style information, ..
The $head is used to define the document title and style elements. The $body is used to insert the document contents.

latex2xml

public static Value latex2xml(String text)
Converts some LaTeX text to a XML structure.
The conversion is only ``at the syntax level´´ in that it extracts a structure from the latex syntax without any reference to the underlying semantic (which is to be treated via some XSL transform) and is limited to the following syntax:
  • \begin{name} .. \end{name} -> <name> .. </name>
  • \name[attribute=value,..]{..} -> <name> .. </name>
  • \name .. or \name{**} .. -> <name title="**"> .. </name>
  • {\name } -> <name> .. </name>
It is thus to be understood only as a way to write XML in a LaTeX style.


main

public static void main(String[] arguments)
Translates a textual document in this context.
Usage: $JAVA imp.core.Text -tex2xml <document-file> to translate a LaTeX syntax to a XML syntax document.


xhtml2string

public static String xhtml2string(String text)
Converts an HTML text to a raw text.