I'm wondering if/how the following can be accomplished in XSLT. If not, what would you use? (I used OmniMark, but I would like to know if this is possible in XSLT.)
Here's an example of the input XML:
<?xml version="1.0" encoding="UTF-8"?>
<fragment>
<firstElem>
<secondElem>D12</secondElem>
</firstElem>
<firstElem>
<secondElem>A3J7-10</secondElem>
</firstElem>
<firstElem>
<secondElem>C2-4</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP20-25</secondElem>
</firstElem>
</fragment>
What I needed to do was take the text content of the secondElem
element and create as many new firstElem
elements as required. The '-' was a "through", so 'A3J7-10' was really 'A3J7' through 'A3J10' (A3J7, A3J8, A3J9, A3J10). (Sometimes the "through" would be fairly large, like A1B2C1-150 (A1B2C1 through A1B2C150).)
If there was no dash, nothing needed to be done.
Here's an example of the output XML:
<?xml version="1.0" encoding="UTF-8"?>
<fragment>
<firstElem>
<secondElem>D12</secondElem>
</firstElem>
<firstElem>
<secondElem>A3J7</secondElem>
</firstElem>
<firstElem>
<secondElem>A3J8</secondElem>
</firstElem>
<firstElem>
<secondElem>A3J9</secondElem>
</firstElem>
<firstElem>
<secondElem>A3J10</secondElem>
</firstElem>
<firstElem>
<secondElem>C2</secondElem>
</firstElem>
<firstElem>
<secondElem>C3</secondElem>
</firstElem>
<firstElem>
<secondElem>C4</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP20</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP21</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP22</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP23</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP24</secondElem>
</firstElem>
<firstElem>
<secondElem>QW9R7NP25</secondElem>
</firstElem>
</fragment>
Is there a way to do this in XSLT?
Thanks!