<xsl:apply-templates select="element[child='Yes']">
fonctionne très bien, mais je voudrais utiliserXSLT - Match élément variable dans prédicat
<xsl:apply-templates select="element[$childElementName='Yes']">
Je peux utiliser une variable pour spécifier le noeud.
Par exemple
<xsl:apply-templates select="theList/entity[Central='Yes']">
fonctionne très bien contre:
<?xml version="1.0" encoding="utf-8"?>
<theList>
<entity>
<Business-Name>Company 1</Business-Name>
<Phone-Number>123456</Phone-Number>
<Central>Yes</Central>
<region1>No</region1>
<region2>Yes</region2>
<region3>No</region3>
<Northern>No</Northern>
</entity>
<entity>
<Business-Name>Company 2</Business-Name>
<Phone-Number>123456</Phone-Number>
<Central>No</Central>
<region1>Yes</region1>
<region2>No</region2>
<region3>No</region3>
<Northern>Yes</Northern>
</entity>
<entity>
<Business-Name>Company 3</Business-Name>
<Phone-Number>123456</Phone-Number>
<Central>Yes</Central>
<region1>No</region1>
<region2>No</region2>
<region3>No</region3>
<Northern>No</Northern>
</entity>
<entity>
<Business-Name>Company 4</Business-Name>
<Phone-Number>123456</Phone-Number>
<Central>No</Central>
<region1>No</region1>
<region2>No</region2>
<region3>No</region3>
<Northern>No</Northern>
</entity>
</theList>
Mais je ne veux pas coder en dur le nom de l'élément enfant.
Des suggestions?
Merci Tim pour la réponse:
<xsl:apply-templates select="theList/entity[child::*[name()=$childElement]='Yes']" />
Ne serait-sélectionner une 'entity' qui a un nœud descendant avec une valeur de «Oui» atteindre la même chose? – Oded
Bonne question (+1). Voir ma réponse pour une solution très courte et simple. :) –