Each document manipulated by a script is stored in the form of a Document Object Model (DOM), represented by a tree of nodes, each of which contains a set of associated properties.
The DOM for a document is acquired by retrieving the file and loading the content, for example,
var uuid = env.getParameterValue(“document”); var file = repository.retrieveFile(uuid); var dom = env.getBqyDocument(file, bqReadWriteDom, bqDashboardReportStrategy)
The first line retrieves the parameter that contains the document UUID. The second line is used to copy the file from the repository to a temporary file which is deleted when the script ends. The third line loads the content of the file, providing a BqyDocument object that represents the DOM.
Note: | The second parameter, bqReadWriteDom, specifies that the document is to be rewritten. If it is not to be rewritten, specify bqReadOnlyDom to reduce the amount of memory required for the DOM. The third parameter is the document conversion strategy, bqDashboardReportStrategy. It determines how much of the underlying document structure is accessible to the script. |
Using different strategies, the amount of memory required by a script can be reduced, as can the time spent loading the document.