XPath and Regex Examples for E-Document Templates

The examples provided in the table can be used to validate the following sample template:

          <document>
<buyer>Abuyer</buyer>
<amount>100</amount>
<items>
<item><id>1</id><name>Mouse</name></item>
<item><id>2</id><name>Keyboard</name></item>
<item><id>3.0</id><name>Monitor</name></item>
<count>3.0</count>
</items>
</document> 

        

The following table contains sample xpath and regex validation expressions:

Xpath

Regex validation expression

Description

Values for validation

Validation result

"document/buyer"

/^.+$/

The value cannot be blank

Abuyer

Pass

"document/amount"

/^\d+\.\d{0,4}$/

The value is a decimal with up to 4 decimal places

100

Fail

"document/items/item/id"

/^\d+$/

The value is a whole number

Each value will be validated

1

Pass

2

Pass

3.0

Fail

"document/items/count”

/^\d+(\.*\d{0,2}){1}$/

The value is a whole number or a decimal number with up to 2 decimal places

3.0

Pass

For more information about xpath and regex validations, go to the w3schools website:

Related Topics

Creating E-Document Templates
PEPPOL Template
Understanding Inbound E-Document Templates in JSON Format
Understanding XSD in Inbound E-Document Templates
Understanding XSD in Outbound E-Document Templates
Creating a Digital Signature Plug-in Implementation for E-Documents
Creating an Outbound Validation Plug-in Implementation for E-Documents
Creating a Custom Plug-in Implementation for E-Document Custom Data Source

General Notices