Document functions

This section describes functions that operate on document values that are available in expressions.

getDocLength

Retrieves the file size of a document.

Syntax

    getDocLength(com.adobe.idp.Document)

Parameters

com.adobe.idp.Document is a reference to a serialized document.

Returns

A Long that contains the file size of the document in bytes. Returns 0 if the parameter does not evaluate to a document.

Example

A variable named vardocument references a PDF file that was serialized after being submitted as a work item form. The following example returns 455343 , the size of the referenced document in bytes:

getDocLength(/process_data/@vardocument)

getDocAttribute

Retrieves the value of the specified document attribute.

Syntax

    getDocAttribute(com.adobe.idp.Document, String)

Parameters

com.adobe.idp.Document is a reference to a serialized document. String is a string that holds the name of the document attribute to retrieve. For information about available attributes, see Document attributes for attachments and notes .

Returns

The value of the attribute specified by String . The attribute determines the type of value returned. Returns an empty string if the com.adobe.idp.Document parameter does not evaluate to a com.adobe.idp.Document value. Returns null if String does not hold a valid attribute name.

Example

A document variable named varattachment references a PDF file that was attached to a task. The following example returns an integer that represents the access permissions of the attachment:

getDocAttribute(/process_data/@varattachment,"wspermission")

setDocAttribute

Sets the value of a document attribute.

Syntax

    setDocAttribute(com.adobe.idp.Document, String, String)

Parameters

com.adobe.idp.Document is a reference to a serialized document. The first String parameter is a string that holds the name of the document attribute to set. The second String parameter is a string that holds the value to set the document attribute to. For information about available attributes, see Document attributes for attachments and notes .

Returns

A reference to the input com.adobe.idp.Document value with the attribute specified by the first String parameter set to the value specified by the second String parameter.

Returns a reference to an empty com.adobe.idp.Document value with the specified attribute set to the specified value if the first parameter does not evaluate to a document.

Returns a reference to the unchanged com.adobe.idp.Document value if the second or third parameters do not evaluate to a String .

Example

The following example returns the description of a document that the document variable named vardoc1 references:

setDocAttribute(/process_data/@vardoc1,"wsdescription",  
"An example description.")

getDocContentType

Retrieves the content type of a document. The content type identifies the type of the document, similar to the mime-type property of documents that are sent over the web. For example, a PDF document has a document type of application/pdf .

The document type of a document can have no value or can have any value that is set with the setDocContent function, when the document was attached to a task. For more information, see setDocContentType .

Syntax

    getDocContentType(com.adobe.idp.Document)

Parameters

com.adobe.idp.Document is a serialized document that is referenced by a document variable.

Returns

A String that contains the content type. Returns an empty String if the parameter does not evaluate to a document.

setDocContentType

Sets the content type of a document. The content type identifies the type of the document, similar to the mime-type property of documents that are sent over the web. For example, a PDF document has a document type of application/pdf .

Syntax

    setDocContentType(com.adobe.idp.Document, String)

Parameters

com.adobe.idp.Document is a serialized document that is referenced by a document variable.

String is a string that contains the content type that you want to set for the document.

Returns

A reference to a copy of the com.adobe.idp.Document value that was used as a parameter. Returns a new, empty document with the specified content type if the first parameter does not evaluate to a com.adobe.idp.Document .

getDocContentBase64

Retrieves the content of a document as a Base64-encoded string.

Syntax

    getDocContentBase64(aDocument)

Parameters

aDocument is a serialized document value. You can reference the document value using an XPath expression.

Returns

A string value that represents the document. If the parameter does not evaluate to a document value, an empty string is returned.

Example

A text file is stored in a document variable named documentVar . The content of the text file is the single word content . The following expression returns the string value Y29udGVudA== :

getDocConententBase64(/process_data/@documentVar)

getDocFromBase64

Converts a Base64-encoded string to a document.

Syntax

    getDocFromBase64(aString)

Parameters

aString is a string value that contains Base64-encoded text. You can reference the string value using an XPath expression.

Returns

A document value that represents a document, and the content of the document is the decoded text that aString contained.

Example

A string variable named stringVar contains the Base64-encoded text Y29udGVudA== . The following expression returns a document that contains the text content :

getDocFromBase64(/process_data/@stringVar)