Here is the root of my XML (There is more to it but here is the basis):
<?xml version="1.0" encoding="UTF-8"?><section xmlns="http://quark.com/smartcontent/2.0" id="_63f6a0c9-bac8-4a15-854c-03d80bd46b64" type="clientFactsheet">
Here is my XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:deltaxml="http://www.deltaxml.com/ns/well-formed-delta-v1" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="section[@id]">
<xsl:copy>
<xsl:attribute name="deltaxml:key" select="@id"/>
<xsl:apply-templates select="@*, node()"/>
</xsl:copy>
</xsl:template>
Here is the output XML root:
<?xml version="1.0" encoding="UTF-8"?><section xmlns="http://quark.com/smartcontent/2.0" id="_63f6a0c9-bac8-4a15-854c-03d80bd46b64" type="clientFactsheet">
Here is what I get if I take off the default namespace from the input XML (which is desired result, except that I need to keep the default namespace):
<?xml version="1.0" encoding="UTF-8"?><section xmlns:deltaxml="http://www.deltaxml.com/ns/well-formed-delta-v1" deltaxml:key="_63f6a0c9-bac8-4a15-854c-03d80bd46b64" id="_63f6a0c9-bac8-4a15-854c-03d80bd46b64" type="clientFactsheet">
Basically, I need to be able to add the "deltaxml:key" attributes with the "id" value of the section so for this I need to add the namespace "deltaxml" but I also need to keep the default namespace (which can change from document to document which I won't have control over... so I can't just copy it over). How can I accomplish this?