@@ -45,8 +45,8 @@ public SimpleDMNDialectTransformer(BuildLogger logger, DMNVersion sourceVersion,
4545 }
4646
4747 public TDefinitions transformDefinitions (TDefinitions sourceDefinitions ) {
48- this .logger .info (String .format ("Transforming '%s' from DMN %s to DMN %s ..." , sourceDefinitions .getName (), this .sourceVersion .getVersion (), this .targetVersion .getVersion ()));
4948 if (this .sourceVersion != this .targetVersion ) {
49+ this .logger .info (String .format ("Transforming '%s' from DMN %s to DMN %s ..." , sourceDefinitions .getName (), this .sourceVersion .getVersion (), this .targetVersion .getVersion ()));
5050 sourceDefinitions .accept (this .visitor , null );
5151 }
5252 return sourceDefinitions ;
@@ -80,10 +80,10 @@ public DMNBaseElement visit(TDefinitions element, C context) {
8080 element .getOtherAttributes ().remove (NO_NAMESPACE_SCHEMA_LOCATION );
8181 }
8282 // Update expression language
83- if (this . sourceVersion . getFeelNamespace (). equals (element .getTypeLanguage ())) {
83+ if (isFEELNamespace (element .getTypeLanguage ())) {
8484 element .setTypeLanguage (this .targetVersion .getFeelNamespace ());
8585 }
86- if (this . sourceVersion . getFeelNamespace (). equals (element .getExpressionLanguage ())) {
86+ if (isFEELNamespace (element .getExpressionLanguage ())) {
8787 element .setExpressionLanguage (this .targetVersion .getFeelNamespace ());
8888 }
8989 // Update XML namespaces
@@ -105,10 +105,10 @@ public DMNBaseElement visit(TImport element, C context) {
105105
106106 private void updateImportType (TImport element ) {
107107 String importType = element .getImportType ();
108- if (sourceVersion . getNamespace (). equals (importType )) {
108+ if (isDMNNamespace (importType )) {
109109 element .setImportType (targetVersion .getNamespace ());
110110 }
111- if (sourceVersion . getFeelNamespace (). equals (importType )) {
111+ if (isFEELNamespace (importType )) {
112112 element .setImportType (targetVersion .getFeelNamespace ());
113113 }
114114 }
@@ -644,8 +644,7 @@ private boolean isFEELQName(QName typeRef) {
644644 String prefix = typeRef .getPrefix ();
645645 namespaceURI = this .definitions .getNamespaceURI (prefix );
646646 }
647- return this .targetVersion .getFeelNamespace ().equals (namespaceURI )
648- || this .sourceVersion .getFeelNamespace ().equals (namespaceURI );
647+ return isFEELNamespace (namespaceURI );
649648 }
650649
651650 private boolean isDefinedInCurrentModel (String name ) {
@@ -680,16 +679,16 @@ private void updateXMLNamespaces(DMNBaseElement element) {
680679 ElementInfo elementInfo = element .getElementInfo ();
681680 // DMN namespace
682681 String newNamespaceURI = elementInfo .getNamespaceURI ();
683- if (this . sourceVersion . getNamespace (). equals (elementInfo .getNamespaceURI ())) {
682+ if (isDMNNamespace (elementInfo .getNamespaceURI ())) {
684683 newNamespaceURI = this .targetVersion .getNamespace ();
685684 }
686685 Map <String , String > newNsContext = new LinkedHashMap <>(elementInfo .getNsContext ());
687686 for (Map .Entry <String , String > entry : newNsContext .entrySet ()) {
688687 // DMN namespace
689- if (this . sourceVersion . getNamespace (). equals (entry .getValue ())) {
688+ if (isDMNNamespace (entry .getValue ())) {
690689 entry .setValue (this .targetVersion .getNamespace ());
691690 // FEEL namespace
692- } else if (this . sourceVersion . getFeelNamespace (). equals (entry .getValue ())) {
691+ } else if (isFEELNamespace (entry .getValue ())) {
693692 entry .setValue (this .targetVersion .getFeelNamespace ());
694693 }
695694 }
@@ -706,4 +705,14 @@ private void updateXMLNamespaces(DMNBaseElement element) {
706705 ElementInfo newElementInfo = new ElementInfo (elementInfo .getLocation (), elementInfo .getPrefix (), newNamespaceURI , newNsContext );
707706 element .setElementInfo (newElementInfo );
708707 }
708+
709+ // Include all version to recover from errors when the namespaces do not match the sourceVersion
710+ private boolean isDMNNamespace (String namespace ) {
711+ return DMNVersion .VERSIONS .stream ().anyMatch (v -> v .getNamespace ().equals (namespace ));
712+ }
713+
714+ // Include all version to recover from errors when the namespaces do not match the sourceVersion
715+ private boolean isFEELNamespace (String namespace ) {
716+ return DMNVersion .VERSIONS .stream ().anyMatch (v -> v .getFeelNamespace ().equals (namespace ));
717+ }
709718}
0 commit comments