1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <xsl:stylesheet version="1.0"
|
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
4 | <xsl:output encoding="ISO-8859-1" method="xml"/>
|
---|
5 |
|
---|
6 | <xsl:variable name="targetId"></xsl:variable>
|
---|
7 | <xsl:variable name="action"></xsl:variable>
|
---|
8 | <xsl:template match="/">
|
---|
9 | <xsl:apply-templates select="*|@*"/>
|
---|
10 | </xsl:template>
|
---|
11 |
|
---|
12 |
|
---|
13 | <xsl:template name="toto">
|
---|
14 | <toto/>
|
---|
15 | </xsl:template>
|
---|
16 |
|
---|
17 |
|
---|
18 | <xsl:template name="add">
|
---|
19 | <xsl:param name="type"/>
|
---|
20 | <xsl:choose>
|
---|
21 | <xsl:when test="$type = 'toto'">
|
---|
22 | <xsl:call-template name="toto"/>
|
---|
23 | </xsl:when>
|
---|
24 | </xsl:choose> </xsl:template> <xsl:template name="copy">
|
---|
25 | <xsl:copy>
|
---|
26 | <xsl:apply-templates select="node()|@*"/>
|
---|
27 | </xsl:copy>
|
---|
28 | </xsl:template>
|
---|
29 | <xsl:template name="del">
|
---|
30 | <!-- effacer ! -->
|
---|
31 | </xsl:template>
|
---|
32 |
|
---|
33 | <xsl:template match="*[attribute::id and @id='']">
|
---|
34 | <!-- attribute::type pour éviter de confondre l'absence d'attibute et
|
---|
35 | la valeur nulle -->
|
---|
36 | <xsl:choose>
|
---|
37 | <xsl:when test="$action='del'">
|
---|
38 | <xsl:call-template name="del"/>
|
---|
39 | </xsl:when>
|
---|
40 | <xsl:when test="$action='add'">
|
---|
41 | <xsl:call-template name="copy"/>
|
---|
42 | <xsl:call-template name="add">
|
---|
43 | <xsl:with-param name="type">toto</xsl:with-param>
|
---|
44 | </xsl:call-template>
|
---|
45 | </xsl:when>
|
---|
46 | <xsl:when test="$action='repl'">
|
---|
47 | <xsl:choose>
|
---|
48 | <xsl:when test="$action='del'">
|
---|
49 | <xsl:call-template name="del"/>
|
---|
50 | </xsl:when>
|
---|
51 | </xsl:choose>
|
---|
52 | <xsl:call-template name="add">
|
---|
53 | <xsl:with-param name="type">toto</xsl:with-param>
|
---|
54 | </xsl:call-template>
|
---|
55 | </xsl:when> </xsl:choose>
|
---|
56 | </xsl:template>
|
---|
57 |
|
---|
58 | <!-- liste des elements qui peuvent être édités, donc attribut id -->
|
---|
59 |
|
---|
60 | <xsl:template match="domain">
|
---|
61 | <xsl:copy>
|
---|
62 | <xsl:if test="not(@id)">
|
---|
63 | <xsl:attribute name="id"><xsl:value-of
|
---|
64 | select="generate-id()"/></xsl:attribute>
|
---|
65 | </xsl:if>
|
---|
66 | <xsl:attribute name="add">task</xsl:attribute>
|
---|
67 | <xsl:attribute name="del">domain</xsl:attribute>
|
---|
68 | <xsl:apply-templates select="node()|@*"/>
|
---|
69 | </xsl:copy>
|
---|
70 | </xsl:template>
|
---|
71 |
|
---|
72 | <xsl:template match="name">
|
---|
73 | <xsl:copy>
|
---|
74 | <xsl:if test="not(@id)">
|
---|
75 | <xsl:attribute name="id"><xsl:value-of
|
---|
76 | select="generate-id()"/></xsl:attribute>
|
---|
77 | </xsl:if>
|
---|
78 | <xsl:attribute name="replace">PCDATA</xsl:attribute>
|
---|
79 | <xsl:apply-templates select="node()|@*"/>
|
---|
80 | </xsl:copy>
|
---|
81 | </xsl:template>
|
---|
82 |
|
---|
83 |
|
---|
84 | <xsl:template match="task">
|
---|
85 | <xsl:copy>
|
---|
86 | <xsl:if test="not(@id)">
|
---|
87 | <xsl:attribute name="id"><xsl:value-of
|
---|
88 | select="generate-id()"/></xsl:attribute>
|
---|
89 | </xsl:if>
|
---|
90 | <xsl:attribute name="replace">PCDATA</xsl:attribute>
|
---|
91 | <xsl:attribute name="add">task</xsl:attribute> <xsl:apply-templates select="node()|@*"/>
|
---|
92 | </xsl:copy>
|
---|
93 | </xsl:template>
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 | <xsl:template match="*">
|
---|
98 | <xsl:copy>
|
---|
99 | <xsl:apply-templates select="node()|@*"/>
|
---|
100 | </xsl:copy>
|
---|
101 | </xsl:template>
|
---|
102 | <xsl:template match="@*">
|
---|
103 | <xsl:copy/>
|
---|
104 | </xsl:template>
|
---|
105 | </xsl:stylesheet>
|
---|