Project

Profile

Help

Support #4960 » xslt3-beta-transform-ns&root.xsl

XSLT3 Identity transform - Anonymous, 2021-04-02 06:45

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0">

<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*" />

<xsl:mode on-no-match="shallow-copy"/>

<xsl:variable name="product-ns" select="'http://fc.fasset/product'"/>
<xsl:variable name="keep-attr" select="'href','id'"/>
<xsl:template match="*">
<!-- <requestProduct xmlns="http://fc.fasset/product"> -->
<xsl:element name="{name()}" namespace="{$product-ns}">
<!-- conditional process node attributes -->
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="local-name() = $keep-attr">
<!-- maintain attr prefix -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
<!-- remove ns prefix: <xsl:otherwise> seems redundant ?-->
</xsl:choose>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="comment()"/>

</xsl:stylesheet>
(1-1/3)