I want to use the Pattern Category (which is deprecated) using GeneXus 17 U8. With the sample code that is in https://github.com/genexuslabs/category-pattern.
I manage to compile, install and run the pattern in GeneXus 17.
I try to apply the pattern in a Empresas transaction and it creates the instance, but it gives an error:
========== Pattern generation (CategoryEmpresas) started ========== error: An error occurred while applying pattern instance 'CategoryEmpresas': 'Artech.Common.Diagnostics.GxException' **error: Input file has 1 syntacticals errors AttributeCategoryId.dkt(2,0): error DKT1: Syntax error: irrecoverable syntax error **
Failed: Pattern generation (CategoryEmpresas)
I didn't modify the AttributeCategoryId.dkt file (in fact, I didn't modify any file in the repository) and I can't find what the syntax error could be.
When I compare the dkt file with others that work fine, I can't identify where the error is.
The Windows Event Viewer has the following error:
Timestamp: 18/4/2022 10:46:14 Message: HandlingInstanceID: c51c0798-ff33-416b-8822-8af2c40b9e33 An exception of type 'Artech.Common.Diagnostics.GxException' occurred and was caught.
04/18/2022 10:46:14 Type : Artech.Common.Diagnostics.GxException, Artech.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=6f5bf81c27b6b8aa Message : Input file has 1 syntacticals errors AttributeCategoryId.dkt(2,0): error DKT1: Syntax error: irrecoverable syntax error
Source : Artech.Architecture.Common Help link : Exception Data Product : GeneXus 17 Version : 17.0.158023 U8 Exception.Severity : Error TargetSite : Boolean iEca3OpCse(Artech.Architecture.Common.Defaults.IApplyDefaultTarget, Artech.Architecture.Common.Defaults.IDefaultProvider, System.String, Boolean) HResult : -2146232832 Stack Trace : at Artech.Architecture.Common.Defaults.DefaultManager.iEca3OpCse(IApplyDefaultTarget , IDefaultProvider , String , Boolean ) at Artech.Architecture.Common.Defaults.DefaultManager.ApplyDefault(IApplyDefaultTarget target, Boolean canDecline) at Artech.Architecture.Common.Objects.KBObject.Artech.Architecture.Common.Defaults.IApplyDefaultTarget.CalculateDefault() at Artech.Architecture.Common.Defaults.EntityDefault.SetIsDefault(Boolean value, Boolean fireCalculate) at Artech.Architecture.Common.Defaults.EntityDefault.set_IsDefault(Boolean value) at Artech.Architecture.Common.Objects.KBObject.set_IsDefault(Boolean value) at Artech.Packages.Patterns.Engine.PatternInstanceGenerator.GenerateObject(IPatternBuildProcess buildProcess, PatternModel patternModel, PatternObject patternObject, PatternInstance instance, PatternInstanceElement element, ApplySettings settings) at Artech.Packages.Patterns.Engine.PatternInstanceGenerator.GenerateObjects(IPatternBuildProcess buildProcess, PatternModel patternModel, PatternInstance instance, PatternObject patternObject, ApplySettings settings) at Artech.Packages.Patterns.PatternEngine.GenerateInstanceObjects(IPatternBuildProcess buildProcess, PatternModel patternModel, PatternInstance instance, InstanceObjects instanceObjects, ApplySettings settings, ApplyResults results) at Artech.Packages.Patterns.PatternEngine.InternalApplyPattern(PatternInstance instance, ApplySettings settings) at Artech.Packages.Patterns.PatternEngine.ApplyPattern(PatternInstance instance, ApplySettings settings)
Additional Info:
TimeStamp : 18/4/2022 13:46:14 FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0, Culture=neutral, PublicKeyToken=79a65ef946496ecc AppDomainName : GeneXus.exe
Category: Default Category Priority: 0 EventId: 100
The AttributeCategoryId.dkt content:
<%@ Template Language="C#" TargetLanguage="GX" Description="Grid Selected Objects SDT" %>
<%@ Include Name="Constants.cs" %>
<%@ Assembly Name="Artech.Patterns.Category" %>
<%@ Import Namespace="Artech.Patterns.Category" %>
<%@ Property Name="Object" Type="Artech.Architecture.Common.Objects.KBObject" %>
<%@ Property Name="Part" Type="Artech.Architecture.Common.Objects.KBObjectPart" %>
<%@ Property Name="Instance" Type="Artech.Packages.Patterns.Objects.PatternInstance" %>
<%@ Property Name="Element" Type="Artech.Packages.Patterns.Objects.PatternInstanceElement" %>
<%
CategoryInstance catInstance = new CategoryInstance(Instance);
%>
<Object Type="Attribute" Id="CategoryId" name="<%= catInstance.AttributesName.CategoryId %>" description="<%= catInstance.AttributesName.CategoryId %>">
<Properties><Property><Name>Name</Name><Value><%= catInstance.AttributesName.CategoryId %></Value></Property><Property><Name>Length</Name><Value>4</Value></Property><Property><Name>Decimals</Name><Value>0</Value></Property><Property><Name>AUTONUMBER</Name><Value>True</Value></Property><Property><Name>AUTONUMBER_START</Name><Value>1</Value></Property><Property><Name>IsDefault</Name><Value>False</Value></Property></Properties>
</Object>
I need to debug dkt and the apply pattern process to correct this error.
After reviewing this issue, we found that the cause of the syntax error is because the dkt line breaks were UNIX-style (\n
), while the template parser expects Windows-style line breaks (\r\ n
).
This was an unfortunate change in publishing the project to GitHub, and then downloading it as a zip. In case of cloning the repository from a Windows Git client, the line breaks should be restored.