libxmq · xmq.h

The C
api.

Include xmq.h and compile xmq.c into your program, to parse, query, transform and print xmq, xml, html and json. This page is generated from xmq.h itself: the header is parsed with the ixml grammar ixml:lang/c and transformed with an xslq stylesheet.

scripts/generate_xmq_h_api_doc.sh

Examples:load_config_file.c create_dom.c create_html.c create_json.c default_namespace.c namespace_prefixes.c add_namespace.c generated_prefixes.c parse_with_ixml.c line_printf.c

Functions

147Parse, navigate, modify, transform and print documents.
xmqDetectContentTypeDetect the content type xmq/xml/html/json by examining a few leading non-whitespace words/characters.
XMQContentType xmqDetectContentType(const char *start, const char *stop);
Detect the content type xmq/xml/html/json by examining a few leading non-whitespace words/characters.

Parameters

start
Points to the first byte of the buffer to scan.
stop
Points to the byte after the buffer.

Returns

The detected content type, XMQ_CONTENT_UNKNOWN if it could not be detected.

xmqParseErrorToStringTranslate an error code to a human readable string.
const char *xmqParseErrorToString(XMQStatus e);
Translate an error code to a human readable string.

Parameters

e
The error code.

Returns

A static string describing the error.

xmqNewParseCallbacksAllocate an empty parse callbacks structure.
XMQParseCallbacks *xmqNewParseCallbacks();
Allocate an empty parse callbacks structure. All callbacks are NULL and none will be called.

Returns

The new callbacks, free them with xmqFreeParseCallbacks.

xmqFreeParseCallbacksFree the parse callbacks structure.
void xmqFreeParseCallbacks(XMQParseCallbacks *cb);
Free the parse callbacks structure.

Parameters

cb
The callbacks to free.
xmqSetupParseCallbacksColorizeTokensSet up the callbacks to colorize xmq input, without building a parse tree.
void xmqSetupParseCallbacksColorizeTokens(XMQParseCallbacks *state, XMQRenderFormat render_format);
Set up the callbacks to colorize xmq input, without building a parse tree.

Parameters

state
The callbacks to set up.
render_format
The format to colorize for, eg terminal or html.
xmqSetupParseCallbacksDebugTokensSet up the callbacks to print the location and type of each token, for debugging.
void xmqSetupParseCallbacksDebugTokens(XMQParseCallbacks *state);
Set up the callbacks to print the location and type of each token, for debugging.

Parameters

state
The callbacks to set up.
xmqSetupParseCallbacksDebugContentSet up the callbacks to print the decoded content of each token, for debugging.
void xmqSetupParseCallbacksDebugContent(XMQParseCallbacks *state);
Set up the callbacks to print the decoded content of each token, for debugging.

Parameters

state
The callbacks to set up.
xmqTokenizeBufferTokenize a buffer with xmq content, invoking the callbacks of the parse state for each token.
bool xmqTokenizeBuffer(XMQParseState *state, const char *start, const char *stop);
Tokenize a buffer with xmq content, invoking the callbacks of the parse state for each token.

Parameters

state
The parse state with the callbacks.
start
Points to the first byte of the buffer.
stop
Points to the byte after the buffer.

Returns

True if the buffer was tokenized without errors.

xmqTokenizeFileTokenize a file with xmq content, invoking the callbacks of the parse state for each token.
bool xmqTokenizeFile(XMQParseState *state, const char *file);
Tokenize a file with xmq content, invoking the callbacks of the parse state for each token.

Parameters

state
The parse state with the callbacks.
file
The file to tokenize.

Returns

True if the file was tokenized without errors.

xmqTokenizeFileDescriptorTokenize xmq content read from a file descriptor.
bool xmqTokenizeFileDescriptor(XMQParseState *state, int fd);
Tokenize xmq content read from a file descriptor. Not implemented yet, the function is declared but has no implementation.

Parameters

state
The parse state with the callbacks.
fd
The file descriptor to read from.

Returns

True if the content was tokenized without errors.

xmqNewParseStateCreate a parse state, used to tokenize xmq with your own callbacks.
XMQParseState *xmqNewParseState(XMQParseCallbacks *callbacks, XMQOutputSettings *settings);
Create a parse state, used to tokenize xmq with your own callbacks. The output settings can be referenced from the callbacks, for example when colorizing.

Parameters

callbacks
The callbacks invoked for each token.
settings
The settings available to the callbacks.

Returns

The new parse state, free it with xmqFreeParseState.

xmqFreeParseStateFree the parse state.
void xmqFreeParseState(XMQParseState *state);
Free the parse state.

Parameters

state
The parse state to free.
xmqSetStateSourceNameSet the source name used in the error messages when parsing fails.
void xmqSetStateSourceName(XMQParseState *state, const char *source_name);
Set the source name used in the error messages when parsing fails. The source name is often the file name, but can be "-" for stdin or anything you like.

Parameters

state
The parse state.
source_name
The source name.
xmqStateErrnoGet the error code of a failed parse.
int xmqStateErrno(XMQParseState *state);
Get the error code of a failed parse.

Parameters

state
The parse state.

Returns

The error as the integer value of an XMQStatus.

xmqStateErrorMsgGet a message explaining why a parse failed.
const char *xmqStateErrorMsg(XMQParseState *state);
Get a message explaining why a parse failed.

Parameters

state
The parse state.

Returns

The error message, owned by the parse state.

xmqSetPrintAllParsesIXMLSet if all trees should be generated when an ixml parse is ambiguous.
void xmqSetPrintAllParsesIXML(XMQParseState *state, bool all_parses);
Set if all trees should be generated when an ixml parse is ambiguous.

Parameters

state
The parse state.
all_parses
If true generate all possible trees.
xmqSetTryToRecoverIXMLSet if a failed ixml parse should try to recover.
void xmqSetTryToRecoverIXML(XMQParseState *state, bool try_recover);
Set if a failed ixml parse should try to recover. The default is to fail.

Parameters

state
The parse state.
try_recover
If true try to recover a failed parse.
xmqNewDocCreate an empty document.
XMQReturnDoc xmqNewDoc();
Create an empty document. if it is XMQ_ERROR_OOM the document is NULL. Free the document with xmqFreeDoc.

Returns

The status and the document. If the status is XMQ_OK then the document is valid,

xmqSetDocSourceNameSet the source name used in the error messages when parsing fails.
void xmqSetDocSourceName(XMQDoc *doq, const char *source_name);
Set the source name used in the error messages when parsing fails. The source name is often the file name, but can be "-" for stdin or anything you like.

Parameters

doq
The document.
source_name
The source name.
xmqGetDocSourceNameGet the source name of the document, used in the error messages when parsing fails.
const char *xmqGetDocSourceName(XMQDoc *doq);
Get the source name of the document, used in the error messages when parsing fails.

Parameters

doq
The document.

Returns

The source name, or NULL if none was set.

xmqGetOriginalContentTypeGet the content type (xmq, htmq, xml, html, json, text...) that the document was parsed from.
XMQContentType xmqGetOriginalContentType(XMQDoc *doq);
Get the content type (xmq, htmq, xml, html, json, text...) that the document was parsed from.

Parameters

doq
The document.

Returns

The original content type, if available.

xmqGetOriginalSizeGet the size of the content that the document was parsed from, ie the loaded file size.
size_t xmqGetOriginalSize(XMQDoc *doq);
Get the size of the content that the document was parsed from, ie the loaded file size.

Parameters

doq
The document.

Returns

The original size in bytes, if available.

xmqSetOriginalSizeOverride the original size of the document.
void xmqSetOriginalSize(XMQDoc *doq, size_t size);
Override the original size of the document.

Parameters

doq
The document.
size
The size in bytes.
xmqGetRootNodeGet the root node, suitable as the relative node for xmqForeachRel.
XMQNode *xmqGetRootNode(XMQDoc *doq);
Get the root node, suitable as the relative node for xmqForeachRel.

Parameters

doq
The document.

Returns

The root node.

xmqSetDocTypeSet the doctype of the document.
XMQStatus xmqSetDocType(XMQDoc *doq, const char *name);
Set the doctype of the document. xmqSetDocType(doc, "html");

Parameters

doq
The document.
name
The doctype name.

Returns

XMQ_OK if the doctype was set.

xmqAddRootElementCreate a new root element.
XMQReturnNode xmqAddRootElement(XMQDoc *doq, const char *name, XMQNS ns);
Create a new root element. xmqAddElement(doc, p, "el", NS_NONE); // No namespace. xmqAddElement(doc, p, "el", NS_HERE("urn:myapp:driver")); xmqAddElement(doc, p, "el", NS_HERE("{drv}urn:myapp:driver")); NS_ANCESTOR is not permitted for the root node.

Parameters

doq
The xmq document.
name
The name of the new element.
ns
The namespace setting.

Returns

The status and the new element.

xmqAddElementCreate a new element node below an existing element.
XMQReturnNode xmqAddElement(XMQDoc *doq, XMQNode *parent, const char *name, XMQNS ns);
Create a new element node below an existing element. xmqAddElement(doc, p, "el", NS_NONE); // No namespace. xmqAddElement(doc, p, "el", NS_PARENT); // Inherit parent namespace. xmqAddElement(doc, p, "el", NS_HERE("urn:myapp:driver")); xmqAddElement(doc, p, "el", NS_HERE("{drv}urn:myapp:driver")); xmqAddElement(doc, p, "el", NS_ANCESTOR("urn:myapp:driver")); xmqAddElement(doc, p, "el", NS_ANCESTOR("{drv}urn:myapp:driver"));

Parameters

doq
The xmq document.
parent
The existing element.
name
The name of the new element.
ns
The namespace setting.

Returns

The status and the new element.

xmqAddElementWithAttrsCreate a new element node below an existing element with attributes.
XMQReturnNode xmqAddElementWithAttrs(XMQDoc *doq, XMQNode *parent, const char *name, XMQNS ns, XMQAttrList attrs);
Create a new element node below an existing element with attributes. xmqAddElementWithAttrs(doc, p, "div", NS_PARENT, XMQ_ATTRS( { "id", "123" }, { "class", "info" } )); xmqAddElementWithAttrs(doc, p, "a", NS_PARENT, XMQ_ATTRS( { "href", "https://libxmq.org" } ));

Parameters

doq
The xmq document.
parent
The existing element.
name
The name of the new element.
ns
The namespace setting.
attrs
The attributes, see XMQ_ATTRS.

Returns

The status and the new element.

xmqMoveElementMove an element node somewhere else.
bool xmqMoveElement(XMQDoc *from_doq, XMQNode *from_parent, XMQNode *element, XMQDoc *to_doq, XMQNode *to_parent, XMQMoveTo where, XMQNode *sibling);
Move an element node somewhere else. Either within the same document or between two documents. The element will carry its namespace with it. xmqMoveElement(doc, chapter1, page, chapter2, XMQ_POSITION_LAST, NULL); xmqMoveElement(doc, chapter1, page, chapter2, XMQ_POSITION_BEFORE, page32);

Parameters

from_doq
The xmq document to move from.
from_parent
The parent holding the element to be moved.
element
The element to be moved.
to_doq
The xmq document to move to, can be the same as from_doq.
to_parent
The new parent for the element.
where
Where to place the element below the new parent.
sibling
If where is in relation to a sibling, this is the sibling. Can be NULL if not needed.

Returns

True if the element was moved.

xmqAddKeyValueCreate a key value under an existing node.
XMQReturnNode xmqAddKeyValue(XMQDoc *doq, XMQNode *parent, const char *key, const char *value, XMQNS ns);
Create a key value under an existing node. xmqAddKeyValue(doc, p, "price", "123", NS_PARENT);

Parameters

doq
The xmq document.
parent
The parent in which the key value is created.
key
The key.
value
The value.
ns
The namespace setting.

Returns

The status and the new node.

xmqAddTextAdd text last in an existing node.
XMQStatus xmqAddText(XMQDoc *doq, XMQNode *parent, const char *text, size_t len);
Add text last in an existing node. If the last child of the node is already a text node, then the text is appended to it. xmqAddText(doc, p, "hello", 5);

Parameters

doq
The xmq document.
parent
The node to add the text to.
text
The text, utf8, does not need to be zero terminated.
len
The number of bytes of the text.

Returns

XMQ_OK if the text was added.

xmqHasAttributeCheck if an element has an attribute (without a namespace).
bool xmqHasAttribute(XMQNode *node, const char *name);
Check if an element has an attribute (without a namespace).

Parameters

node
The element.
name
The attribute name.

Returns

True if the attribute exists.

xmqContentMarkMark the end of the current content of a node.
XMQContentMark xmqContentMark(XMQNode *node);
Mark the end of the current content of a node.

Parameters

node
The node.

Returns

The mark, to be given to xmqWrapContent.

xmqWrapContentMove the content (children and attributes) added to the node after the mark into a new element, which is added last to the node.
XMQReturnNode xmqWrapContent(XMQDoc *doq, XMQNode *node, XMQContentMark mark, const char *name);
Move the content (children and attributes) added to the node after the mark into a new element, which is added last to the node. The mark stays valid, so wrapping again nests the elements: XMQContentMark m = xmqContentMark(e); xmqAddText(doc, e, "1", 1); xmqWrapContent(doc, e, m, "sum"); // e { sum = 1 } xmqAddText(doc, e, "+2", 2); xmqWrapContent(doc, e, m, "sum"); // e { sum { sum = 1 '+2' } } This is used by generated parsers to build the left nested ixml tree of left recursive rules.

Parameters

doq
The xmq document.
node
The node.
mark
The mark from xmqContentMark on the same node.
name
The name of the new element.

Returns

The new element.

xmqAddKeyValueWithAttrsCreate a key value with attributes under an existing node.
XMQReturnNode xmqAddKeyValueWithAttrs(XMQDoc *doq, XMQNode *parent, const char *key, const char *value, XMQNS ns, XMQAttrList attrs);
Create a key value with attributes under an existing node. xmqAddKeyValueWithAttrs(doc, p, "p", "hello", NS_NONE, XMQ_ATTRS( { "id", "123" } )); // <p id="123">hello</p>

Parameters

doq
The document.
parent
The parent in which the key value is created.
key
The key.
value
The value.
ns
The namespace setting.
attrs
The attributes, see XMQ_ATTRS.

Returns

The new node.

xmqSetAttributeCreate or update an attribute of an existing node.
XMQReturnAttr xmqSetAttribute(XMQDoc *doq, XMQNode *node, const char *name, const char *value, XMQNS ns);
Create or update an attribute of an existing node. NS_HERE is not permitted for an attribute. xmqSetAttribute(doc, node, "id", "123", NS_NONE); // No namespace. xmqSetAttribute(doc, node, "id", "123", NS_PARENT); // The namespace of the node. xmqSetAttribute(doc, node, "id", "123", NS_ANCESTOR("{drv}urn:myapp:driver"));

Parameters

doq
The document.
node
The node to set the attribute on.
name
The attribute name.
value
The attribute value.
ns
The namespace setting.

Returns

The attribute.

xmqAddNamespaceAdd a prefixed namespace declaration to a node.
XMQStatus xmqAddNamespace(XMQDoc *doq, XMQNode *node, XMQNS ns);
Add a prefixed namespace declaration to a node. It must have a prefix, since the default namespace can only be assigned when the node is created. Only NS_HERE is allowed.

Parameters

doq
The document.
node
The node in which the namespace declaration is put.
ns
The namespace, NS_HERE with the prefix encoded in the uri, eg NS_HERE("{drv}urn:myapp:driver").

Returns

XMQ_OK, or an error if the prefix is already taken.

xmqChangePrefixChange the prefix that was chosen automatically for a namespace.
XMQReturnString xmqChangePrefix(XMQDoc *doq, XMQNode *node, const char *ns_uri, const char *old_prefix, const char *new_prefix);
Change the prefix that was chosen automatically for a namespace. Pass XMQ_NO_PREFIX to change the default prefix. Not implemented yet, the function is declared but has no implementation.

Parameters

doq
The document.
node
The node with the namespace declaration.
ns_uri
The namespace uri.
old_prefix
The current prefix.
new_prefix
The new prefix.

Returns

The status, XMQ_ERROR_PREFIX_EXISTS if the new prefix is already used.

xmqClearDocRemove all content from the document, making it empty.
void xmqClearDoc(XMQDoc *doc);
Remove all content from the document, making it empty.

Parameters

doc
The document.
xmqFreeDocFree the document and all memory associated with it.
void xmqFreeDoc(XMQDoc *doc);
Free the document and all memory associated with it.

Parameters

doc
The document to free.
xmqParseFileParse a file and create the document, or read from stdin if file is NULL.
bool xmqParseFile(XMQDoc *doc, const char *file, const char *implicit_root, int flags);
Parse a file and create the document, or read from stdin if file is NULL. The xmq format permits multiple root nodes if an implicit root is supplied.

Parameters

doc
The document to populate.
file
The file to parse, or NULL for stdin.
implicit_root
The implicit root, or NULL.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqParseBufferParse a buffer and create the document.
bool xmqParseBuffer(XMQDoc *doc, const char *start, const char *stop, const char *implicit_root, int flags);
Parse a buffer and create the document. The xmq format permits multiple root nodes if an implicit root is supplied.

Parameters

doc
The document to populate.
start
Points to the first byte of the buffer.
stop
Points to the byte after the buffer.
implicit_root
The implicit root, or NULL.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqParseReaderParse data fetched with a reader and create the document.
bool xmqParseReader(XMQDoc *doc, XMQReader *reader, void *reader_state, const char *implicit_root, int flags);
Parse data fetched with a reader and create the document. The xmq format permits multiple root nodes if an implicit root is supplied. Not implemented yet, the function is declared but has no implementation.

Parameters

doc
The document to populate.
reader
The reader that fetches the input data.
reader_state
The state passed to the reader.
implicit_root
The implicit root, or NULL.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded.

xmqInferMissingElementNamesRename anonymous elements (elements with name _ ) by inferring a name from the parent element: an anonymous child of an element named for example 'items' or 'branches' gets the name 'item' or 'branch' (the trailing 's' is dropped).
bool xmqInferMissingElementNames(XMQDoc *doq, const char *root_name);
Rename anonymous elements (elements with name _ ) by inferring a name from the parent element: an anonymous child of an element named for example 'items' or 'branches' gets the name 'item' or 'branch' (the trailing 's' is dropped). the root element is renamed to root_name.

Parameters

doq
The document to modify in place.
root_name
If not NULL and non-empty, and the root element is anonymous (_),

Returns

True if the document was processed.

xmqNewOutputSettingsAllocate output settings with everything set to zero.
XMQOutputSettings *xmqNewOutputSettings();
Allocate output settings with everything set to zero.

Returns

The new settings, free them with xmqFreeOutputSettings.

xmqFreeOutputSettingsFree the output settings.
void xmqFreeOutputSettings(XMQOutputSettings *os);
Free the output settings.

Parameters

os
The settings to free.
xmqSetAddIndentSet the number of spaces to indent each level when pretty printing.
void xmqSetAddIndent(XMQOutputSettings *os, int add_indent);
Set the number of spaces to indent each level when pretty printing. The xmq tool uses 4 (2 for json and yaml) and 0 together with compact.

Parameters

os
The output settings to modify.
add_indent
The number of spaces per indentation level.
xmqSetCompactSet compact printing, the whole document on a single line with the whitespace between tokens minimized, eg a=('line one'&#10;'line two')b=2
void xmqSetCompact(XMQOutputSettings *os, bool compact);
Set compact printing, the whole document on a single line with the whitespace between tokens minimized, eg a=('line one'&#10;'line two')b=2

Parameters

os
The output settings to modify.
compact
If true print compact, if false pretty print.
xmqSetColorModeSet if and how the output is colorized when rendering to the terminal, html or tex.
void xmqSetColorMode(XMQOutputSettings *os, XMQColorMode color_mode);
Set if and how the output is colorized when rendering to the terminal, html or tex.

Parameters

os
The output settings to modify.
color_mode
No color, colors for a dark or a light background, or automatic.
xmqSetTrueColorSet if the terminal supports truecolor (24 bit ansi colors), otherwise the colors are approximated with the 256 color palette.
void xmqSetTrueColor(XMQOutputSettings *os, bool truecolor);
Set if the terminal supports truecolor (24 bit ansi colors), otherwise the colors are approximated with the 256 color palette.

Parameters

os
The output settings to modify.
truecolor
If true use 24 bit ansi color codes.
xmqSetPreferDoubleQuotesSet if quotes should use double quotes "..." instead of single quotes '...' when the content permits it.
void xmqSetPreferDoubleQuotes(XMQOutputSettings *os, bool prefer_double_quotes);
Set if quotes should use double quotes "..." instead of single quotes '...' when the content permits it.

Parameters

os
The output settings to modify.
prefer_double_quotes
If true prefer double quotes.
xmqSetFinalNewlineSet if the output ends with a newline.
void xmqSetFinalNewline(XMQOutputSettings *os, bool final_nl);
Set if the output ends with a newline. The default is true.

Parameters

os
The output settings to modify.
final_nl
If true print a final newline.
xmqSetEscapeNewlinesSet if newlines inside quotes should be printed as the entity &#10; instead, eg ( 'line one' &#10; 'line two' ) instead of a multiline quote.
void xmqSetEscapeNewlines(XMQOutputSettings *os, bool escape_newlines);
Set if newlines inside quotes should be printed as the entity &#10; instead, eg ( 'line one' &#10; 'line two' ) instead of a multiline quote.

Parameters

os
The output settings to modify.
escape_newlines
If true escape newlines.
xmqSetEscapeNon7bitSet if characters outside of 7 bit ascii should be printed as entities, eg Göteborg becomes ( 'G' &#246; 'teborg' ).
void xmqSetEscapeNon7bit(XMQOutputSettings *os, bool escape_non_7bit);
Set if characters outside of 7 bit ascii should be printed as entities, eg Göteborg becomes ( 'G' &#246; 'teborg' ).

Parameters

os
The output settings to modify.
escape_non_7bit
If true escape non 7 bit characters.
xmqSetEscapeTabsSet if tabs inside quotes should be printed as the entity &#9; instead.
void xmqSetEscapeTabs(XMQOutputSettings *os, bool escape_tabs);
Set if tabs inside quotes should be printed as the entity &#9; instead.

Parameters

os
The output settings to modify.
escape_tabs
If true escape tabs.
xmqSetOutputFormatSet the format that xmqPrint prints the document in.
void xmqSetOutputFormat(XMQOutputSettings *os, XMQContentType output_format);
Set the format that xmqPrint prints the document in.

Parameters

os
The output settings to modify.
output_format
XMQ_CONTENT_XMQ, HTMQ, XML, HTML, JSON, YAML, TEXT or CLINES.
xmqSetOmitDeclSet if the xml declaration <?xml version="1.0" encoding="utf-8"?> should be left out when printing xml.
void xmqSetOmitDecl(XMQOutputSettings *os, bool omit_decl);
Set if the xml declaration <?xml version="1.0" encoding="utf-8"?> should be left out when printing xml.

Parameters

os
The output settings to modify.
omit_decl
If true do not print the xml declaration.
xmqSetRenderFormatSet how xmq output is rendered: plain, or colorized for the terminal, html, htmq or tex.
void xmqSetRenderFormat(XMQOutputSettings *os, XMQRenderFormat render_to);
Set how xmq output is rendered: plain, or colorized for the terminal, html, htmq or tex.

Parameters

os
The output settings to modify.
render_to
The render format.
xmqSetRenderThemeSet the theme used for rendering, a theme name with optional color overrides, eg lightbg:C=ff0000_U:AKV=00ffff.
void xmqSetRenderTheme(XMQOutputSettings *os, const char *theme_spec);
Set the theme used for rendering, a theme name with optional color overrides, eg lightbg:C=ff0000_U:AKV=00ffff. The string is not copied, it must stay valid while the settings are used.

Parameters

os
The output settings to modify.
theme_spec
The theme specification, or NULL for the default theme.
xmqSetRenderRawSet if rendering should produce only the colorized content, without the surrounding page and style, eg only the pre element of render-html (--nostyle).
void xmqSetRenderRaw(XMQOutputSettings *os, bool render_raw);
Set if rendering should produce only the colorized content, without the surrounding page and style, eg only the pre element of render-html (--nostyle).

Parameters

os
The output settings to modify.
render_raw
If true render only the content.
xmqSetRenderOnlyStyleSet if rendering should produce only the style, eg the css of render-html (--onlystyle).
void xmqSetRenderOnlyStyle(XMQOutputSettings *os, bool only_style);
Set if rendering should produce only the style, eg the css of render-html (--onlystyle).

Parameters

os
The output settings to modify.
only_style
If true render only the style.
xmqSetWriterContentSet the writer that receives the printed content.
void xmqSetWriterContent(XMQOutputSettings *os, XMQWriter content);
Set the writer that receives the printed content.

Parameters

os
The output settings to modify.
content
The writer function and its state.
xmqSetWriterErrorSet the writer that receives the error messages.
void xmqSetWriterError(XMQOutputSettings *os, XMQWriter error);
Set the writer that receives the error messages.

Parameters

os
The output settings to modify.
error
The writer function and its state.
xmqSetupPrintStdOutStdErrSet up the printer to print the content to stdout and the errors to stderr.
void xmqSetupPrintStdOutStdErr(XMQOutputSettings *ps);
Set up the printer to print the content to stdout and the errors to stderr.

Parameters

ps
The output settings to modify.
xmqSetupPrintFileSet up the printer to print to a file.
void xmqSetupPrintFile(XMQOutputSettings *ps, const char *file);
Set up the printer to print to a file. Not implemented yet, the function is declared but has no implementation.

Parameters

ps
The output settings to modify.
file
The file to print to.
xmqSetupPrintFileDescriptorSet up the printer to print to a file descriptor.
void xmqSetupPrintFileDescriptor(XMQOutputSettings *ps, int fd);
Set up the printer to print to a file descriptor. Not implemented yet, the function is declared but has no implementation.

Parameters

ps
The output settings to modify.
fd
The file descriptor to print to.
xmqSetupPrintMemorySet up the printer to print to a dynamically allocated memory buffer.
void xmqSetupPrintMemory(XMQOutputSettings *ps, char **start, char **stop);
Set up the printer to print to a dynamically allocated memory buffer. When xmqPrint is done, *start points to the NUL terminated output, which the caller frees, and *stop to its terminating NUL.

Parameters

ps
The output settings to modify.
start
Receives the start of the output.
stop
Receives the end of the output.
xmqSetupPrintSkipSet where to store the number of leading bytes of the memory output to skip, eg the xml declaration when it should be omitted.
void xmqSetupPrintSkip(XMQOutputSettings *ps, size_t *skip);
Set where to store the number of leading bytes of the memory output to skip, eg the xml declaration when it should be omitted. Used together with xmqSetupPrintMemory.

Parameters

ps
The output settings to modify.
skip
Receives the number of bytes to skip.
xmqPrintPrint the document according to the output settings.
void xmqPrint(XMQDoc *doc, XMQOutputSettings *settings);
Print the document according to the output settings.

Parameters

doc
The document to print.
settings
The output settings.
xmqAnnotateOffsetsAdd an attribute to each element with the offset of its text content.
void xmqAnnotateOffsets(XMQDoc *doc, const char *attribute_name, const char *ns);
Add an attribute to each element with the offset of its text content. For example <root>ABC<a>DEF</a>GHIJ<b>xyz</b></root> becomes <root o="0">ABC<a o="3">DEF</a>GHIJ<b o="10">xyz</b></root> with the attribute name o.

Parameters

doc
The document to modify.
attribute_name
The name of the attribute to add.
ns
The namespace of the attribute, or NULL.
xmqTrimWhitespaceTrim the whitespace of the text nodes and comments in the document.
void xmqTrimWhitespace(XMQDoc *doc, int flags);
Trim the whitespace of the text nodes and comments in the document.

Parameters

doc
The document to modify.
flags
The trim flags, eg XMQ_FLAG_TRIM_HEURISTIC.
xmqCompactQuoteCreate a compact single line quote that safely stores the content.
char *xmqCompactQuote(const char *content);
Create a compact single line quote that safely stores the content. The output can for example be: 123, John, 'John Doe', "There's a light!" or ( &#10; 'a line' &#10; )

Parameters

content
The string to quote.

Returns

A new NUL terminated string that the caller frees.

xmqDocErrorGet the error message of a failed parse or operation on the document.
const char *xmqDocError(XMQDoc *doc);
Get the error message of a failed parse or operation on the document.

Parameters

doc
The document.

Returns

The error message, freed together with the document.

xmqDocErrnoGet the error status of a failed parse or operation on the document.
XMQStatus xmqDocErrno(XMQDoc *doc);
Get the error status of a failed parse or operation on the document.

Parameters

doc
The document.

Returns

The error status code.

xmqGetNameGet the name of a node, eg the element name.
const char *xmqGetName(XMQNode *node);
Get the name of a node, eg the element name.

Parameters

node
The node.

Returns

The name.

xmqGetContentGet the content of a node.
const char *xmqGetContent(XMQNode *node);
Get the content of a node. For an element, the content of its first child (the value of a key=value). For a text, cdata, comment or processing instruction node, its own text.

Parameters

node
The node.

Returns

The content, or NULL.

xmqGetNodeTypeGet the kind of a node, eg element, text or comment.
XMQNodeType xmqGetNodeType(XMQNode *node);
Get the kind of a node, eg element, text or comment.

Parameters

node
The node.

Returns

The node type.

xmqGetDocNodeGet the document node, whose children are the top level nodes (the root element, comments, processing instructions and the doctype).
XMQNode *xmqGetDocNode(XMQDoc *doq);
Get the document node, whose children are the top level nodes (the root element, comments, processing instructions and the doctype).

Parameters

doq
The document.

Returns

The document node.

xmqGetParentGet the parent node.
XMQNode *xmqGetParent(XMQNode *node);
Get the parent node.

Parameters

node
The node.

Returns

The parent node, the document node for a top level node, or NULL for the document node.

xmqFirstChildGet the first child node.
XMQNode *xmqFirstChild(XMQNode *node);
Get the first child node. Attributes are not children, see xmqFirstAttr.

Parameters

node
The node.

Returns

The first child node, or NULL if there are no children.

xmqLastChildGet the last child node.
XMQNode *xmqLastChild(XMQNode *node);
Get the last child node.

Parameters

node
The node.

Returns

The last child node, or NULL if there are no children.

xmqNextSiblingGet the next sibling node.
XMQNode *xmqNextSibling(XMQNode *node);
Get the next sibling node.

Parameters

node
The node.

Returns

The next sibling node, or NULL if it is the last.

xmqPrevSiblingGet the previous sibling node.
XMQNode *xmqPrevSibling(XMQNode *node);
Get the previous sibling node.

Parameters

node
The node.

Returns

The previous sibling node, or NULL if it is the first.

xmqGetNamespaceUriGet the namespace uri of an element.
const char *xmqGetNamespaceUri(XMQNode *node);
Get the namespace uri of an element.

Parameters

node
The element.

Returns

The namespace uri, or NULL if it has no namespace.

xmqGetNamespacePrefixGet the namespace prefix of an element.
const char *xmqGetNamespacePrefix(XMQNode *node);
Get the namespace prefix of an element.

Parameters

node
The element.

Returns

The prefix, or NULL if it has no prefix.

xmqGetLineGet the line number in the source where the node was found.
int xmqGetLine(XMQNode *node);
Get the line number in the source where the node was found.

Parameters

node
The node.

Returns

The line number, or 0 if unknown.

xmqFirstAttrGet the first attribute of an element.
XMQAttr *xmqFirstAttr(XMQNode *node);
Get the first attribute of an element. Namespace declarations (xmlns, xmlns:prefix) are not attributes. for (XMQAttr *a = xmqFirstAttr(node); a; a = xmqNextAttr(a)) { printf("%s=%s\n", xmqGetAttrName(a), xmqGetAttrValue(a)); }

Parameters

node
The element.

Returns

The first attribute, or NULL if there are no attributes.

xmqNextAttrGet the next attribute of the same element.
XMQAttr *xmqNextAttr(XMQAttr *attr);
Get the next attribute of the same element.

Parameters

attr
The attribute.

Returns

The next attribute, or NULL if it is the last.

xmqGetAttrFind an attribute by its name (without prefix), regardless of namespace, like xmqHasAttribute.
XMQAttr *xmqGetAttr(XMQNode *node, const char *name);
Find an attribute by its name (without prefix), regardless of namespace, like xmqHasAttribute.

Parameters

node
The element.
name
The attribute name.

Returns

The first matching attribute, or NULL.

xmqGetAttrNameGet the name of an attribute, without prefix.
const char *xmqGetAttrName(XMQAttr *attr);
Get the name of an attribute, without prefix.

Parameters

attr
The attribute.

Returns

The name.

xmqGetAttrValueGet the value of an attribute.
const char *xmqGetAttrValue(XMQAttr *attr);
Get the value of an attribute. The value is NULL if it contains entity references that have not been expanded (only possible when xml with a DTD was parsed), use xmqExpandEntities first.

Parameters

attr
The attribute.

Returns

The value, or NULL.

xmqGetAttrNamespaceUriGet the namespace uri of an attribute.
const char *xmqGetAttrNamespaceUri(XMQAttr *attr);
Get the namespace uri of an attribute.

Parameters

attr
The attribute.

Returns

The namespace uri, or NULL if it has no namespace.

xmqGetAttrNamespacePrefixGet the namespace prefix of an attribute.
const char *xmqGetAttrNamespacePrefix(XMQAttr *attr);
Get the namespace prefix of an attribute.

Parameters

attr
The attribute.

Returns

The prefix, or NULL if it has no prefix.

xmqGetAttrOwnerGet the element that an attribute belongs to.
XMQNode *xmqGetAttrOwner(XMQAttr *attr);
Get the element that an attribute belongs to.

Parameters

attr
The attribute.

Returns

The element.

xmqSetContentSet the content of a node, replacing its children with the text.
void xmqSetContent(XMQNode *node, const char *raw_content);
Set the content of a node, replacing its children with the text.

Parameters

node
The node.
raw_content
The new content.
xmqGetNodeGet the first node that matches the xpath.
XMQNode *xmqGetNode(XMQDoc *doc, const char *xpath);
Get the first node that matches the xpath.

Parameters

doc
The document.
xpath
The xpath to search for.

Returns

The node, or NULL if nothing matches.

xmqGetNodeRelGet the first node that matches the xpath, evaluated relative to a node.
XMQNode *xmqGetNodeRel(XMQDoc *doc, const char *xpath, XMQNode *relative);
Get the first node that matches the xpath, evaluated relative to a node.

Parameters

doc
The document.
xpath
The xpath to search for.
relative
The node the xpath is evaluated from.

Returns

The node, or NULL if nothing matches.

xmqGetIntGet the content of the first node that matches the xpath as a 32 bit signed integer.
int32_t xmqGetInt(XMQDoc *doc, const char *xpath);
Get the content of the first node that matches the xpath as a 32 bit signed integer. A leading 0x is parsed as hex and a leading 0 as octal.

Parameters

doc
The document.
xpath
The xpath to search for.

Returns

The integer, or 0 if nothing matches.

xmqGetIntRelGet the content of the first node that matches the xpath, evaluated relative to a node, as a 32 bit signed integer.
int32_t xmqGetIntRel(XMQDoc *doc, const char *xpath, XMQNode *relative);
Get the content of the first node that matches the xpath, evaluated relative to a node, as a 32 bit signed integer. A leading 0x is parsed as hex and a leading 0 as octal.

Parameters

doc
The document.
xpath
The xpath to search for.
relative
The node the xpath is evaluated from.

Returns

The integer, or 0 if nothing matches.

xmqGetLongGet the content of the first node that matches the xpath as a 64 bit signed integer.
int64_t xmqGetLong(XMQDoc *doc, const char *xpath);
Get the content of the first node that matches the xpath as a 64 bit signed integer. A leading 0x is parsed as hex and a leading 0 as octal.

Parameters

doc
The document.
xpath
The xpath to search for.

Returns

The integer, or 0 if nothing matches.

xmqGetLongRelGet the content of the first node that matches the xpath, evaluated relative to a node, as a 64 bit signed integer.
int64_t xmqGetLongRel(XMQDoc *doc, const char *xpath, XMQNode *relative);
Get the content of the first node that matches the xpath, evaluated relative to a node, as a 64 bit signed integer. A leading 0x is parsed as hex and a leading 0 as octal.

Parameters

doc
The document.
xpath
The xpath to search for.
relative
The node the xpath is evaluated from.

Returns

The integer, or 0 if nothing matches.

xmqGetDoubleGet the content of the first node that matches the xpath as a double.
double xmqGetDouble(XMQDoc *doc, const char *xpath);
Get the content of the first node that matches the xpath as a double.

Parameters

doc
The document.
xpath
The xpath to search for.

Returns

The double, or 0 if nothing matches.

xmqGetDoubleRelGet the content of the first node that matches the xpath, evaluated relative to a node, as a double.
double xmqGetDoubleRel(XMQDoc *doc, const char *xpath, XMQNode *relative);
Get the content of the first node that matches the xpath, evaluated relative to a node, as a double.

Parameters

doc
The document.
xpath
The xpath to search for.
relative
The node the xpath is evaluated from.

Returns

The double, or 0 if nothing matches.

xmqGetStringGet the content of the first node that matches the xpath as a string, eg the value of a key=value.
const char *xmqGetString(XMQDoc *doc, const char *xpath);
Get the content of the first node that matches the xpath as a string, eg the value of a key=value.

Parameters

doc
The document.
xpath
The xpath to search for.

Returns

The content, owned by the document, or NULL if nothing matches.

xmqGetStringRelGet the content of the first node that matches the xpath, evaluated relative to a node, as a string, eg the value of a key=value.
const char *xmqGetStringRel(XMQDoc *doc, const char *xpath, XMQNode *relative);
Get the content of the first node that matches the xpath, evaluated relative to a node, as a string, eg the value of a key=value.

Parameters

doc
The document.
xpath
The xpath to search for.
relative
The node the xpath is evaluated from.

Returns

The content, owned by the document, or NULL if nothing matches.

xmqForeachCall a function for each node that matches the xpath.
int xmqForeach(XMQDoc *doq, const char *xpath, XMQNodeCallback cb, void *user_data);
Call a function for each node that matches the xpath.

Parameters

doq
The document.
xpath
The xpath.
cb
The function to call for each node, or NULL to only count.
user_data
The user data passed to the function.

Returns

The number of matching nodes.

xmqForeachRelCall a function for each node that matches the xpath, evaluated relative to a node.
int xmqForeachRel(XMQDoc *doq, const char *xpath, XMQNodeCallback cb, void *user_data, XMQNode *relative);
Call a function for each node that matches the xpath, evaluated relative to a node.

Parameters

doq
The document.
xpath
The xpath.
cb
The function to call for each node, or NULL to only count.
user_data
The user data passed to the function.
relative
The node the xpath is evaluated from.

Returns

The number of matching nodes.

xmqReplaceEntityReplace each reference to an entity with a text.
int xmqReplaceEntity(XMQDoc *doq, const char *entity, const char *content);
Replace each reference to an entity with a text. Not implemented yet, the function is declared but has no implementation.

Parameters

doq
The document.
entity
The entity name.
content
The text to insert.

Returns

The number of replacements.

xmqReplaceEntityWithNodeReplace each reference to an entity with a copy of a node from another document.
int xmqReplaceEntityWithNode(XMQDoc *doq, const char *entity, XMQDoc *idoq, XMQNode *inode);
Replace each reference to an entity with a copy of a node from another document. Not implemented yet, the function is declared but has no implementation.

Parameters

doq
The document.
entity
The entity name.
idoq
The document with the node to insert.
inode
The node to insert.

Returns

The number of replacements.

xmqExpandEntitiesExpand the entities declared in the doctype.
XMQStatus xmqExpandEntities(XMQDoc *doq);
Expand the entities declared in the doctype. Entities are never expanded when parsing, a reference &name; to a declared entity stays as an entity node (and contributes nothing to xpath string values) until this is called. Every reference to an internal entity, also inside attribute values, is replaced with its replacement text parsed as content (text, elements, comments...). References inside the replacement text are expanded too. Character references, undeclared entities and external entities (which are never loaded) are kept. Entity loops, more than 19 nested entities and an expansion larger than 1MB and five times the size of the parsed source are errors (the limits of libxml2). After an error the references expanded so far stay expanded.

Parameters

doq
The document.

Returns

XMQ_OK, or XMQ_ERROR_ENTITY_EXPANSION with the message in xmqDocError.

xmqVersionGet the version of this library.
const char *xmqVersion();
Get the version of this library.

Returns

The version string.

xmqFeaturesGet the optional parts compiled into this library, space separated, from "xmq-printing json yaml xslt xsd ixml html".
const char *xmqFeatures();
Get the optional parts compiled into this library, space separated, from "xmq-printing json yaml xslt xsd ixml html". A part is missing when it was excluded with XMQ_NO_XMQ_PRINTING, XMQ_NO_JSON, XMQ_NO_YAML, XMQ_NO_LIBXSLT, XMQ_NO_XSD, XMQ_NO_IXML or XMQ_NO_HTML.

Returns

The compiled in parts.

xmqSetVerboseEnable or disable verbose logging.
void xmqSetVerbose(bool e);
Enable or disable verbose logging.

Parameters

e
True to enable.
xmqSetProgressEnable or disable printing the progress on stderr, eg while parsing a large input with ixml.
void xmqSetProgress(bool e);
Enable or disable printing the progress on stderr, eg while parsing a large input with ixml.

Parameters

e
True to enable.
xmqSetDebugEnable or disable debug logging.
void xmqSetDebug(bool e);
Enable or disable debug logging.

Parameters

e
True to enable.
xmqSetTraceEnable or disable trace logging.
void xmqSetTrace(bool e);
Enable or disable trace logging.

Parameters

e
True to enable.
xmqLogFilterOnly log the debug and trace messages that start with a prefix, eg "xmq=".
void xmqLogFilter(const char *log_filter);
Only log the debug and trace messages that start with a prefix, eg "xmq=".

Parameters

log_filter
The prefix, or NULL to log all messages.
xmqDebuggingCheck if debug logging is enabled.
bool xmqDebugging();
Check if debug logging is enabled.

Returns

True if enabled.

xmqTracingCheck if trace logging is enabled.
bool xmqTracing();
Check if trace logging is enabled.

Returns

True if enabled.

xmqSetLogHumanReadableSet if the verbose, debug and trace logging is human readable.
void xmqSetLogHumanReadable(bool e);
Set if the verbose, debug and trace logging is human readable. The default is xmq.

Parameters

e
True for human readable.
xmqLoggingXMQCheck if logging is in xmq.
bool xmqLoggingXMQ();
Check if logging is in xmq. Not implemented yet, the function is declared but has no implementation.

Returns

True if logging is in xmq.

xmqParseBufferWithTypeParse a buffer with a given content type and create the document.
bool xmqParseBufferWithType(XMQDoc *doc, const char *start, const char *stop, const char *implicit_root, XMQContentType ct, int flags);
Parse a buffer with a given content type and create the document.

Parameters

doc
The document to populate.
start
Points to the first byte of the buffer.
stop
Points to the byte after the buffer.
implicit_root
The implicit root, or NULL.
ct
The content type, or XMQ_CONTENT_DETECT to detect it.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqParseFileWithTypeParse a file with a given content type and create the document, or read from stdin if file is NULL.
bool xmqParseFileWithType(XMQDoc *doc, const char *file, const char *implicit_root, XMQContentType ct, int flags);
Parse a file with a given content type and create the document, or read from stdin if file is NULL.

Parameters

doc
The document to populate.
file
The file to parse, or NULL for stdin.
implicit_root
The implicit root, or NULL.
ct
The content type, or XMQ_CONTENT_DETECT to detect it.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqParseBufferWithIXMLParse a buffer with an ixml grammar and create the document.
bool xmqParseBufferWithIXML(XMQDoc *doc, const char *start, const char *stop, XMQDoc *ixml_grammar, int flags);
Parse a buffer with an ixml grammar and create the document.

Parameters

doc
The document to populate.
start
Points to the first byte of the buffer.
stop
Points to the byte after the buffer.
ixml_grammar
The grammar, a document parsed with XMQ_CONTENT_IXML.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqTakeIXMLTraceTake the trace of the last parse of doc with xmqParseBufferWithIXML and the flag XMQ_FLAG_IXML_TRACE.
XMQDoc *xmqTakeIXMLTrace(XMQDoc *doc);
Take the trace of the last parse of doc with xmqParseBufferWithIXML and the flag XMQ_FLAG_IXML_TRACE. The trace is: trace(engine=yaep) { grammar { rule(name rhs) ... } input { token(pos) = 1 ... token(pos) = ω } steps { read(pos) item(id from to state rule matched expected) ... } tree { node(id from to rule rhs) ... } } where state is predicted, partial, complete or blocked.

Parameters

doc
The parsed document.

Returns

The trace document, owned by the caller who frees it with xmqFreeDoc, or NULL.

xmqIXMLFromDocGet the ixml text of a grammar in xml form, ie the parse tree of the grammar with the ixml grammar, eg ixml{rule(name=S){alt{literal(string=a)}}}, read from xml, xmq or json.
char *xmqIXMLFromDoc(XMQDoc *grammar, char **error);
Get the ixml text of a grammar in xml form, ie the parse tree of the grammar with the ixml grammar, eg ixml{rule(name=S){alt{literal(string=a)}}}, read from xml, xmq or json. Parse the text with xmqParseBufferWithType(..., XMQ_CONTENT_IXML, ...).

Parameters

grammar
The grammar in xml form.
error
Receives an error message, that the caller frees, if NULL is returned.

Returns

The ixml text, that the caller frees, or NULL if the document is not such a grammar.

xmqTakeIXMLCompletionsTake what could follow the input of the last parse of doc with xmqParseBufferWithIXML and the flag XMQ_FLAG_IXML_COMPLETE.
char *xmqTakeIXMLCompletions(XMQDoc *doc);
Take what could follow the input of the last parse of doc with xmqParseBufferWithIXML and the flag XMQ_FLAG_IXML_COMPLETE. One line for each, sorted by rule: string<TAB>rule<TAB>text the characters text can follow, eg verb gives char<TAB>rule<TAB>#a a control character, written as in an ixml grammar charset<TAB>rule<TAB>['a'-'z'] a character from the set can follow end<TAB><TAB> the input can end here where rule is the named grammar rule (a generated rule gives the rule it was made for). ixml has no tokens, so text is the characters up to the next character set or rule, eg the rest of a word: with the input "a man gi" the line is: string verb ves

Parameters

doc
The parsed document.

Returns

The completions, that the caller frees, or NULL if the input could not be parsed up to its end.

xmqParseFileWithIXMLParse a file with an ixml grammar and create the document, or read from stdin if file is NULL.
bool xmqParseFileWithIXML(XMQDoc *doc, const char *file, XMQDoc *ixml_grammar, int flags);
Parse a file with an ixml grammar and create the document, or read from stdin if file is NULL.

Parameters

doc
The document to populate.
file
The file to parse, or NULL for stdin.
ixml_grammar
The grammar, a document parsed with XMQ_CONTENT_IXML.
flags
The parse flags (XMQFlagBits), 0 for the defaults.

Returns

True if the parse succeeded, otherwise see xmqDocError.

xmqSetupDefaultColorsSet up the colors of the output settings from the theme and the color mode.
void xmqSetupDefaultColors(XMQOutputSettings *settings);
Set up the colors of the output settings from the theme and the color mode.

Parameters

settings
The output settings to modify.
xmqOverrideSettingsChange the strings printed for indentation and explicit whitespace.
void xmqOverrideSettings(XMQOutputSettings *settings, const char *indentation_space, const char *explicit_space, const char *explicit_tab, const char *explicit_cr, const char *explicit_nl);
Change the strings printed for indentation and explicit whitespace.

Parameters

settings
The output settings to modify.
indentation_space
The indentation, if NULL use " ".
explicit_space
An explicit space, if NULL use " ".
explicit_tab
An explicit tab, if NULL use "\t".
explicit_cr
An explicit carriage return, if NULL use "\r".
explicit_nl
An explicit newline, if NULL use "\n".
xmqRenderHtmlSettingsSet the id and class of the pre element of the rendered html.
void xmqRenderHtmlSettings(XMQOutputSettings *settings, const char *use_id, const char *use_class);
Set the id and class of the pre element of the rendered html.

Parameters

settings
The output settings to modify.
use_id
The id of the pre element, or NULL.
use_class
The class of the pre element, or NULL.
xmqOverrideColorChange the color strings of a syntax element.
void xmqOverrideColor(XMQOutputSettings *settings, const char *render_style, XMQColorName cn, const char *pre, const char *post, const char *ns);
Change the color strings of a syntax element. Currently this does nothing.

Parameters

settings
The output settings to modify.
render_style
The render style, "" for the default.
cn
The syntax element to change the color for.
pre
The string printed before the element.
post
The string printed after the element.
ns
The color of the namespace prefix.
xmqNewLineConfigAllocate a line configuration with the defaults, used to generate single line xmq for logging.
XMQLineConfig *xmqNewLineConfig();
Allocate a line configuration with the defaults, used to generate single line xmq for logging.

Returns

The new line configuration, free it with xmqFreeLineConfig.

xmqFreeLineConfigFree the line configuration.
void xmqFreeLineConfig(XMQLineConfig *lc);
Free the line configuration.

Parameters

lc
The line configuration to free.
xmqSetLineHumanReadableSet if the generated log lines should be more human readable.
void xmqSetLineHumanReadable(XMQLineConfig *lc, bool enable);
Set if the generated log lines should be more human readable.

Parameters

lc
The line configuration.
enable
True for more human readable lines.
xmqLineDocGenerate a compact single line xmq string, without any newlines, from a document, for logging.
char *xmqLineDoc(XMQLineConfig *lc, XMQDoc *doc);
Generate a compact single line xmq string, without any newlines, from a document, for logging.

Parameters

lc
The line configuration.
doc
The document.

Returns

A new string that the caller frees.

xmqLinePrintfGenerate a compact single line xmq string, without any newlines, for logging.
char *xmqLinePrintf(XMQLineConfig *lc, const char *element_name, ...);
Generate a compact single line xmq string, without any newlines, for logging. The content is constructed from printf formatted strings: xmqLinePrintf(&lc, "car{", "model=", "%s", modelstring, "id=", "%d", idnumber, "description=", "desc: %s", multilinedescription, "}"); generates: car{model=Volvo id=123 description=('desc: lines of'&#10;'next line')}

Parameters

lc
The line configuration.
element_name
The element name, eg "car{", followed by key, format and value arguments.

Returns

A new string that the caller frees.

xmqLineVPrintfThe same as xmqLinePrintf but with the arguments as a va_list.
char *xmqLineVPrintf(XMQLineConfig *lc, const char *element_name, va_list ap);
The same as xmqLinePrintf but with the arguments as a va_list.

Parameters

lc
The line configuration.
element_name
The element name, eg "car{", followed by the arguments in ap.
ap
The key, format and value arguments, see xmqLinePrintf.

Returns

A new string that the caller must free.

xmqCompileXsltCompile an xslt stylesheet.
XMQReturnXslt xmqCompileXslt(XMQDoc *stylesheet, XMQXsltSettings *settings);
Compile an xslt stylesheet. A copy of the stylesheet is compiled, the document is not changed. and the messages are also available with xmqDocError(stylesheet).

Parameters

stylesheet
The stylesheet document.
settings
The loader and message settings, or NULL for the defaults.

Returns

The status and the compiled stylesheet. On failure the status is XMQ_ERROR_XSLT_COMPILE

xmqSetXsltParamSet a top level parameter of the stylesheet.
void xmqSetXsltParam(XMQXslt *xslt, const char *name, const char *value, bool is_xpath);
Set a top level parameter of the stylesheet.

Parameters

xslt
The compiled stylesheet.
name
The parameter name.
value
The value.
is_xpath
If true the value is an xpath expression (like --param), otherwise a string (like --stringparam).
xmqTransformApply the stylesheet to a document.
XMQReturnDoc xmqTransform(XMQXslt *xslt, XMQDoc *doc);
Apply the stylesheet to a document. Whitespace may be stripped from the document by xsl:strip-space. The result gets the xsl:output method as its original content type (XMQ_CONTENT_XML, XMQ_CONTENT_HTML or XMQ_CONTENT_TEXT). and the messages are also available with xmqDocError(doc).

Parameters

xslt
The compiled stylesheet.
doc
The document to transform.

Returns

The status and the result document. On failure the status is XMQ_ERROR_XSLT_TRANSFORM

xmqSaveXsltResultSerialize a result of xmqTransform as the xsl:output of the stylesheet asks for (method, encoding, indent, doctype, xml declaration), like libxslt xsltSaveResultToString.
char *xmqSaveXsltResult(XMQXslt *xslt, XMQDoc *result, size_t *len);
Serialize a result of xmqTransform as the xsl:output of the stylesheet asks for (method, encoding, indent, doctype, xml declaration), like libxslt xsltSaveResultToString.

Parameters

xslt
The compiled stylesheet.
result
The result of xmqTransform.
len
Receives the length, the string may contain zeros for UTF-16.

Returns

A new string that the caller frees.

xmqFreeXsltFree a compiled stylesheet.
void xmqFreeXslt(XMQXslt *xslt);
Free a compiled stylesheet.

Parameters

xslt
The compiled stylesheet to free.
xmqCompileXsdCompile an xsd schema.
XMQReturnXsd xmqCompileXsd(XMQDoc *schema, XMQXsdSettings *settings);
Compile an xsd schema. A copy of the schema is compiled, the document is not changed. The message callback of the settings is also used by xmqValidate. and the messages are also available with xmqDocError(schema).

Parameters

schema
The schema document.
settings
The loader and message settings, or NULL for the defaults.

Returns

The status and the compiled schema. On failure the status is XMQ_ERROR_XSD_COMPILE

xmqSetXsdMessageCallbackChange where the messages of xmqValidate go.
void xmqSetXsdMessageCallback(XMQXsd *xsd, XMQXsdMessageCallback callback, void *user_data);
Change where the messages of xmqValidate go.

Parameters

xsd
The compiled schema.
callback
The function that receives the messages, or NULL to print them on stderr.
user_data
The user data passed to the callback.
xmqValidateValidate a document against a schema.
XMQStatus xmqValidate(XMQXsd *xsd, XMQDoc *doc);
Validate a document against a schema. with xmqDocError(doc)) or XMQ_ERROR_XSD_COMPILE if the schema cannot be used.

Parameters

xsd
The compiled schema.
doc
The document to validate.

Returns

XMQ_OK if it is valid, XMQ_ERROR_XSD_INVALID if it is not (the messages are also available

xmqFreeXsdFree a compiled schema.
void xmqFreeXsd(XMQXsd *xsd);
Free a compiled schema.

Parameters

xsd
The compiled schema to free.

Types

30Opaque structures, structures and callbacks.
XMQDocOpaque structure storing a document.
typedef struct XMQDoc XMQDoc;
Opaque structure storing a document.
XMQNodeOpaque structure storing a node in the document.
typedef struct XMQNode XMQNode;
Opaque structure storing a node in the document. A node can be an element, text or entity. An element containing only text and entities is usually displayed as a key=value.
XMQAttrOpaque structure storing an attribute in the document.
typedef struct XMQAttr XMQAttr;
Opaque structure storing an attribute in the document.
XMQParseStateAn opaque structure to maintain the parse state and the list of callbacks to be invoked when parsing xmq.
typedef struct XMQParseState XMQParseState;
An opaque structure to maintain the parse state and the list of callbacks to be invoked when parsing xmq.
XMQParseCallbacksStore your own parse callbacks into this structure and register it with the XMQParseState.
typedef struct XMQParseCallbacks XMQParseCallbacks;
Store your own parse callbacks into this structure and register it with the XMQParseState. Then you will get your own callbacks when parsing XMQ and using these callbacks you can implement your own document builder or token handler.
XMQOutputSettingsOpaque structure storing a output settings when printing xmq, xml or json.
typedef struct XMQOutputSettings XMQOutputSettings;
Opaque structure storing a output settings when printing xmq, xml or json.
XMQReaderA reader that the xmq parser invokes to fetch more data.
typedef struct XMQReader XMQReader;
A reader that the xmq parser invokes to fetch more data. The read function stores data in the buffer (start <= i < stop) and returns the number of bytes stored, at most stop-start. You can create your own reader with a function that takes a pointer to the reader state.

Members

void *reader_state The reader_state is passed to the read function.
size_t (*read)(void *reader_state, char *start, char *stop) The function to be invoked from the parser to fetch more data to parse.
XMQWriteYou can pass your own xmq_writer to the printer routines to do your own final output.
typedef bool (*XMQWrite)(void *writer_state, const char *start, const char *stop);
You can pass your own xmq_writer to the printer routines to do your own final output. Any function implementing XMQWrite must handle stop == NULL.

Parameters

writer_state
Your own writer_state supplied to the printing function.
start
Start of buffer to write.
stop
Points to byte after buffer to write. If NULL then assume start is null terminated.
XMQWriterThe xmq printer uses the writer to write data supplied from a buffer (start <= i < stop).
typedef struct XMQWriter XMQWriter;
The xmq printer uses the writer to write data supplied from a buffer (start <= i < stop). You can create your own writer with a function that takes a pointer to the writer state. The writer function must return true if the writing was successful.

Members

void *writer_state The writer_state is passed to the write function.
XMQWrite write The function to be invoked from the printer to write output data.
XMQNodeCallbackThe function type which is called by foreach functions.
typedef XMQProceed (*XMQNodeCallback)(XMQDoc *doc, XMQNode *node, void *user_data);
The function type which is called by foreach functions.

Parameters

doc
The document being processed.
node
The node triggering the callback.
user_data
The user data supplied to for_each.
XMQReturnDocThe status and the document returned by a function that creates a document.
typedef struct XMQReturnDoc XMQReturnDoc;
The status and the document returned by a function that creates a document. The document is only valid if the status is XMQ_OK.

Members

XMQStatus status
XMQDoc *doc
XMQReturnNodeThe status and the node returned by a function that creates a node.
typedef struct XMQReturnNode XMQReturnNode;
The status and the node returned by a function that creates a node. The node is only valid if the status is XMQ_OK.

Members

XMQStatus status
XMQNode *node
XMQReturnAttrThe status and the attribute returned by a function that creates an attribute.
typedef struct XMQReturnAttr XMQReturnAttr;
The status and the attribute returned by a function that creates an attribute. The attribute is only valid if the status is XMQ_OK.

Members

XMQStatus status
XMQAttr *attr
XMQReturnStringThe status and a string, that the caller frees, returned by a function.
typedef struct XMQReturnString XMQReturnString;
The status and a string, that the caller frees, returned by a function. The string is only valid if the status is XMQ_OK.

Members

XMQStatus status
char *string
XMQReturnConstStringThe status and a string, owned by the library, returned by a function.
typedef struct XMQReturnConstString XMQReturnConstString;
The status and a string, owned by the library, returned by a function. The string is only valid if the status is XMQ_OK.

Members

XMQStatus status
const char *string
XMQLineConfigOpaque structure with the settings used to generate single line xmq for logging, see xmqNewLineConfig and xmqLinePrintf.
typedef struct XMQLineConfig XMQLineConfig;
Opaque structure with the settings used to generate single line xmq for logging, see xmqNewLineConfig and xmqLinePrintf.
XMQAddAttrAn attribute to add, a name and a value, see XMQ_ATTRS.
typedef struct XMQAddAttr XMQAddAttr;
An attribute to add, a name and a value, see XMQ_ATTRS.

Members

const char *name
const char *value
XMQAttrListA list of attributes to add, created with XMQ_ATTRS.
typedef struct XMQAttrList XMQAttrList;
A list of attributes to add, created with XMQ_ATTRS.

Members

const XMQAddAttr *array
size_t count
XMQNSThe namespace setting of a new element or attribute, created with NS_NONE, NS_PARENT, NS_HERE(uri) or NS_ANCESTOR(uri).
typedef struct XMQNS XMQNS;
The namespace setting of a new element or attribute, created with NS_NONE, NS_PARENT, NS_HERE(uri) or NS_ANCESTOR(uri).

Members

NamespaceAction action
const char *uri
XMQContentMarkA position at the end of the current content (children and attributes) of a node, used by xmqWrapContent.
typedef struct XMQContentMark XMQContentMark;
A position at the end of the current content (children and attributes) of a node, used by xmqWrapContent. Treat the members as opaque.

Members

void *child
size_t text_len
void *attr
XMQXsltA compiled XSLT 1.0 stylesheet.
typedef struct XMQXslt XMQXslt;
A compiled XSLT 1.0 stylesheet.
XMQReturnXsltThe status and the compiled stylesheet returned by xmqCompileXslt.
typedef struct XMQReturnXslt XMQReturnXslt;
The status and the compiled stylesheet returned by xmqCompileXslt. The stylesheet is only valid if the status is XMQ_OK.

Members

XMQStatus status
XMQXslt *xslt
XMQXsltLoaderLoad the document at uri for xsl:import, xsl:include and document(), return NULL if it cannot be loaded.
typedef XMQDoc *(*XMQXsltLoader)(void *user_data, const char *uri);
Load the document at uri for xsl:import, xsl:include and document(), return NULL if it cannot be loaded. The returned document is owned by the caller of the loader.
XMQXsltMessageCallbackReceives the messages of compilation and transformation (errors, warnings, xsl:message).
typedef void (*XMQXsltMessageCallback)(void *user_data, const char *message);
Receives the messages of compilation and transformation (errors, warnings, xsl:message).
XMQXsltSettingsThe settings for compiling a stylesheet, how to load imported files and where the messages go.
typedef struct XMQXsltSettings XMQXsltSettings;
The settings for compiling a stylesheet, how to load imported files and where the messages go.

Members

XMQXsltLoader loader NULL loads the files with xmqParseFileWithType (content detection, no trimming).
void *loader_user_data
XMQXsltMessageCallback message_callback NULL prints the messages on stderr (like libxslt).
void *message_user_data
XMQXsdA compiled XSD 1.0 schema.
typedef struct XMQXsd XMQXsd;
A compiled XSD 1.0 schema.
XMQReturnXsdThe status and the compiled schema returned by xmqCompileXsd.
typedef struct XMQReturnXsd XMQReturnXsd;
The status and the compiled schema returned by xmqCompileXsd. The schema is only valid if the status is XMQ_OK.

Members

XMQStatus status
XMQXsd *xsd
XMQXsdLoaderLoad the schema document at uri for xs:include, xs:import and xs:redefine, return NULL if it cannot be loaded.
typedef XMQDoc *(*XMQXsdLoader)(void *user_data, const char *uri);
Load the schema document at uri for xs:include, xs:import and xs:redefine, return NULL if it cannot be loaded. The returned document is owned by the caller of the loader.
XMQXsdMessageCallbackReceives the messages of compilation and validation, exactly as libxml2 formats them for its plain error callbacks.
typedef void (*XMQXsdMessageCallback)(void *user_data, const char *message, bool is_warning);
Receives the messages of compilation and validation, exactly as libxml2 formats them for its plain error callbacks. is_warning is true for warnings.
XMQXsdSettingsThe settings for compiling a schema, how to load included files and where the messages go.
typedef struct XMQXsdSettings XMQXsdSettings;
The settings for compiling a schema, how to load included files and where the messages go.

Members

XMQXsdLoader loader NULL reads the files and parses them as xml with entities substituted (like libxml2).
void *loader_user_data
XMQXsdMessageCallback message_callback NULL prints the messages on stderr in the libxml2 format (file:line: element x: ...).
void *message_user_data

Enums

10Content types, flags, colors and status codes.
XMQColorModeSpecifies the color mode when rendering output that can be colorized (terminal, html and tex).
typedef enum { … } XMQColorMode;
Specifies the color mode when rendering output that can be colorized (terminal, html and tex).

Values

XMQ_MONO 0 Render without any color. Output is plain monochrome.
XMQ_BG_DARK 1 Render with color, assuming a dark background. The dark background mode is forced.
XMQ_BG_LIGHT 2 Render with color, assuming a light background. The light background mode is forced.
XMQ_BG_AUTO 3 Render with color and decide the background automatically, defaulting to a dark background. For html this means the rendered page follows the browser dark/light mode preference.
XMQContentTypeSpecify the file/buffer content type both for input and for output.
typedef enum { … } XMQContentType;
Specify the file/buffer content type both for input and for output.

Values

XMQ_CONTENT_UNKNOWN 0 Unknown buffer content.
XMQ_CONTENT_DETECT 1 Try to detect buffer content, is it xmq, xml or json?
XMQ_CONTENT_XMQ 2 Content is xmq.
XMQ_CONTENT_HTMQ 3 Content is htmq.
XMQ_CONTENT_XML 4 Content is xml.
XMQ_CONTENT_HTML 5 Content is html.
XMQ_CONTENT_JSON 6 Content is json.
XMQ_CONTENT_IXML 7 Content is ixml.
XMQ_CONTENT_TEXT 8 Content is text.
XMQ_CONTENT_CLINES 9 Cline content looks like: xpath="c-escaped string"
XMQ_CONTENT_YAML 10 Content is YAML.
XMQRenderFormatXMQRenderFormat decides how to format the xmq output: PLAIN, or for human consumption in TERMINAL, HTML, HTMQ, TEX.
typedef enum { … } XMQRenderFormat;
XMQRenderFormat decides how to format the xmq output: PLAIN, or for human consumption in TERMINAL, HTML, HTMQ, TEX.

Values

XMQ_RENDER_PLAIN 0 Normal output for data storage.
XMQ_RENDER_TERMINAL 1 Colorize output using ansi codes.
XMQ_RENDER_HTML 2 Colorize output using html tags.
XMQ_RENDER_HTMQ 3 Colorize output using htmq tags.
XMQ_RENDER_TEX 4 Colorize using latex.
XMQFlagBitsThe flag bits specify by the parser builds the document.
typedef enum { … } XMQFlagBits;
The flag bits specify by the parser builds the document. If a 0 is provided as the flag bits to the parse functions, then it will parse using the these default settings: When loading xml/html: trim the whitespace from the input to generate the most likely desired xmq output. merge character entities When loading xmq/htmq: no trimming but merge character entities such as &#10; and consecutive text quotes If you load xml with XMQ_TRIM_NONE (--trim=none) there will be a lot of unnecessary whitespace stored in the xmq, like &#32;&#9;&#10; etc. You can then view the xmq with XMQ_TRIM_HEURISTIC (--trim=heuristic) to drop the whitespace. If you load xmq with --nomerge then character entities and separate text blocks will be kept as is. The --nomerge currently does not work for XML/HTML since libxml2 does not have a setting for merge, it always merges.

Values

XMQ_FLAG_TRIM_NONE 1 Do not trim any whitespace. Only relevant when parsing xml.
XMQ_FLAG_TRIM_HEURISTIC 2 Remove leading/ending whitespace, but try to keep significant, remove incidental indentation.
XMQ_FLAG_TRIM_EXACT 4 Not implemented.
XMQ_FLAG_NOMERGE 8 Do not merge adjacent text nodes and character entity nodes.
XMQ_FLAG_IXML_ALL_PARSES 16 When ixml parse is ambiguous generate all parses.
XMQ_FLAG_IXML_TRY_TO_RECOVER 32 When ixml parse fails, try to recover.
XMQ_FLAG_IXML_FAIL_SILENT 64 If the ixml parse fails generate an empty document and no errors.
XMQ_FLAG_IXML_TRACE 128 Record a trace of the ixml parse (the grammar, the Earley items and the tree), see xmqTakeIXMLTrace.
XMQ_FLAG_IXML_COMPLETE 256 Find what could follow the input, for completion, see xmqTakeIXMLCompletions.
XMQColorNameXMQColorName is used to color the output when pretty printing xmq.
typedef enum { … } XMQColorName XMQColorName;
XMQColorName is used to color the output when pretty printing xmq.

Values

XMQ_COLOR_C Comment.
XMQ_COLOR_Q Quote.
XMQ_COLOR_E Entity.
XMQ_COLOR_NS Name Space (both for element and attribute).
XMQ_COLOR_EN Element name.
XMQ_COLOR_EK Element key.
XMQ_COLOR_EKV Element key value.
XMQ_COLOR_AK Attribute key.
XMQ_COLOR_AKV Attribute key value.
XMQ_COLOR_CP Compound Parentheses.
XMQ_COLOR_NSD Name Space Declaration xmlns.
XMQ_COLOR_UW Unicode whitespace.
XMQ_COLOR_XLS Override xls prefixed element names with this color.
XMQMoveToXMQMoveTo decides where a node is moved to, in a new parent element and potentially in relation to another sibling node.
typedef enum { … } XMQMoveTo;
XMQMoveTo decides where a node is moved to, in a new parent element and potentially in relation to another sibling node.

Values

XMQ_MOVE_FIRST 0 Place the element first in the parents list of childrens.
XMQ_MOVE_LAST 1 Place the element last in the parents list of children.
XMQ_MOVE_BEFORE 2 Place the element before the element referenced.
XMQ_MOVE_AFTER 3 Place the element after the element referenced.
XMQProceedThe XMQProceed is used to proceed or stop when iterating over xmq nodes.
typedef enum { … } XMQProceed;
The XMQProceed is used to proceed or stop when iterating over xmq nodes.

Values

XMQ_CONTINUE Return XMQ_CONTINUE to continue iterating over xmq nodes.
XMQ_STOP Return XMQ_STOP to stop iterating.
XMQStatusThe xmq functions return OK or error values using the XMQStatus.
typedef enum { … } XMQStatus;
The xmq functions return OK or error values using the XMQStatus.

Values

XMQ_OK 0 No error.
XMQ_ERROR_CANNOT_READ_FILE 1 File not found or cannot be opened for reading.
XMQ_ERROR_OOM 2 Out of memory.
XMQ_ERROR_NOT_XMQ 3 Expected xmq but auto detect sees early that it is not xmq.
XMQ_ERROR_QUOTE_NOT_CLOSED 4 An xmq quote is not closed, ie single quotes are missing.
XMQ_ERROR_ENTITY_NOT_CLOSED 5 An entity is missing the semicolon.
XMQ_ERROR_COMMENT_NOT_CLOSED 6 A comment has not been closed.
XMQ_ERROR_COMMENT_CLOSED_WITH_TOO_MANY_SLASHES 7 A comment close is not balanced.
XMQ_ERROR_BODY_NOT_CLOSED 8 A body is missing a closing brace.
XMQ_ERROR_ATTRIBUTES_NOT_CLOSED 9 The attribute list is missing the closing parentheses.
XMQ_ERROR_COMPOUND_NOT_CLOSED 10 Compound content is missing the closing double parentheses.
XMQ_ERROR_COMPOUND_MAY_NOT_CONTAIN 11 Compound content may only contains quotes and entities.
XMQ_ERROR_QUOTE_CLOSED_WITH_TOO_MANY_QUOTES 12 Too many closing single quotes.
XMQ_ERROR_UNEXPECTED_CLOSING_BRACE 13 An unexpected closing brace.
XMQ_ERROR_EXPECTED_CONTENT_AFTER_EQUALS 14 Expected a value after equals.
XMQ_ERROR_UNEXPECTED_TAB 15 Tabs are not permitted as token separators.
XMQ_ERROR_INVALID_CHAR 16 An invalid character found.
XMQ_ERROR_BAD_DOCTYPE 17 The doctype could not be parsed.
XMQ_ERROR_JSON_INVALID_ESCAPE 18 An invalid json escape sequence.
XMQ_ERROR_JSON_INVALID_CHAR 19 An invalid json character.
XMQ_ERROR_CANNOT_HANDLE_XML 20 The XMl parser has been left out to shrink code size.
XMQ_ERROR_CANNOT_HANDLE_HTML 21 The HTML parser has been left out to shrink code size.
XMQ_ERROR_CANNOT_HANDLE_JSON 22 The JSON parser has been left out to shrink code size.
XMQ_ERROR_EXPECTED_XMQ 23 Expecte xmq but was given something else.
XMQ_ERROR_EXPECTED_HTMQ 24 Expecte htmq but was given something else.
XMQ_ERROR_EXPECTED_XML 25 Expecte xml but was given something else.
XMQ_ERROR_EXPECTED_HTML 26 Expecte html but was given something else.
XMQ_ERROR_EXPECTED_JSON 27 Expecte json but was given something else.
XMQ_ERROR_PARSING_XML 28 Error while parsing xml.
XMQ_ERROR_PARSING_HTML 29 Error while parsing html.
XMQ_ERROR_VALUE_CANNOT_START_WITH 30 A value after a key cannot start with comments or equals.
XMQ_ERROR_INVALID_NAMESPACE_URI 31 Not a proper uri for a namespace.
XMQ_ERROR_INVALID_NAMESPACE_PREFIX 32 Not a proper prefix for a namespace.
XMQ_ERROR_NAMESPACE_PREFIX_ALREADY_TAKEN 33 When adding a new namespace with a prefix, the prefix has already been used.
XMQ_ERROR_BAD_RANGE 35 Pointer errors to buffers are wrong.
XMQ_ERROR_BAD_VALUE 36 Invalid enums provided or other bad input to functions.
XMQ_ERROR_XML_FRAGMENT_NOT_CLOSED 37 An embedded xml fragment inside an xmq document is not closed.
XMQ_ERROR_ENTITY_EXPANSION 38 An entity could not be expanded: a loop, too deep nesting, too large expansion or malformed replacement text.
XMQ_ERROR_INVALID_UTF8 39 The input is not valid UTF-8.
XMQ_ERROR_TOO_DEEP 40 The elements, objects or arrays are nested deeper than XMQ_MAX_NESTING_DEPTH.
XMQ_ERROR_IXML_SYNTAX_ERROR 50 The ixml grammar cannot be parsed.
XMQ_ERROR_XSLT_COMPILE 60 The xslt stylesheet cannot be compiled.
XMQ_ERROR_XSLT_TRANSFORM 61 The xslt transformation failed.
XMQ_ERROR_XSD_COMPILE 62 The xsd schema cannot be compiled.
XMQ_ERROR_XSD_INVALID 63 The document is not valid according to the xsd schema.
XMQ_ERROR_EXCLUDED_FROM_BUILD 64 The feature was excluded when libxmq was built (eg XMQ_NO_JSON).
XMQ_WARNING_QUOTES_NEEDED 1000 Warning, when parse succeeds, but it seems there is a mistake.
XMQCoreTypeWhen loading xmq/xml/json as a config file, the content is parsed and decoded according the the requested type.
typedef enum { … } XMQCoreType;
When loading xmq/xml/json as a config file, the content is parsed and decoded according the the requested type. These are the available core types.

Values

XMQ_CORE_BOOL
XMQ_CORE_I8 Signed 8 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_I16 Signed 16 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_I32 Signed 32 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_I64 Signed 64 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_I128 Signed 128 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_U8 Unsigned 8 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_U16 Unsigned 16 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_U32 Unsigned 32 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_U64 Unsigned 64 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_U128 Unsigned 128 bit integer. Can be decimal, hex (0x) or octal (0).
XMQ_CORE_F32 Floating point 32bit.
XMQ_CORE_F64 Floating point 64bit.
XMQ_CORE_STRING Zero to infinite sized unicode string. No zero bytes.
XMQ_CORE_EMAIL String formatted as a valid email address.
XMQ_CORE_URI String formatted as a valid uri/iri.
XMQ_CORE_URL String formatted as a valid url.
XMQ_CORE_IP_ADDRESS Either a v4 or a v6.
XMQ_CORE_IPV4_ADDRESS 128.0.0.1
XMQ_CORE_IPV6_ADDRESS ::0
XMQ_BINARY_BASE64 Base64 encoded binary data.
XMQNodeTypeThe kind of a node, see xmqGetNodeType.
typedef enum { … } XMQNodeType;
The kind of a node, see xmqGetNodeType.

Values

XMQ_NODE_UNKNOWN 0
XMQ_NODE_ELEMENT 1
XMQ_NODE_TEXT 3
XMQ_NODE_CDATA 4
XMQ_NODE_ENTITY_REF 5 An entity reference that has not been expanded. The name is the entity name, a character reference has a name starting with #, e.g. #10
XMQ_NODE_PI 7 A processing instruction, the name is the target and the content the data.
XMQ_NODE_COMMENT 8
XMQ_NODE_DOCUMENT 9 The document node, the parent of the root element and of the other top level nodes.
XMQ_NODE_DOCTYPE 14 The doctype, the name is the doctype name.

Defines

1 macros
XMQ_ATTRSCreate an XMQAttrList from name value pairs, for xmqAddElementWithAttrs and xmqAddKeyValueWithAttrs, eg XMQ_ATTRS( { "id", "123" }, { "class", "info" } ).
#define XMQ_ATTRS(...) ((XMQAttrList) { (XMQAddAttr[]) { __VA_ARGS__ }, sizeof((XMQAddAttr[]) { __VA_ARGS__ }) / sizeof(XMQAddAttr) })
Create an XMQAttrList from name value pairs, for xmqAddElementWithAttrs and xmqAddKeyValueWithAttrs, eg XMQ_ATTRS( { "id", "123" }, { "class", "info" } ).