Mr. Boy
Mr. Boy

Reputation: 63846

Match multiple element names of a specific parent element

I am used to matching multiple elements like this:

<xsl:template match="horse | sheep | pig | cow | dog">

But how can I restrict this to such elements which are children of a given parent type. e.g. it would match:

<animals>
 <horse .../>
 <sheep .../>
</animals>

But not match:

<pets>
 <horse .../>
 <dog .../>
</pets>

Upvotes: 2

Views: 196

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167781

You need to spell that out as <xsl:template match="animals/horse | animals/sheep | animals/pig | animals/cow | animals/dog">.

Upvotes: 2

Related Questions