Problem generating an XML

Hi everyone,
sorry for the very generic title, but it's hard to explain my problem with few words.

I need to generate an XML file, but I'm stuck with a problem:

I have a publisher tag in the form "A, B" (without quotes)
and a composer tag in the form "a, b" (without quotes)

The desired output is:

A a A b B a B b

Thanks For the help

Has the problem to do ...
with the markup language "XML"
or ...
with the scripting language "Mp3tag Export scripting language" ...
and there maybe with the creation of several user-defined variables?

For the latter case ...
use the functions $put() ... or ... $puts() ... and $get() ...
from the "Mp3tag Export Scripting Language" ...
and some other functions from the "Mp3tag Scripting Language".

The problem, if there any, can be resolved kinda like this example ...

Note: I use this arrow <== with the meaning of an action "Format value" to fill a tag-field with a text constant. I use this arrow ==> with the meaning of showing the content from the variable. Mp3tag Scripting Language Tag-Field <== Value TMP01 <== 'A, B' TMP02 <== 'C, D' TMP11 <== $left(%TMP01%,$sub($strstr(%TMP01%,', '),1)) TMP12 <== $cutLeft(%TMP01%,$add($strstr(%TMP01%,', '),1)) TMP21 <== $left(%TMP02%,$strstr(%TMP02%,', ')) TMP22 <== $cutLeft(%TMP02%,$add($strstr(%TMP02%,', '),1)) %TMP11%', 'TMP21 ==> 'A, C' %TMP11%', 'TMP22 ==> 'A, D' %TMP12%', 'TMP21 ==> 'B, C' %TMP12%', 'TMP22 ==> 'B, D' Mp3tag Export Scripting Language $put(TMP01,'A, B') $put(TMP02,'C, D') $get(TMP01) ==> 'A, B' $get(TMP02) ==> 'C, D' $put(TMP11,$left($get(TMP01),$sub($strstr($get(TMP01),', '),1))) $put(TMP12,$cutLeft($get(TMP01),$add($strstr($get(TMP01),', '),1))) $put(TMP21,$left($get(TMP02),$strstr($get(TMP02),', ')) $put(TMP22,$cutLeft($get(TMP02),$add($strstr($get(TMP02),', '),1)) $get(TMP11) ==> 'A' $get(TMP12) ==> 'B' $get(TMP21) ==> 'C' $get(TMP22) ==> 'D'

DD.20150305.1720.CET

Hey thanks for the quick answer!
Yes, it's a problem with mp3tag export scripting language.

I realize now that I wasn't very clear while explaining my problem, I'm very sorry.

The real problem is that I don't know beforehand how many publishers and composers I'll have!
So it could be
'A, B' and 'a, b'
but it could also be
'A, B, C' and 'a'
or
'A, B,' and 'a, b, c, d'

I do expect a problem for you, if you want to create and handle all the possible permutations of Publishers and Composers.
And for what should it be worth?

Or do I misunderstand the problem?
Maybe you only want to get each single item from a list of items?
But there is no loop or foreach instruction, which works directly on the content of a tag-field, ...
therefore you have to do it the hard way, extract each single item from the itemlist, which is stored within one tag-field, step by step.

For example ... you can count the commas within a string (3 commas = 4 items), ...
and then decide, using $if, which case of a set of prepared cases, is able to handle this number of items.

For example ... you can try this sort of regular expression ...

$regexp('Aaa, Bbb, Ccc, Ddd, ','^(?:.+?, ){0}(.+?), (?:.+, )*$','$1') ==> 'Aaa' $regexp('Aaa, Bbb, Ccc, Ddd, ','^(?:.+?, ){1}(.+?), (?:.+, )*$','$1') ==> 'Bbb' $regexp('Aaa, Bbb, Ccc, Ddd, ','^(?:.+?, ){2}(.+?), (?:.+, )*$','$1') ==> 'Ccc' $regexp('Aaa, Bbb, Ccc, Ddd, ','^(?:.+?, ){3}(.+?), (?:.+, )*$','$1') ==> 'Ddd'

DD.20150305.1854.CET

Hmm, here is another idea, ...
how to split an itemlist into single addressable items, ...
by creating a multi-value tag-field from the tag-field, which contains the string with the itemlist.

  1. Copy the existing content from COMPOSER to new tag-field COMPOSER_META, ...
    e. g. the list of items is 'Aaa, Bbb, Ccc, Ddd'

  2. Run Action "Split field by separator", ...
    Field: COMPOSER_META
    Split character: ,

  3. Then there exists a multi-value tag-field COMPOSER_META.
    COMPOSER_META = 'Aaa'
    COMPOSER_META = 'Bbb'
    COMPOSER_META = 'Ccc'
    COMPOSER_META = 'Ddd'

Each value can be accessed directly by using the function $meta.
$meta(COMPOSER_META,0) ==> 'Aaa'
$meta(COMPOSER_META,1) ==> 'Bbb'
$meta(COMPOSER_META,2) ==> 'Ccc'
$meta(COMPOSER_META,3) ==> 'Ddd'

This might be useful when creating an export script, ...
which probably can have simpler coding needed than the $regex proposal.

After creating the report, the multi-value tag-field COMPOSER_META can be removed from the tag, using the ...
Action "Remove fields"
Field: COMPOSER_META

DD.20150305.2109.CET

Yes, I need to handle all the possible permutations...
"luckily" I think it's limited to 4 elements at most, but I wanted to avoid having to write all the possible cases if possible.
Thanks for the help :slight_smile:

Please explain, what should be the purpose of permutations in practice ...
which means all possible pairs of publishers and composers, this is crazy???
For a given 4x4 relation, that are 123*4 = 24 cases.

I assume, you simply want to extract each publisher from an itemlist of publishers ...
and want to print out this publisher.

I assume, you simply want to extract each composer from an itemlist of composers ...
and want to print out this composer.

DD.20150305.2012.CET

Yes, it's crazy. But I need to generate an XML that has to be sent to an online service, and they want that format :frowning:

Now I know that you don't know what a permutation is. :blush:

DD.20150305.2029.CET