Table of Contents

Search

  1. Preface
  2. Introduction to Data Transformation
  3. Data Processor Transformation
  4. Wizard Input and Output Formats
  5. Relational Input and Output
  6. Using the IntelliScript Editor
  7. XMap
  8. Libraries
  9. Schema Object
  10. Command Line Interface
  11. Scripts
  12. Parsers
  13. Script Ports
  14. Document Processors
  15. Formats
  16. Data Holders
  17. Anchors
  18. Transformers
  19. Actions
  20. Serializers
  21. Mappers
  22. Locators, Keys, and Indexing
  23. Streamers
  24. Validators, Notifications, and Failure Handling
  25. Validation Rules
  26. Custom Script Components

User Guide

User Guide

Example: Using dt:next-sequence()

Example: Using dt:next-sequence()

You can use the dt:next-sequence() function to access logically hierarchical data that is not nested within the current element.
Consider the following input:
<Root> <A/> <B/> <C/> <A/> </Root>
The XPath
/Root/A/dt:next-sequence()
returns the following node-set:
<A/> <B/> <C/>
In the following example, each
id
element is associated with a set of sibling elements called
name
,
quantity
, and
price
:
<items> <id>100</id> <name>Plate</name> <quantity>4</quantity> <price>10</price> <id>101</id> <name>Toaster</name> <quantity>6</quantity> <price>10</price> <id>102</id> <name>Knife</name> <quantity>10</quantity> <price>5</price> </items>
The
name
,
quantity
, and
price
elements are all logically nested within
id
, even though they are not nested physically.
The following rule requires that
price*quantity
for each
id
be less than or equal to 50:
<rule code="sum1" select="/items/id" description="For each id, check that the total price (price*quantity) does not exceed 50"> <variable name="current">dt:next-sequence()</variable> <variable name="total">$current[3]*$current[4]</variable> <assert additionalData="$total"><![CDATA[ $total <= 50 ]]></assert> </rule>
For the first
id
element, the variable
$current
is a node-set with the following value:
<id>100</id> <name>Plate</name> <quantity>4</quantity> <price>10</price>
The expression
$current[3]*$current[4}
evaluates to 4*10 = 40. The rule confirms that 40 < 50.
For the subsequent
id
elements, the rule evaluates the expression in a similar way.

0 COMMENTS

We’d like to hear from you!