Bonjour,

j'ai une feuille de style XSLT dans laquelle j'ai défini un ensemble d'attributs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
<xsl:attribute-set name="texte">    
    <xsl:attribute name="font-size">11pt</xsl:attribute>    
    <xsl:attribute name="padding-before">0pt</xsl:attribute>
    <xsl:attribute name="padding-after">0pt</xsl:attribute>          
    <xsl:attribute name="font-weight">normal</xsl:attribute>
    <xsl:attribute name="font-variant">normal</xsl:attribute>      
  </xsl:attribute-set>
Et dans une classe Java, je voudrais récupérer la valeur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
xsl:attribute-set[@name='texte']/xsl:attribute[@name='font-size']/text()
Cette classe utilise le contexte de la règle XSLT.
J'ai tenté de récupérer la valeur à l'aide de la classe org.apache.xalan.templates.
Mais je suis bloqué. Si vous aviez une idée. Merci.

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
Stylesheet stylesheet = context.getStylesheet(); 
 
    for (int i=0; i<stylesheet.getAttributeSetCount(); i++) {
      ElemAttributeSet elemAttributeSet = stylesheet.getAttributeSet(i);
      System.out.println("M1 name: " + elemAttributeSet.getNodeName() + ", localname : " + elemAttributeSet.getName().getLocalName());
 
      if (elemAttributeSet.getName().getLocalName().equals("texte")) {
        i = stylesheet.getAttributeSetCount() + 1;
        NodeList nl = elemAttributeSet.getChildNodes();
        System.out.println("M2 child : " + elemAttributeSet.hasChildNodes() + " : " + nl.getLength());    
 
        for (int j=0; j<nl.getLength(); j++) {
          ElemAttribute n = (ElemAttribute) nl.item(j);
          System.out.println("M3 name  : " + n.getNodeName() + ", localname : " + n.getLocalName());
 
          // Et là, pas moyen de récupérer la valeur de l'attribut name
 
          NodeList attributeNodeList = n.getChildNodes();
          System.out.println("M3 child : " + n.hasChildNodes() + " : " + attributeNodeList.getLength());    
 
            for (int k=0; k<attributeNodeList.getLength(); k++) { 
              Node nt = attributeNodeList.item(k);
            System.out.println("M4 " + nt.getNodeName() + " : " + nt.getNodeValue());                      
            }
        }
 
      }        
    }