Skip to content

Commit

Permalink
Merge pull request #10 from CrossBreezeNL/feature/new-icon
Browse files Browse the repository at this point in the history
Update CrossGenerate icon and prepare release v3.4.0
  • Loading branch information
harmen-xb authored Nov 1, 2024
2 parents bbdeca9 + 40569a7 commit 46f7081
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 23 deletions.
56 changes: 37 additions & 19 deletions Documentation/docs/Config/XPath.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,63 @@ For the basic explanation on XPath, please consult the following website:
- <a href="https://www.w3schools.com/xml/xpath_intro.asp" target="_blank">W3Schools - XPath Tutorial</a>

## Examples
Here some examples are given which represent commonly occuring configurations containg XPath when using CrossGenerate.
Here some examples are given which represent commonly occurring configurations containing XPath when using CrossGenerate.

### Selection
When using XPath an important concept is the use of axes. An axis is a relationship of a certain node or set of nodes in the XML document to the current node. When traversing nodes the first part of the XPath is usually the axis. If no axis is given, the current node (self) is the default. See <a href="https://www.w3schools.com/xml/xpath_axes.asp" target="_blank">W3Schools - XPath Axes</a> for an explanation of this concept.

#### Child node selection
The '/' at the beginning of the expression makes sure it selects all attribute elements relative to the current node.
#### Child element selection
The `./` at the beginning of the expression makes sure it selects all elements and attributes relative to the current node. In the example below we select the `attribute` element as a child of the current node.
``` xml
/attribute
./attribute
```

By default XPath will select the child nodes, so the following XPath expression will yield the same results:
``` xml
attribute
```

#### Child attribute selection
In this example we want to select all name attributes of the current node. This will result in a single result or no result, since a node can have only one attribute with a certain name.
In this example we want to select all `name` attributes of the current node. This will result in a single result or no result, since a node can have only one attribute with a certain name.
``` xml
/@name
@name
```

#### Parent attribute value
To get to a node of the parent use the '../' axis. For example here we select the name attribute of the parent.
To get to the parent node use the `..` axis. For example here we select the `name` attribute of the parent.
``` xml
../@name
```

#### Any attribute selection
The '//' at the beginning of the expression makes sure it selects all attribute elements no matter where they reside in the XML document (so not only descedants of the current node).
#### Any element selection
The '//' at the beginning of the expression makes sure it selects all nodes no matter where they reside in the XML document (so not only descendants of the current node).
``` xml
//attribute
```

### Filtering

#### Filter on a element
In this example we want to select the attributes where the datatype is 'varchar'.
#### Filter on an element
In this example we want to select the attribute elements where the datatype is `varchar`.
``` xml
/attribute[@datatype='varchar']
attribute[@datatype='varchar']
```

#### Case insenstive filter
To make the comparison in the filter case insensitive, make sure to use lower-case() or upper-case() functions before comparing the value.
#### Using functions in a filter
Besides the standard comparison operators (=, >, <, ...) you can also use XPath functions in a filter as long as the result of the expression is a boolean result.

An example is to make the comparison in the filter case insensitive. For this we will use lower-case() or upper-case() functions before comparing the value.
``` xml
/attribute[lower-case(@datatype)='varchar']
attribute[lower-case(@datatype)='varchar']
```

One can also use different boolean type functions to perform checks in filters. For example contains(), starts-with() & ends-with().

#### Filter on attribute
Here we add a filter on the current datatype attribute. See how we use the '.' to select the current node value.
#### Filter on element text

In the examples above we filter in the value of an attribute of an element, but you can also filter on the attribute, while selecting the attribute in the XPath. In the example below we add a filter on the current datatype attribute. See how we use the '.' to select the current node value.
``` xml
/attribute/@datatype[.='varchar']
attribute/@datatype[.='varchar']
```

### Functions
Expand All @@ -72,10 +81,19 @@ Here we use the count function to count the numbers of attributes.
count(/attribute)
```

#### Replace[^1]
Here we use the replace function to replace (parts of) the value of the attribute `name`. In the example below we replace spaces with underscores.
``` xml
replace(@name, ' ', '_')
```

## References
In this section a list of relevant references is given.

- <a href="https://www.w3schools.com/xml/xml_xpath.asp" target="_blank">W3Schools - XML and XPath</a>
- <a href="https://www.w3schools.com/xml/xpath_intro.asp" target="_blank">W3Schools - XPath Tutorial</a>
- <a href="https://www.w3schools.com/xml/xsl_functions.asp" target="_blank">XPath Function Reference</a>
- <a href="https://www.w3.org/TR/xquery-operators/" target="_blank">XQuery and XPath Reference</a>
- <a href="https://www.w3.org/TR/xquery-operators/" target="_blank">XQuery and XPath Reference</a>

[comment]: Footnotes
[^1]: The replace XPath function is only available in `modelXPath` expressions and not in `templateXPath` expressions.
9 changes: 9 additions & 0 deletions Documentation/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Click on the header of a version number to go to the documentation of that speci
[//]: # (> * [ ] Binding)
[//]: # (> * [X] Some issue...)

## [Version 3.4](../../3.4/)

- [ ] 3.4.0 <sup>01-11-2024</sup>
>
> !!! info "Enhanced features"
> * [ ] Config
> * [ ] Model
> - [X] Added support for XPath 2.0 and XPath 3.0 function (including support for XPath 1.0 replace function).
## [Version 3.3](../../3.3/)

- [ ] 3.3.0 <sup>15-07-2024</sup>
Expand Down
Binary file modified Documentation/docs/img/favicon.ico
Binary file not shown.
Binary file modified Documentation/docs/img/xg_process_animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/docs/img/xgen-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion NuGet/CrossBreeze.CrossGenerate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CrossGenerate generates software using:
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>

<PackageVersion>3.3.0</PackageVersion>
<PackageVersion>3.4.0</PackageVersion>
<PackageReleaseNotes>Dependency updates and fix special characters in model attribute injection.</PackageReleaseNotes>
<PackageIcon>x-generate-icon.png</PackageIcon>
<RepositoryUrl>https://github.com/CrossBreezeNL/CrossGenerate</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion XGenerate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.xbreeze.xgenerate</groupId>
<artifactId>XGenerate</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions XGenerateTest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>
<groupId>XGenerateTest</groupId>
<artifactId>XGenerateTest</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<properties>
<xgenerate.version>3.3.0</xgenerate.version>
<xgenerate.version>3.4.0</xgenerate.version>
<java.version>1.8</java.version>
<cucumber.version>7.18.0</cucumber.version>
<junit.version>5.10.3</junit.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@Unit
Feature: Unit_CommandLine_ProgressScreen
In this feature we'll test the progress screen feature.

Background:
Given I have the following model:
"""
<?xml version="1.0" encoding="UTF-8"?>
<entities>
<entity name="A"/>
<entity name="B"/>
<entity name="C"/>
</entities>
"""
# In the below template we have an unbounded section to make sure there is a warning in the console/log output.
And the following template named "Unit_Config_Template_OutputType_table_name.txt":
"""
table_name
-- @XGenTextSection(name='UnboundedSection')
Unbounded section contents.
"""
And the following config:
"""
<XGenConfig>
<Model/>
<TextTemplate rootSectionName="Template">
<FileFormat singleLineCommentPrefix="--" />
<Output type="single_output" />
</TextTemplate>
<Binding>
<SectionModelBinding section="Template" modelXPath="/entities/entity" placeholderName="table" />
</Binding>
</XGenConfig>
"""
And the following app config:
"""
<?xml version="1.0" encoding="utf-8"?>
<XGenAppConfig>
<App>
<ConfigFolder>C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Config\</ConfigFolder>
<ModelFolder>C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Model\</ModelFolder>
<OutputFolder>C:\CrossGenerate\Test\Output\</OutputFolder>
<TemplateFolder>C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Template\</TemplateFolder>
</App>
</XGenAppConfig>
"""
And the directory "C:\CrossGenerate\Test\Log" is empty.

Scenario: Generate with progress screen
Given the following additional comma separated commandline arguments:
"""
-ps, true
"""
When I run the generator
Then I expect 1 generation result
And no log file
And I expect exit code 0

0 comments on commit 46f7081

Please sign in to comment.