|
Using references to
items
It is possible to use references to
items (documents and folders) in an XML file.
If a
DOCUMENT or
FOLDER element has the
id attribute set for it, you can use the ID specified in this attribute to
access various data stored in this item later.
For
example:
<!-- Creating
a document -->
<DOCUMENT
id="doc01"
action="create"
ifexists="error"
onerror="break">
<SEARCH>
<QUERY>SELECT DOCNUMBER FROM DOCSADM.PROFILE
WHERE DOCNAME='doc01'</QUERY>
</SEARCH>
<PROFILE
form="DEF_PROF">
<FIELD
name="DOCNAME">doc01</FIELD>
<FIELD
name="AUTHOR_ID">%AUTHOR_ID%</FIELD>
<FIELD
name="TYPIST_ID">%TYPIST_ID%</FIELD>
<FIELD
name="APP_ID">MS WORD</FIELD>
<FIELD
name="TYPE_ID">DEFAULT</FIELD>
</PROFILE>
</DOCUMENT>
<!-- Creating
a folder and moving to it the previously created document -->
<FOLDER
action="create"
ifexists="error"
onerror="break">
<SEARCH>
<QUERY>SELECT DOCNUMBER FROM DOCSADM.PROFILE
WHERE DOCNAME='fldr01'</QUERY>
</SEARCH>
<PROFILE
form="DEF_PROF">
<FIELD
name="DOCNAME">fldr01</FIELD>
<FIELD
name="AUTHOR_ID">%AUTHOR_ID%</FIELD>
<FIELD
name="TYPIST_ID">%TYPIST_ID%</FIELD>
<FIELD
name="TYPE_ID">DEFAULT</FIELD>
<FIELD
name="ABSTRACT">test folder</FIELD>
</PROFILE>
<ACTIONS>
<ADD_ITEM
docnumber="%doc02.DOCNUMBER%"
display_name="%doc02.DOCNAME%" />
</ACTIONS>
</FOLDER>
In the above example, we create a
document with id="doc01" first and then we create a folder while the document is
moved to the folder in the ACTIONS element. And a reference to the previously
defined item is used as the number of the document moved to the folder.
The item is referred to by the ID of the
item and its property after a dot enclosed by percent characters (as if for
VARIABLE).
You can use the ID of any field present
on the form of the item as the item property.
The item that is being referred to can
be defined not only as the result of creation, but as a result of searching
among those existing. See the elements DOCUMENT /
FOLDER /
SEARCH / QUERY for
more information.
If DOCUMENT (FOLDER) / SEARCH / QUERY
returns more than one document (or folder), the reference will point to the
first item in the list of those returned. Use sorting in your search queries to
get the result you need.
|