Bonjour,
Je dois récupérer le contenu d'une balise tei (Text encoding initiative = édition numérique de documents).
Voici un exemple:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<record>
    <doc_id>cote-g226_1_f_176__r____</doc_id>
    <nb_termes>3</nb_termes>
    <num_fragment>1</num_fragment>
    <bibl3>b6839-3</bibl3>
    <termes>
        <term rend="underline">gens de <choice>
                <abbr>lettr</abbr>
                <expan>lettr<ex>es</ex>
                </expan>
            </choice>
        </term>
        <term>Beautés</term>
        <term hand="GF-encre" rend="underline">Socrate <choice>
                <orig>
                    <c>&amp;</c>
                </orig>
                <reg>et</reg>
            </choice> Platon</term>
    </termes>
</record>
Je veux retourner tous les termes, avec, quant c'est le cas, leur version originale et régularisée.
Dans l'exemple, il y a 3 termes dont 2 qui auront 2 forme (orig et reg + abbr et expan); je dois donc retourner 5 termes.
Pour le premier <term> : "gens de lettr" et "gens de lettres";
pour le 2nd : "Beautés" (tout simple, mon préféré)
pour le 3ème: "Socrate & Platon" et "Socrate et Platon".

Pour cela, j'utilise XSLT:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg"
	xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns="http://www.tei-c.org/ns/1.0"
	xmlns:dbp="http://site.fr/ns/1.0" version="1.0">
 
	<xsl:template match="/">
		<xsl:for-each select="//termes/*">
		REGUL : INSERT INTO tmp_termes_indexation VALUES ('<xsl:call-template name="regul"></xsl:call-template>');
		DIPLO : INSERT INTO tmp_termes_indexation VALUES ('<xsl:call-template name="diplo"></xsl:call-template>');
 
		</xsl:for-each>
	</xsl:template>
 
	<xsl:template match="*[ancestor::termes]">
		<xsl:apply-templates />
	</xsl:template>
 
	<xsl:template match="record">
	</xsl:template>
 
	<xsl:template match="bibl3"></xsl:template>
 
	<xsl:template match="//termes"></xsl:template>
 
	<xsl:template name="regul" match="//term/choice">
		<xsl:choose>
			<xsl:when test="abbr[@type='conventionnel']">
				<xsl:choose>
					<xsl:when test="reg">
						<xsl:apply-templates select="reg[last()]" />
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="abbr" />
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="abbr and expan and reg">
				<xsl:apply-templates select="reg" />
			</xsl:when>
			<xsl:when test="abbr and expan">
				<xsl:apply-templates select="expan" />
			</xsl:when>
			<xsl:when test="orig and reg">
				<xsl:apply-templates select="reg" />
			</xsl:when>
			<xsl:when test="sic and corr">
				<xsl:apply-templates select="corr" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>    
 
   <xsl:template name="diplo" match="//term/choice">        
        <xsl:choose>            
            <xsl:when test="abbr">                
              <xsl:apply-templates select="abbr"/>                                         
            </xsl:when>               
            <xsl:when test="orig">
                <xsl:apply-templates select="orig"/>               
            </xsl:when>                  
            <xsl:when test="sic">
                <xsl:apply-templates select="sic"/>               
            </xsl:when>             
            <xsl:otherwise>
             <xsl:apply-templates/>
            </xsl:otherwise>            
        </xsl:choose>        
    </xsl:template>
 
	<xsl:template match="lb">*</xsl:template>
</xsl:stylesheet>
Sauf que le template "regul" semble être ignoré; je ne sais comment faire pour récupérer toutes mes formes pour ces termes.