1 |
teichmann |
30 |
<?xml version="1.0" encoding="UTF-8" ?> |
2 |
|
|
<!-- |
3 |
|
|
(c) 2007 by Intevation GmbH |
4 |
|
|
Author: Sascha L. Teichmann |
5 |
|
|
Converts <choice value="" options="xxx" other="..."/> |
6 |
|
|
to <choice value="xxx" other="..."/> |
7 |
|
|
--> |
8 |
|
|
<xsl:stylesheet version="1.0" |
9 |
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
10 |
|
|
<xsl:output method="xml" encoding="UTF-8"/> |
11 |
|
|
|
12 |
|
|
<xsl:template match="choice"> |
13 |
|
|
<choice> |
14 |
|
|
<!-- iterate over all attributes --> |
15 |
|
|
<xsl:for-each select="@*"> |
16 |
|
|
<xsl:choose> |
17 |
|
|
<xsl:when test="name() = 'value' and current() = ''"/> |
18 |
|
|
<!-- ignore old value attribute --> |
19 |
|
|
<xsl:when test="name() = 'options'"> |
20 |
|
|
<!-- save old options attribute as value --> |
21 |
|
|
<xsl:attribute name="value"> |
22 |
|
|
<xsl:value-of select="."/> |
23 |
|
|
</xsl:attribute> |
24 |
|
|
</xsl:when> |
25 |
|
|
<xsl:otherwise> |
26 |
|
|
<!-- copy thru all other attributes --> |
27 |
|
|
<xsl:attribute name="{name()}"> |
28 |
|
|
<xsl:value-of select="."/> |
29 |
|
|
</xsl:attribute> |
30 |
|
|
</xsl:otherwise> |
31 |
|
|
</xsl:choose> |
32 |
|
|
</xsl:for-each> |
33 |
|
|
</choice> |
34 |
|
|
</xsl:template> |
35 |
|
|
|
36 |
|
|
<!-- copy thru all other stuff --> |
37 |
|
|
<xsl:template match="@*|node()"> |
38 |
|
|
<xsl:copy> |
39 |
|
|
<xsl:apply-templates select="@*|node()"/> |
40 |
|
|
</xsl:copy> |
41 |
|
|
</xsl:template> |
42 |
|
|
|
43 |
|
|
</xsl:stylesheet> |