blob: e022521893a970a56285ebaf9376d3b5f7af8eb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
---
title: position
slug: Web/XPath/Functions/position
tags:
- Référence_XSLT
translation_of: Web/XPath/Functions/position
original_slug: Web/XPath/Fonctions/position
---
{{ XsltRef() }}
La fonction `position` retourne un nombre égal à la position du contexte dans le contexte d'évaluation d'expression.
### Syntaxe
position()
### Retour
Un nombre entier égal à la position du contenu dans le contexte d'évaluation d'expression.
### Notes
- Notez que la numérotation de la position d'un n\&oelig:ud dans un contexte commence à 1. Le premier nœud a donc la position 1.
<!---->
- Le contexte est déterminé par le reste du chemin :
<!---->
<xsl:template match="//a[position() = 5]">
<!-- cet exemple 'attrape' le cinquième élément "a"
n'importe où dans le document. -->
</xsl:template>
<!---->
<xsl:template match="//div[@class='foo']/bar[position() = 1]">
<!-- cet exemple 'attrape' le premier
élément "bar" enfant d'un élément "div"
avec un attribut "class" valant "foo" -->
</xsl:template>
### Définition
[XPath 1.0, section 4.1](http://www.w3.org/TR/xpath#function-position).
### Support Gecko
Supportée.
|