M
Marrow
Hi Markus,
Try something like...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:changes="urn:my-changes">
<!-- just used to store the node-set -->
<changes:nodeset>
<item name="change" attr="text" value="new_value"/>
<item name="change2" attr="label" value="new_value2"/>
</changes:nodeset>
<!-- store changes in a global variable -->
<xsl:variable name="changes" select="document('')/*/changes:nodeset/*"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<!-- get the change node - if present -->
<xsl:variable name="this-change" select="$changes[@name =
current()/parent::*/@name and @attr = name(current())]"/>
<!-- see if this attribute needs changing -->
<xsl:choose>
<xsl:when test="$this-change">
<xsl:attribute name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="$this-change/@value"/>
</xsl:attribute>
</xsl:when>
<xsltherwise>
<xsl:copy/>
</xsltherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
Try something like...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:changes="urn:my-changes">
<!-- just used to store the node-set -->
<changes:nodeset>
<item name="change" attr="text" value="new_value"/>
<item name="change2" attr="label" value="new_value2"/>
</changes:nodeset>
<!-- store changes in a global variable -->
<xsl:variable name="changes" select="document('')/*/changes:nodeset/*"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<!-- get the change node - if present -->
<xsl:variable name="this-change" select="$changes[@name =
current()/parent::*/@name and @attr = name(current())]"/>
<!-- see if this attribute needs changing -->
<xsl:choose>
<xsl:when test="$this-change">
<xsl:attribute name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="$this-change/@value"/>
</xsl:attribute>
</xsl:when>
<xsltherwise>
<xsl:copy/>
</xsltherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator