XSL / Die XSLT - Struktur / XPath 3.1: Map, xsl:map / XPath: map:contains
![]() |
![]() |
➪ map:contains prüft, ob eine Map einen bestimmten Schlüssel aufweist.
Signatur:
map:contains($map as map(*), $key as xs:anyAtomicType) as xs:boolean
Siehe https://www.w3.org/TR/xpath-functions-31/#func-map-contains
<xsl:template match="/">
<root>
<contains nr="1">
<xsl:value-of select="map:contains($vmap, 2)"/>
</contains>
<contains nr="2">
<xsl:value-of select="map:contains($vmap, 'Lotte Rielos')"/>
</contains>
<contains nr="3">
<xsl:value-of select="map:contains(map{'Theo':23}, 'Theo')"/>
</contains>
</root>
</xsl:template>
Auch dieses Ergebnis ist nachvollziehbar. Im Fall Nr. 1 ist der Schlüssel "2" enthalten, also true. Die Information (Nr. 2) 'Lotte Rielos' ist zwar als Wert vorhanden, aber nicht als Schlüssel, daher false. Im dritten Fall wird nicht die eingangs erwähnte XSL-Variable verwendet, sondern eine neue Map mit dem Schlüssel 'Theo' generiert und umgehend geprüft, ob 'Theo' auch vorhanden ist: true.
<root>
<contains nr="1">true</contains>
<contains nr="2">false</contains>
<contains nr="3">true</contains>
</root>
wg / 7. April 2020
Fragen? Anmerkungen? Tipps?
Bitte nehmen Sie Kontakt zu mir auf.
V.i.S.d.P.: Wilfried Grupe * Klus 6 * 37643 Negenborn
☎ 0151. 750 360 61 * eMail: info10@wilfried-grupe.de