This section describes the methods provided by the LuaDocument object. A LuaDocument allows you to access and modify the reference, metadata and content of a document.
If you have a LuaDocument object called document you can call its methods using the ':' operator. For example:
document:addField(name, value)
| Constructor | Description |
|---|---|
| LuaDocument:new | The constructor for a LuaDocument object (creates a new LuaDocument object that only contains a reference). |
| Method | Description |
|---|---|
| addField | Creates a new field. |
| addSection | Add an empty section to the end of the document. |
| appendContent | Appends content to the existing content of the document. |
| copyField | Creates a new named field with the same value as an existing named field. |
| copyFieldNoOverwrite | Copies a field to a certain name but does not overwrite the existing value. |
| countField | Returns the number of fields with the name specified. |
| deleteField | Deletes a field from the document. |
| deleteFieldByPath | Deletes all document fields with the specified path. |
| getContent | Returns the document content. |
| getField | Returns the first field with a specified name. |
| getFieldNames | Returns all the field names for the document. |
| getFields | Returns all fields with the specified name. |
| getFieldsByRegex | Returns all fields where the field name or path matches a regular expression. |
| getFieldValue | Gets a field value. |
| getFieldValues | Gets all values of a multi-valued field. |
| getNextSection | Gets the next section in a document, allowing you to perform find or add operations on every section. |
| getReference | Returns the document reference. |
| getSection | Returns a LuaDocument object with the specified section as the active section. |
| getSectionCount | Returns the number of sections in the document. |
| getValueByPath | Gets the value of the document field or sub field with the specified path. |
| getValuesByPath | Gets all values of a multi-value document field or sub field, with the specified path. |
| hasField | Checks whether the document has a named field. |
| insertJson | Inserts metadata, from a JSON string, into a document. |
| insertXml | Inserts XML metadata into a document. |
| insertXmlWithoutRoot | Inserts XML metadata into a document. |
| removeSection | Removes a section from a document. |
| renameField | Renames a field. |
| setContent | Sets the content for a document. |
| setFieldValue | Sets a field value. |
| setReference | Sets the document reference. |
| to_idx | Returns a string containing the document in IDX format. |
| to_json | Returns a string containing the document in JSON format. |
| to_xml | Returns a string containing the document in XML format. |
| writeStubIdx | Writes out a stub IDX document. |
| writeStubXml | Writes out a stub XML document. |