Getting Started > Use Lua Scripts > Method Reference > Document Methods

Document Methods
addField
Adds a new field to the document.
Syntax
addField ( String fieldname, String fieldvalue )
Arguments
 
appendContent
Appends content to the existing content of the document.
Syntax
appendContent ( String content )
Arguments
 
copyField
Copies a field to a certain name.
Syntax
copyField (String sourcename, String targetname [, Boolean case])
Arguments
 
copyFieldNoOverwrite
Copies a field to a certain name but does not overwrite the existing value.
Syntax
copyFieldNoOverwrite ( String sourcename, String targetname [, Boolean case])
Arguments
 
countField
This method returns an integer of the number of fields with the name specified.
Syntax
countField (String fieldname [, Boolean case])
Arguments
 
Returns
An integer.
deleteField
Deletes a field from a document.
Syntax
deleteField ( String fieldname [, Boolean case])
Arguments
 
findField
This method returns the LuaField object of the specified name.
Syntax
findField ( String fieldname)
Arguments
 
Returns
A LuaField object of the specified name.
getContent
Gets the content for a document.
Syntax
getContent ()
Returns
The document content as a string.
getField
This method returns the first LuaField object of the specified name.
Syntax
getField (String name [, Boolean case])
Arguments
 
Returns
First LuaField object of the specified name.
getFields
This method returns a table of LuaFields of the specified name.
Syntax
getFields (String name [, Boolean case])
Arguments
 
Returns
A table of LuaFields.
getFieldNames
Gets all the field names for the document.
Syntax
getFieldNames ( )
Returns
A table of all the field names.
getFieldValue
Gets the value of a field on a document.
Syntax
getFieldValue( String fieldname [, Boolean case])
Arguments
 
Returns
A string containing the value.
getFieldValues
Gets all values from all fields that have the same name.
Syntax
getFieldValues( String fieldname [, Boolean case])
Arguments
 
Returns
A table of all the field values.
getNextSection
The document object passed to the script's handler function in fact represents the first section of the document. This means the functions previously detailed only read and modify the first section. This method returns the next section in the document when sectioned.
Syntax
LuaDocument getNextSection ()
Example
To perform operations on every section, for example:
local section = document
while section do
-- Manipulate section
section = section:getNextSection()
end
Returns
A document object that contains the next DRE section.
getReference
This method returns a string containing the reference.
Syntax
getReference ()
Returns
The string containing the reference.
hasField
Checks to see if a field exists for a document.
Syntax
hasField ( String fieldname [, Boolean case])
Arguments
 
Returns
A Boolean: true if the field exists, false otherwise.
insertXML
This method inserts a portion of XML as a new piece of metadata for the document.
Syntax
insertXML (LuaXMLNode node)
Arguments
 
Returns
A LuaField object of the inserted data.
renameField
Changes the name of a field from one name to another.
Syntax
renameField ( String currentname, String newname [, Boolean case])
Arguments
 
setContent
Sets the content for a document.
Syntax
setContent ( String content )
Arguments
 
setFieldValue
Sets the value of a field on a document.
Syntax
setFieldValue( String fieldname, String newvalue )
Arguments
 
setReference
This method sets the reference to the string passed in.
Syntax
setReference (String reference)
Arguments
 
writeStubIdx
Writes out a stub idx document (a metadata file used by IDOL applications).
Syntax
writeStubIdx( String filename )
Arguments
 
Returns
A Boolean: true if written, false otherwise.