File: bug-89.xsl

package info (click to toggle)
libxslt 1.1.43-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,188 kB
  • sloc: xml: 66,120; ansic: 36,035; sh: 4,582; python: 3,206; makefile: 1,378; javascript: 470; perl: 34
file content (105 lines) | stat: -rw-r--r-- 2,610 bytes parent folder | download | duplicates (13)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="ISO-8859-1" method="xml"/>

<xsl:variable name="targetId"></xsl:variable>
<xsl:variable name="action"></xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="*|@*"/>
</xsl:template>


<xsl:template name="toto">
<toto/>
</xsl:template>


<xsl:template name="add">
<xsl:param name="type"/>
<xsl:choose>
<xsl:when test="$type = 'toto'">
<xsl:call-template name="toto"/>
</xsl:when>
</xsl:choose> </xsl:template> <xsl:template name="copy">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template name="del">
<!-- effacer ! -->
</xsl:template>

<xsl:template match="*[attribute::id and @id='']">
<!-- attribute::type pour viter de confondre l'absence d'attibute et
la valeur nulle -->
<xsl:choose>
<xsl:when test="$action='del'">
<xsl:call-template name="del"/>
</xsl:when>
<xsl:when test="$action='add'">
<xsl:call-template name="copy"/>
<xsl:call-template name="add">
<xsl:with-param name="type">toto</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$action='repl'">
<xsl:choose>
<xsl:when test="$action='del'">
<xsl:call-template name="del"/>
</xsl:when>
</xsl:choose>
<xsl:call-template name="add">
<xsl:with-param name="type">toto</xsl:with-param>
</xsl:call-template>
</xsl:when> </xsl:choose>
</xsl:template>

<!-- liste des elements qui peuvent tre dits, donc attribut id -->

<xsl:template match="domain">
<xsl:copy>
<xsl:if test="not(@id)">
<xsl:attribute name="id"><xsl:value-of
select="generate-id()"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="add">task</xsl:attribute>
<xsl:attribute name="del">domain</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="name">
<xsl:copy>
<xsl:if test="not(@id)">
<xsl:attribute name="id"><xsl:value-of
select="generate-id()"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="replace">PCDATA</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>


<xsl:template match="task">
<xsl:copy>
<xsl:if test="not(@id)">
<xsl:attribute name="id"><xsl:value-of
select="generate-id()"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="replace">PCDATA</xsl:attribute>
<xsl:attribute name="add">task</xsl:attribute> <xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>



<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>