Yann
Yann

Reputation: 35

Concatenation of occurrences / XML and XSL

I have this kind of XML with similar beginning of url for <platform> and <source>:

<informations>
    <platform>http://networkcultures.org/</plateforme>
    <source>http://networkcultures.org/wpmu/theoryondemand/2011/07/11/distant-reading/</source>
</informations>

I would like to know with XSL how to have this output in HTML, in order to combine/concatenate the two markups in the beginning and have after the rest of <source> :

<span class="url">
    <span class="platform"><xsl:value-of select="platform"/></span>
    <xsl:value-of select="the rest of <source>"/>
</span>

I've searched for <xsl:key> or generate-id() but without success. Hope you'll understand my question. And thanks for your help !

Upvotes: 2

Views: 91

Answers (1)

LarsH
LarsH

Reputation: 28004

Change the second <xsl:value-of> as follows:

<span class="url">
    <span class="platform"><xsl:value-of select="platform"/></span>
    <xsl:value-of select="substring-after(source, platform)" />
</span>

This assumes that the string value of <platform> will always occur at the beginning of <source>. Otherwise, substring-after() returns an empty string.

This will give, e.g.

<span class="url">
    <span class="platform">http://networkcultures.org/</span>wpmu/theoryondemand/2011/07/11/distant-reading/
</span>

Upvotes: 1

Related Questions