This is an automated email from the ASF dual-hosted git repository.

shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new fd950d3  Address incorrect relative paths when Copying or Appending 
TDML
fd950d3 is described below

commit fd950d3d607ec4928fb08d9acbbc66644465bef9
Author: Jeremy Yao <[email protected]>
AuthorDate: Wed Apr 9 16:26:24 2025 -0400

    Address incorrect relative paths when Copying or Appending TDML
    
    Closes #1034
---
 src/tdmlEditor/utilities/tdmlXmlUtils.ts | 34 +++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/tdmlEditor/utilities/tdmlXmlUtils.ts 
b/src/tdmlEditor/utilities/tdmlXmlUtils.ts
index 42c7a36..28b809a 100644
--- a/src/tdmlEditor/utilities/tdmlXmlUtils.ts
+++ b/src/tdmlEditor/utilities/tdmlXmlUtils.ts
@@ -336,9 +336,22 @@ export async function copyTestCase(
       node.name?.endsWith(testCaseElement)
     )
 
+    /**
+     * Creates an absolute path from the given relative path to the temp TDML 
file
+     *
+     * @param relativePath - Relative path to convert into an absolute path
+     * @returns
+     */
+    const getAbsolutePathFromRelativeToTempTDMLFIlePath = (
+      relativePath: string
+    ) => resolve(dirname(getTmpTDMLFilePath()), relativePath)
+
+    // set to relative path to DFDL file from destination folder
     sourceTestCase[0].attributes[testCaseModelAttribute] = relative(
-      destinationFilePath,
-      sourceTestCase[0].attributes[testCaseModelAttribute].toString()
+      dirname(destinationFilePath),
+      getAbsolutePathFromRelativeToTempTDMLFIlePath(
+        sourceTestCase[0].attributes[testCaseModelAttribute].toString() // 
Contains relative path to the temp TDML file
+      )
     )
 
     // Each test case may contain any number of documents
@@ -355,9 +368,12 @@ export async function copyTestCase(
                 documentPartNode.elements !== undefined &&
                 documentPartNode.elements[0].text !== undefined
               )
+                // Set to relative path to data file from destination folder
                 documentPartNode.elements[0].text = relative(
-                  destinationFilePath,
-                  documentPartNode.elements[0].text.toString()
+                  dirname(destinationFilePath),
+                  getAbsolutePathFromRelativeToTempTDMLFIlePath(
+                    documentPartNode.elements[0].text.toString() // Contains 
relative path to the temp TDML file
+                  )
                 )
             })
         )
@@ -376,11 +392,15 @@ export async function copyTestCase(
               if (
                 dfdlInfosetNode.elements !== undefined &&
                 dfdlInfosetNode.elements[0].text !== undefined
-              )
+              ) {
+                // Set relative path to infoset from destinatino
                 dfdlInfosetNode.elements[0].text = relative(
-                  destinationFilePath,
-                  dfdlInfosetNode.elements[0].text.toString()
+                  dirname(destinationFilePath),
+                  getAbsolutePathFromRelativeToTempTDMLFIlePath(
+                    dfdlInfosetNode.elements[0].text.toString() // Relative 
path from temp TDML file to infoset file
+                  )
                 )
+              }
             })
         )
     })

Reply via email to