Skip to content

Commit aadbe73

Browse files
authored
Merge pull request #10814 from pijuskri/dat/contains-empty
Clarify handling of empty arguments in xpath function contains
2 parents d3301ab + a21ee3e commit aadbe73

4 files changed

Lines changed: 80 additions & 10 deletions

File tree

content/en/docs/refguide/modeling/xpath/xpath-constraints/xpath-constraint-functions/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ The following pages describe the functions that can be executed within constrain
2323
* [contains](/refguide/xpath-contains/)
2424
* [starts-with](/refguide/xpath-starts-with/)
2525
* [ends-with](/refguide/xpath-ends-with/)
26+
27+
{{% alert color="info" %}}
28+
In all these functions, the attribute in the example is just the name of the attribute, for example `Name`. This is for clarity. However, the attribute can also contain the path to the attribute, for example `Sales.Order_Customer/Sales.Customer/Name`.
29+
{{% /alert %}}

content/en/docs/refguide/modeling/xpath/xpath-constraints/xpath-constraint-functions/xpath-contains.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ The `contains()` function tests whether a string attribute contains a specific s
1313
String comparisons in XPath constraints are generally case-insensitive, but this can depend on the collation setting for some databases. See [Case-Sensitive Database Behavior](/refguide/case-sensitive-database-behavior/) for more information.
1414
{{% /alert %}}
1515

16+
## Syntax
17+
18+
The syntax is as follows:
19+
20+
```
21+
contains ( attribute, string_expression )
22+
```
23+
24+
### attribute
25+
26+
`attribute` specifies the attribute to test. It must be of the **String** type.
27+
28+
### expression
29+
30+
`string_expression` specifies the value to test for being contained in the attribute. It can be a string literal or a string parameter.
31+
32+
{{% alert color="info" %}}
33+
If the `attribute` is an empty value or `NULL`, the function will always return `false`, independent of the value of `string_expression`.
34+
35+
If the `string_expression` is empty, it is treated as an empty string. The function is then equivalent to ```attribute != empty```.
36+
{{% /alert %}}
37+
1638
## Example
1739

1840
This query returns all the customers from which the name contains the string `an`:

content/en/docs/refguide/modeling/xpath/xpath-constraints/xpath-constraint-functions/xpath-ends-with.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,39 @@ The `ends-with()` function checks whether a string attribute ends with a specifi
1313
String comparisons in XPath constraints are generally case-insensitive, but this can depend on the collation setting for some databases. See [Case-Sensitive Database Behavior](/refguide/case-sensitive-database-behavior/) for more information.
1414
{{% /alert %}}
1515

16+
## Syntax
17+
18+
The syntax is as follows:
19+
20+
```
21+
ends-with ( attribute, string_expression )
22+
```
23+
24+
### attribute
25+
26+
`attribute` specifies the attribute to test. It must be of the **String** type.
27+
28+
### expression
29+
30+
`string_expression` specifies the value to test for being at the end of the attribute. It must be a string literal or a string parameter.
31+
32+
{{% alert color="info" %}}
33+
If the `attribute` is an empty value or `NULL`, the function will always return `false`, independent of the value of `string_expression`.
34+
35+
If the `string_expression` is empty, it is treated as an empty string. The function is then equivalent to ```attribute != empty```.
36+
{{% /alert %}}
37+
1638
## Example
1739

1840
This query returns all customers whose name ends with the sub-string `sen`:
1941

2042
{{< tabpane >}}
21-
{{% tab header="Environments:" disabled=true /%}}
22-
{{< tab header="Studio Pro" lang="StudioPro" >}}
23-
[ends-with(Name, 'sen')]
43+
{{% tab header="Environments:" disabled=true /%}}
44+
{{< tab header="Studio Pro" lang="StudioPro" >}}
45+
[ends-with(Name, 'sen')]
2446
{{% /tab %}}
25-
{{< tab header="Java" lang="JavaQuery" >}}
26-
//Sales.Customer[ends-with(Name, 'sen')]
47+
{{< tab header="Java" lang="JavaQuery" >}}
48+
//Sales.Customer[ends-with(Name, 'sen')]
2749
{{% /tab %}}
2850
{{< /tabpane >}}
2951

content/en/docs/refguide/modeling/xpath/xpath-constraints/xpath-constraint-functions/xpath-starts-with.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,39 @@ The `starts-with()` function tests whether a string attribute starts with a spec
1313
String comparisons in XPath constraints are generally case-insensitive, but this can depend on the collation setting for some databases. See [Case-Sensitive Database Behavior](/refguide/case-sensitive-database-behavior/) for more information.
1414
{{% /alert %}}
1515

16+
## Syntax
17+
18+
The syntax is as follows:
19+
20+
```
21+
starts-with ( attribute, string_expression )
22+
```
23+
24+
### attribute
25+
26+
`attribute` specifies the attribute to test. It must be of the **String** type.
27+
28+
### expression
29+
30+
`string_expression` specifies the value to test for being at the start of the attribute. It should be a string literal or a string parameter.
31+
32+
{{% alert color="info" %}}
33+
If the `attribute` is an empty value or `NULL`, the function will always return `false`, independent of the value of `string_expression`.
34+
35+
If the `string_expression` is empty, it is treated as an empty string. The function is then equivalent to ```attribute != empty```.
36+
{{% /alert %}}
37+
1638
## Example
1739

1840
This query returns all the customers from which the name starts with the string "Jans":
1941

2042
{{< tabpane >}}
21-
{{% tab header="Environments:" disabled=true /%}}
22-
{{< tab header="Studio Pro" lang="StudioPro" >}}
23-
[starts-with(Name, 'Jans')]
43+
{{% tab header="Environments:" disabled=true /%}}
44+
{{< tab header="Studio Pro" lang="StudioPro" >}}
45+
[starts-with(Name, 'Jans')]
2446
{{% /tab %}}
25-
{{< tab header="Java" lang="JavaQuery" >}}
26-
//Sales.Customer[starts-with(Name, 'Jans')]
47+
{{< tab header="Java" lang="JavaQuery" >}}
48+
//Sales.Customer[starts-with(Name, 'Jans')]
2749
{{% /tab %}}
2850
{{< /tabpane >}}
2951

0 commit comments

Comments
 (0)