pang
pang

Reputation: 4154

How to match attribute for special character in XSLT

Assume that I have xml as follow and I want to match the template for tag Cell with attribute aid5:cellstyle="hilite_white"

How can I do that in XSLT template as I can't select attribute with special char like :?

<table>
<Cell aid:table="cell" aid5:cellstyle="hilite_white" aid:crows="1" aid:ccols="1" aid:ccolwidth="112" />
</table>

@jim: here is what I try

<xsl:template match="Cell[@aid5:cellstyle='hilite_white']">
            <xsl:value-of select="local-name()" />

        </xsl:template>

Upvotes: 1

Views: 216

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52848

You can either use * as the namespace prefix in your match:

match="Cell[@*:cellstyle='hilite_white']"

or you can declare the prefix in your xsl:stylesheet:

<xsl:stylesheet version="2.0" xmlns:aid5="unknown namespace uri" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

(Replace unknown namespace uri with whatever the namepace uri is in the source XML.)

Upvotes: 1

Related Questions