teichmann@5499: <?xml version="1.0" encoding="UTF-8"?> teichmann@5499: <!-- teichmann@5499: inline-dc-attribute.xsl teichmann@5499: ======================= teichmann@5499: Transforms datacage templates from: teichmann@5499: teichmann@5499: <foo> teichmann@5499: <dc:element name="bar" value="${baz}"/> teichmann@5499: <dc:element name="bla" value="${blub}-${urgs}"/> teichmann@5499: </foo> teichmann@5499: teichmann@5499: to: teichmann@5499: teichmann@5499: <foo bar="{$bar} bla="{$blub}-{$urgs}/> teichmann@5499: --> teichmann@5499: <xsl:stylesheet version="1.0" teichmann@5499: xmlns:xsl="http://www.w3.org/1999/XSL/Transform" teichmann@5499: xmlns:dc="http://www.intevation.org/2011/Datacage"> teichmann@5499: teichmann@5499: <xsl:output method="xml" encoding="UTF-8" indent="yes"/> teichmann@5499: teichmann@5499: <xsl:template name="string-replace-all"> teichmann@5499: <xsl:param name="text"/> teichmann@5499: <xsl:param name="replace"/> teichmann@5499: <xsl:param name="by"/> teichmann@5499: <xsl:choose> teichmann@5499: <xsl:when test="contains($text, $replace)"> teichmann@5499: <xsl:value-of select="substring-before($text,$replace)"/> teichmann@5499: <xsl:value-of select="$by"/> teichmann@5499: <xsl:call-template name="string-replace-all"> teichmann@5499: <xsl:with-param name="text" select="substring-after($text,$replace)"/> teichmann@5499: <xsl:with-param name="replace" select="$replace"/> teichmann@5499: <xsl:with-param name="by" select="$by"/> teichmann@5499: </xsl:call-template> teichmann@5499: </xsl:when> teichmann@5499: <xsl:otherwise> teichmann@5499: <xsl:value-of select="$text"/> teichmann@5499: </xsl:otherwise> teichmann@5499: </xsl:choose> teichmann@5499: </xsl:template> teichmann@5499: teichmann@5499: <xsl:template teichmann@5499: match="node()[count(dc:attribute) > 0 and namespace-uri() != 'http://www.intevation.org/2011/Datacage']"> teichmann@5499: <xsl:copy> teichmann@5499: <xsl:for-each select="./dc:attribute"> teichmann@5499: <xsl:attribute name="{@name}"> teichmann@5499: <xsl:call-template name="string-replace-all"> teichmann@5499: <xsl:with-param name="text" select="@value"/> teichmann@5499: <xsl:with-param name="replace">${</xsl:with-param> teichmann@5499: <xsl:with-param name="by">{$</xsl:with-param> teichmann@5499: </xsl:call-template> teichmann@5499: </xsl:attribute> teichmann@5499: </xsl:for-each> teichmann@5499: <xsl:apply-templates select="@*|node()" mode="ignore-text"/> teichmann@5499: </xsl:copy> teichmann@5499: </xsl:template> teichmann@5499: teichmann@5499: <xsl:template match="dc:attribute|text()" mode="ignore-text"/> teichmann@5499: <xsl:template match="@*|node()" mode="ignore-text"> teichmann@5499: <xsl:copy> teichmann@5499: <xsl:apply-templates select="@*|node()"/> teichmann@5499: </xsl:copy> teichmann@5499: </xsl:template> teichmann@5499: teichmann@5499: <xsl:template match="@*|node()"> teichmann@5499: <xsl:copy> teichmann@5499: <xsl:apply-templates select="@*|node()"/> teichmann@5499: </xsl:copy> teichmann@5499: </xsl:template> teichmann@5499: teichmann@5499: </xsl:stylesheet>