You can test a Parse Structured rule directly, separate from the activity or other context in your application in which it will ultimately operate.
For a simple test, obtain an XML document that contains test data. You can choose to type or paste the document into a form, store it in a local Windows file, or upload it into a Text File rule.
Conducting the test
For basics of unit testing, see Unit testing individual rules.
- Save the Parse Structured form.
or the equivalent keyboard shortcut
R. A test window opens.
- Select a radio button to indicate whether a new empty page or an existing page is to provide input property values for the test.
- Select a radio button to indicate the source of test data.
- If the data is to be entered directly, type or paste the data into the text area. If the data is in a local file, click Browse and navigate to the file. Click OK. If the test data is in a text file rule, enter all three key parts of the rule separated by periods.
- Click Execute. The resulting parsed XML document appears in a new window. The clipboard is not altered.
The parseState object and debugging
As it executes, a Parse Structured rule creates and maintains a Java object in memory
parseState. This corresponds to a method variable in the generated
This object is not visible through the Tracer or the Clipboard tool, but you can use Public API functions to examine it. To do this, include a Java step containing the Public API call:
myStepPage.putString("debug3", Long.toString(parseState.getStreamOffset()) );
where debug3 is a
property. This function places the byte
offset position of the Java object into a clipboard value. You can review the clipboard
value with the Tracer or Clipboard tool.
methods operate on the
- Parse-Byte-Pos (for byte streams)
- Parse-Char-Pos (for character streams)
- Parse-Fixed-Binary (for byte streams)
- Parse-Packed-Decimal (for byte streams)
The result of each method is stored in
(which can be
accessed in a Java step) and optionally is stored as a property value.
object is defined in the PublicAPI Interface
This facility is based on
capabilities (not the newer
capabilities). The PublicAPI includes methods to query or
operate on the object.
Using the Tracer
To trace the start and end of Parse Structured rule executions:
- Open the Tracer.
- Click Settings to open the Tracer Settings panel.
- Under the Rule Types to Trace section, select the Parse Rules check box.