Class XMQ
java.lang.Object
org.libxmq.XMQ
The XMQ class is used to parse/print/render XMQ/XML/HTML/JSON documents.
-
Constructor Summary
ConstructorsConstructorDescriptionXMQ()Construct an XMQ with the default DOM implementation.Construct an XMQ with a DocumentBuilderFactory if you need to override the default DOM implementation. -
Method Summary
Modifier and TypeMethodDescriptionparseBuffer(String buffer, InputSettings is) Parse a buffer containing XMQ/XML/HTML/JSON/CLINES.parseFile(Path file, InputSettings is) Parse a file containing XMQ/XML/HTML/JSON/CLINES.static StringRender a locale adapted text cli error printout of a parse exception using the default locale.static StringprintException(ParseException e, Locale locale) Render a locale adapted text cli error printout of a parse exception.queryBuffer(String buffer, InputSettings is) Parse a buffer containing XMQ/XML/HTML/JSON/CLINES and return a Query object for the DOM.queryFile(Path file, InputSettings is) Parse a file containing XMQ/XML/HTML/JSON/CLINES and return a Query object to the DOM.renderHTML(Document doc, OutputSettings os) Render the document as XMQ in HTML.renderTEX(Document doc, OutputSettings os) Render the document as XMQ in TeX.toCLINES(Document doc, OutputSettings os) Print the document as clines.toHTML(Document doc, OutputSettings os) Print the document as HTML.toJSON(Document doc, OutputSettings os) Print the document as json.toXML(Document doc, OutputSettings os) Print the document as XML.toXMQ(Document doc, OutputSettings os) Print the document as XMQ.
-
Constructor Details
-
XMQ
public XMQ()Construct an XMQ with the default DOM implementation. -
XMQ
Construct an XMQ with a DocumentBuilderFactory if you need to override the default DOM implementation.- Parameters:
f- The document builder factory.
-
-
Method Details
-
parseFile
Parse a file containing XMQ/XML/HTML/JSON/CLINES.- Parameters:
file- The file to parse.is- The input settings, should white space be trimmed, should text nodes be merged etc.- Returns:
- A DOM document.
- Throws:
IOException- if file cannot be read.ParseException- if the parse failed.
-
parseBuffer
Parse a buffer containing XMQ/XML/HTML/JSON/CLINES.- Parameters:
buffer- The string to parse.is- The input settings, should white space be trimmed, should text nodes be merged etc.- Returns:
- A DOM document.
- Throws:
ParseException- if the parse failed.
-
queryFile
Parse a file containing XMQ/XML/HTML/JSON/CLINES and return a Query object to the DOM.- Parameters:
file- The file to parse.is- The input settings, should white space be trimmed, should text nodes be merged etc.- Returns:
- A Query object.
- Throws:
IOException- if file cannot be read.ParseException- if the parse failed.
-
queryBuffer
Parse a buffer containing XMQ/XML/HTML/JSON/CLINES and return a Query object for the DOM.- Parameters:
buffer- The string to parse.is- The input settings, should white space be trimmed, should text nodes be merged etc.- Returns:
- A Query object.
- Throws:
ParseException- if the parse failed.
-
toXMQ
Print the document as XMQ.- Parameters:
doc- Document to print.os- Settings for printing.- Returns:
- A string with XMQ.
-
toXML
Print the document as XML. This means that the argument doc is assumed to store an XML document. By printing it as XML the document will follow the XML rules.- Parameters:
doc- Document to print.os- Settings for printing.- Returns:
- A string with XML.
-
toHTML
Print the document as HTML. This means that the argument doc is assumed to store a HTML document. By printing it as HTML the document will follow the HTML rules (using self closing tags like <br> and potentially using HTML entities like )- Parameters:
doc- Document to print.os- Settings for printing.- Returns:
- A string with HTML.
-
toJSON
Print the document as json.- Parameters:
doc- Document to print.os- Settings for printing.- Returns:
- A string with JSON.
-
toCLINES
Print the document as clines.- Parameters:
doc- Document to print.os- Settings for printing.- Returns:
- A string with clines.
-
renderHTML
Render the document as XMQ in HTML. I.e. build a new HTML document that when viewed in a browser makes it easy to read the XMQ.- Parameters:
doc- Document to renderos- Settings for rendering- Returns:
- A string with HTML.
-
renderTEX
Render the document as XMQ in TeX. When the TeX document is rendered using for example xetex/xelatex, it will generate a pdf containing the human readable XMQ.- Parameters:
doc- Document to renderos- Settings for rendering- Returns:
- A string with TeX commands.
-
printException
Render a locale adapted text cli error printout of a parse exception.- Parameters:
e- The parse exception.locale- The locale to use.- Returns:
- A string to be printed on the console.
-
printException
Render a locale adapted text cli error printout of a parse exception using the default locale.- Parameters:
e- The parse exception.- Returns:
- A string to be printed on the console.
-