I’m a bit stuck on how to proceed best with following XML example : What I have is the following :
<Story>
<Content para="div"><local>This is some (normal) text to start with.</local></Content>
<Content para="div"><local>Connect something (</local></Content>
<Content para="div"><local><refnr value="58236"/></local></Content>
<Content para="div"><local>) to something else (</local></Content>
<Content para="div"><local><refnr value="58237"/></local></Content>
<Content para="div"><local>), and make sure it's connected to this (</local></Content>
<Content para="div"><local><refnr value="58239"/></local></Content>
<Content para="div"><local>).</local></Content>
<Content para="div"><local>If that's ok do the same with this (</local></Content>
<Content para="div"><local><refnr value="58238"/></local></Content>
<Content para="div"><local>) also.</local></Content>
<Content para="div"><local>This is some normal text.</local></Content>
<Content para="div"><local>This also.</local></Content>
</Story>
and the output I’d like to get is as follows :
<Story>
<Content para="div"><local>This is some (normal) text to start with.</local></Content>
<Content para="div"><local>Connect something (<refnr value="58236"/>) to something else (<refnr value="58237"/>), and make sure it's connected to this (<refnr value="58239"/>).</local></Content>
<Content para="div"><local>If that's ok do the same with this (<refnr value="58238"/>) also.</local></Content>
<Content para="div"><local>This is some normal text.</local></Content>
<Content para="div"><local>This also.</local></Content>
</Story>
Or, to ‘code’ it : Any [Content para=div][local] node ending with an open bracket, needs to be merged with the following [Content para=div][local] nodes untill the node containing the last closing bracket and the end of the sentence (identified by closing dot). I was able to do some things, but it became overly complex and slow and without all wanted results. Any advice using xslt2 ?
This XSLT 2.0 transformation (can easily be translated to XSLT 1.0):
when applied on the provided XML document:
produces the wanted, correct result: