sethspace
sethspace |
Purpose
Synopsis
procedure sethspace(doc:xmldoc, n:integer, s:integer)
Arguments
doc
|
Document to use
|
n
|
Node number
|
s
|
Number of spaces to put before the node output
|
Example
The following example reformats the XML document layout by adding an additional line before 'region' nodes and printing three consecutive tags within 'employee' on a single line. The indentmode is set to 'manual' in order to apply the user formatting (instead of automatic or none).
declarations DB: xmldoc NodeList, Employees: list of integer end-declarations ! New line without indentation for Root setvspace(DB, Root, 1) ! Add extra line in between regions, keeping original indentation getnodes(DB, "personnelList/region", NodeList) forall(r in NodeList) setvspace(DB, r, 2) ! Spacing/indentation for 'employee' tag getnodes(DB, "personnelList/region/employee", Employees) forall(p in Employees) do setvspace(DB, p, 1); sethspace(DB, p, 4) ! Within 'employee', display up to 3 consecutive tags on a single line getnodes(DB, p, "child::node()[position() mod 3=1]", NodeList) forall(r in NodeList) do setvspace(DB, r, 1); sethspace(DB, r, 6) end-do getnodes(DB, p, "child::node()[position() mod 3<>1]", NodeList) forall(r in NodeList) do setvspace(DB, r, 0); sethspace(DB, r, 1) end-do end-do ! Set indentation mode to 'manual' to use our own formatting for display setindentmode(DB, XML_MANUAL) save(DB, "")
Further information
This spacing indicates the number of spaces to skip from the start of a new line before displaying the node when outputing the document. The horizontal spacing setting is only used when the indentation is in manual mode (see
setindentmode).
Related topics
Module