comparison artifacts/contrib/inline-dc-attribute.xsl @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/contrib/inline-dc-attribute.xsl@43bf4976dd24
children
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 inline-dc-attribute.xsl
4 =======================
5 Transforms datacage templates from:
6
7 <foo>
8 <dc:element name="bar" value="${baz}"/>
9 <dc:element name="bla" value="${blub}-${urgs}"/>
10 </foo>
11
12 to:
13
14 <foo bar="{$bar} bla="{$blub}-{$urgs}/>
15 -->
16 <xsl:stylesheet version="1.0"
17 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:dc="http://www.intevation.org/2011/Datacage">
19
20 <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
21
22 <xsl:template name="string-replace-all">
23 <xsl:param name="text"/>
24 <xsl:param name="replace"/>
25 <xsl:param name="by"/>
26 <xsl:choose>
27 <xsl:when test="contains($text, $replace)">
28 <xsl:value-of select="substring-before($text,$replace)"/>
29 <xsl:value-of select="$by"/>
30 <xsl:call-template name="string-replace-all">
31 <xsl:with-param name="text" select="substring-after($text,$replace)"/>
32 <xsl:with-param name="replace" select="$replace"/>
33 <xsl:with-param name="by" select="$by"/>
34 </xsl:call-template>
35 </xsl:when>
36 <xsl:otherwise>
37 <xsl:value-of select="$text"/>
38 </xsl:otherwise>
39 </xsl:choose>
40 </xsl:template>
41
42 <xsl:template
43 match="node()[count(dc:attribute) &gt; 0 and namespace-uri() != 'http://www.intevation.org/2011/Datacage']">
44 <xsl:copy>
45 <xsl:for-each select="./dc:attribute">
46 <xsl:attribute name="{@name}">
47 <xsl:call-template name="string-replace-all">
48 <xsl:with-param name="text" select="@value"/>
49 <xsl:with-param name="replace">${</xsl:with-param>
50 <xsl:with-param name="by">{$</xsl:with-param>
51 </xsl:call-template>
52 </xsl:attribute>
53 </xsl:for-each>
54 <xsl:apply-templates select="@*|node()" mode="ignore-text"/>
55 </xsl:copy>
56 </xsl:template>
57
58 <xsl:template match="dc:attribute|text()" mode="ignore-text"/>
59 <xsl:template match="@*|node()" mode="ignore-text">
60 <xsl:copy>
61 <xsl:apply-templates select="@*|node()"/>
62 </xsl:copy>
63 </xsl:template>
64
65 <xsl:template match="@*|node()">
66 <xsl:copy>
67 <xsl:apply-templates select="@*|node()"/>
68 </xsl:copy>
69 </xsl:template>
70
71 </xsl:stylesheet>

http://dive4elements.wald.intevation.org