Reputation: 1214
I have following xml code
<root_el>
<cell>
<button id="btn_phone_mvg">
<text>…</text>
</button>
</cell>
<cell>
<button id="btn_email_cmb">
<text>…</text>
</button>
</cell>
<cell>
<button id="btn_address_mvg">
<text>…</text>
</button>
</cell>
</root_el>
And I need to transform it to another xml where all cell with child button that has id with _mvg ending will be removed
So far I've figured out that to remove all cells with child buttons with certain id attribute value will takes this
<xsl:template match="cell[button/@id='value']"/>
and to get the last 4 chars of id attribute will take next XPath expression
substring(@id,string-length(@id)-4)
But I don't know how to put this together and get required output
Upvotes: 1
Views: 455
Reputation: 89285
Try this way to match <cell>
with child <button>
that has id with last four character equals _mvg
:
<xsl:template match="cell[button[substring(@id,string-length(@id)-3)='_mvg']]"/>
Or if available, you can use ends-with()
function to literally match by string ending :
<xsl:template match="cell[button[ends-with(@id, '_mvg')]]"/>
Upvotes: 4