Xpathforlife
Xpathforlife

Reputation: 87

Select specific part of a attribute and assign it to a variable

I want to select specific part of a attribute and assign it to a variable.

Input :

<p anepane="swedd" conref="../../go_ref/Disti_didin#Disti_didin/k_irl_oi_2222"/>

There are lot of <p> in input. In that all <p> last part starts with p_frm. So I want common template to select p_frm_l1_los_246 from @conref and assign to to a variable.

Tried code :

<xsl:template match="p[@conref]">
    <xsl:variable name="aaa" select="self:p"/>
</xsl:template>

Above tried code is not working. Help me to solve this.

Upvotes: 0

Views: 36

Answers (1)

zx485
zx485

Reputation: 29022

Try this approach:

<xsl:template match="p[substring-after(substring-after(@conref,'#'),'/') = 'p_frm_l1_los_246']">
    <xsl:variable name="aaa" select="@conref"/>
</xsl:template>

It selects the whole value of p/@conref which ends with p_frm_l1_los_246.

../../page_references/where_used_breadcrumbs.dita#where_used_breadcrumbs/p_frm_l1_los_246

Upvotes: 1

Related Questions