diff --git a/Documentation/docs/Config/XPath.md b/Documentation/docs/Config/XPath.md index 5ff9678a..df89ad7d 100644 --- a/Documentation/docs/Config/XPath.md +++ b/Documentation/docs/Config/XPath.md @@ -7,54 +7,63 @@ For the basic explanation on XPath, please consult the following website: - W3Schools - XPath Tutorial ## 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 W3Schools - XPath Axes 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 @@ -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. - W3Schools - XML and XPath - W3Schools - XPath Tutorial - XPath Function Reference -- XQuery and XPath Reference \ No newline at end of file +- XQuery and XPath Reference + +[comment]: Footnotes +[^1]: The replace XPath function is only available in `modelXPath` expressions and not in `templateXPath` expressions. \ No newline at end of file diff --git a/Documentation/docs/ReleaseNotes.md b/Documentation/docs/ReleaseNotes.md index f9693cfc..6810c519 100644 --- a/Documentation/docs/ReleaseNotes.md +++ b/Documentation/docs/ReleaseNotes.md @@ -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 01-11-2024 +> +> !!! 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 15-07-2024 diff --git a/Documentation/docs/img/favicon.ico b/Documentation/docs/img/favicon.ico index 39dac9d4..1a6a7f85 100644 Binary files a/Documentation/docs/img/favicon.ico and b/Documentation/docs/img/favicon.ico differ diff --git a/Documentation/docs/img/xg_process_animation.gif b/Documentation/docs/img/xg_process_animation.gif index a9c2ea8f..f4b390d6 100644 Binary files a/Documentation/docs/img/xg_process_animation.gif and b/Documentation/docs/img/xg_process_animation.gif differ diff --git a/Documentation/docs/img/xgen-icon.png b/Documentation/docs/img/xgen-icon.png index 19b1c7a3..903e1efd 100644 Binary files a/Documentation/docs/img/xgen-icon.png and b/Documentation/docs/img/xgen-icon.png differ diff --git a/NuGet/CrossBreeze.CrossGenerate.csproj b/NuGet/CrossBreeze.CrossGenerate.csproj index 1564f2e7..3533f9b0 100644 --- a/NuGet/CrossBreeze.CrossGenerate.csproj +++ b/NuGet/CrossBreeze.CrossGenerate.csproj @@ -23,7 +23,7 @@ CrossGenerate generates software using: README.md LICENSE.txt - 3.3.0 + 3.4.0 Dependency updates and fix special characters in model attribute injection. x-generate-icon.png https://github.com/CrossBreezeNL/CrossGenerate diff --git a/XGenerate/pom.xml b/XGenerate/pom.xml index 70271b73..abfea9ab 100644 --- a/XGenerate/pom.xml +++ b/XGenerate/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.xbreeze.xgenerate XGenerate - 3.3.0 + 3.4.0 jar diff --git a/XGenerate/src/main/resources/com/xbreeze/xgenerate/gui/x-generate-icon.png b/XGenerate/src/main/resources/com/xbreeze/xgenerate/gui/x-generate-icon.png index 19f7898b..ae91c021 100644 Binary files a/XGenerate/src/main/resources/com/xbreeze/xgenerate/gui/x-generate-icon.png and b/XGenerate/src/main/resources/com/xbreeze/xgenerate/gui/x-generate-icon.png differ diff --git a/XGenerateTest/pom.xml b/XGenerateTest/pom.xml index dd9b0994..ab247df3 100644 --- a/XGenerateTest/pom.xml +++ b/XGenerateTest/pom.xml @@ -2,9 +2,9 @@ 4.0.0 XGenerateTest XGenerateTest - 3.3.0 + 3.4.0 - 3.3.0 + 3.4.0 1.8 7.18.0 5.10.3 diff --git a/XGenerateTest/src/test/resources/features/unit/commandline/Unit_CommandLine_ProgressScreen.feature b/XGenerateTest/src/test/resources/features/unit/commandline/Unit_CommandLine_ProgressScreen.feature new file mode 100644 index 00000000..04f38951 --- /dev/null +++ b/XGenerateTest/src/test/resources/features/unit/commandline/Unit_CommandLine_ProgressScreen.feature @@ -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: + """ + + + + + + + """ + # 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: + """ + + + + + + + + + + + """ + And the following app config: + """ + + + + C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Config\ + C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Model\ + C:\CrossGenerate\Test\Output\ + C:\git\GitHub\CrossGenerate\XGenerateTest\src\test\resources\feature-support-files\Template\ + + + """ + 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