comet.CXMLTree

class comet.CXMLTree

Methods

CXMLTree.getRoot()

Get the root node of this tree.

Returns:

The root node of this tree

Return type:

CXMLNode

Raises:

CometError – On internal error

Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlnode::root

CXMLTree.send(command)

Send an XMLQuery command to this tree.

Subsequent calls to this function will not overwrite but extend the command.

Once execute() is called, the command is reset.

Parameters:

command (str) – The command to send.

Return type:

None

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::send

CXMLTree.sendCDataBegin()

Open a CData block in the XMLQuery command.

This is a convenience function doing the same as calling send() with the parameter ‘<![CDATA[’ .

A once opened CData block must be closed again using sendCDataEnd().

In CData blocks, the string ‘![[[CDATA[’ must not be used!

Return type:

None

Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::send_cdata_begin

CXMLTree.sendCDataEnd()

Close a CData block in the XMLQuery command.

This is a convenience function doing the same as calling send() with the parameter ‘]]>’ .

Return type:

None

Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::send_cdata_end

CXMLTree.input(value)

Bind a value to a placeholder in the XMLQuery command.

The value is copied immediately to the command.

Parameters:

value (int | float | str) – The value to insert

Return type:

None

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::input

CXMLTree.output(types)

Bind output types to result columns of the XMLQuery command.

Since XML does not contain type information all result columns would usually be of type str. This function changes the result types in the result exec(). It is possible to call this function after exec(), but it must be called before fetch().

The first entry of the type list is the type of the first result, etc..

The value from the XML input must be convertible to the designated result type.

Parameters:

list[int]types

The list of expected output types.

Allowed values and their corresponding output types:

Return type:

None

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::output

CXMLTree.execute(showErrors=True)

Execute the XMLQuery command stored in this tree.

This resets the stored command.

Parameters:

showErrors (bool) –

Should the processing errors be displayed automatically?

  • True

    Show errors in an error dialog.

  • False

    Do not show errors in an error dialog. The script does the error handling itself.

A list of possible errors and their description can be found here .

Please note that warnings e.g. about missing attributes or elements are NOT considered as errors but only as warnings and therefore will not be seen by setting showErrors.

Return type:

None

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::exec

CXMLTree.fetch()

Fetch the result columns of the XMLQuery command executed by exec().

Returns:

The result of the query.

Each entry contains types according to the specification set by output().

Return type:

list[tuple]

Raises:

CometError – On internal error

Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::fetch

CXMLTree.serialize()

Serialize this tree to a string.

Returns:

The serialized tree as str

Return type:

str

Available:

InDesign® comet_pdf® Illustrator®

CScript:

xmlquery::serialize

Special methods

CXMLTree.__repr__()

String representation.

Returns:

<CXMLTree> Source Path: Source Path

Example
<CXMLTree> Source Path: C:/Temp/Products.xml

Return type:

str