|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Transform selected attribute to element when eleme
On 22.05.2021 20:51, Sam Spade anonymousjuly1@xxxxxxxx wrote:
As you can see,B the unwanted attribute *currencyScheme* still persists. Is there a way to remove the attribute which is not in the $keepAttr list? Perhaps in this case it is better to filter when applying templates: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all"> <xsl:param name="namespace" as="xs:string">http://fc.fasset/product</xsl:param> <xsl:param name="root" as="xs:string">requestProduct</xsl:param> <xsl:param name="keepAttr" static="yes" as="xs:string*" select="'href', 'id'"/> <xsl:strip-space elements="*"/> <xsl:output indent="yes"/> <xsl:template match="/*">
<xsl:element name="{$root}" namespace="{$namespace}">
<xsl:apply-templates select="@*[local-name() = $keepAttr],
node()"/>
</xsl:element>
</xsl:template> <xsl:template match="*">
<xsl:element name="{local-name()}" namespace="{$namespace}">
<xsl:apply-templates select="@*[local-name() = $keepAttr],
node()"/>
</xsl:element>
</xsl:template> <xsl:template match="*[@* and text()[normalize-space()]]">
<xsl:element name="{local-name()}" namespace="{$namespace}">
<xsl:apply-templates/>
</xsl:element>
<xsl:apply-templates select="@*[local-name() = $keepAttr]"/>
</xsl:template> <xsl:template match="@*">
<xsl:element name="{local-name()}" namespace="{$namespace}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template></xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








