Structural variation while inserting fragment based on user input
Posted: Sat Sep 14, 2024 12:40 pm
Hello,
In a framework operation, I am trying to let the user determine the number of children a fragment would have.
For example, take the following fragment:
I am inserting user input by replacing "Name" and "Title" with ${ask('...',generic,'')}.
Now I want to split the input for artist along the commas so that user input "Robert Plant, Jimmy Page, Eric Clapton" would translate into three separate <artist> elements:
I tried using xpath_eval with a for loop on tokenize of the ${ask()}, but it brought no output:
I may have made some mistakes in the code, but I may also have misunderstood some limitation.
Is there a way to do what I an trying to do?
Thank you in advance,
Alexey
In a framework operation, I am trying to let the user determine the number of children a fragment would have.
For example, take the following fragment:
Code: Select all
<cd>
<artist>Name</artist>
<title>Title</title>
</cd>
Now I want to split the input for artist along the commas so that user input "Robert Plant, Jimmy Page, Eric Clapton" would translate into three separate <artist> elements:
Code: Select all
<cd>
<artist>Robert Plant</artist>
<artist>Jimmy Page</artist>
<artist>Eric Clapton</artist>
<title>Title</title>
</cd>
Code: Select all
${xpath_eval(for $i in tokenize(${ask('Artists:',generic,'')}) return <artist>$i</artist>)}
Is there a way to do what I an trying to do?
Thank you in advance,
Alexey