|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Transform selected attribute to element when eleme
p b$o8
Excellent Collaboration!!!B
On Saturday, May 22, 2021, 12:03:32 p.m. MST, Martin Honnen
martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
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"
B version="3.0"
B xmlns:xs="http://www.w3.org/2001/XMLSchema"
B exclude-result-prefixes="#all">
B <xsl:param name="namespace"
as="xs:string">http://fc.fasset/product</xsl:param>
B <xsl:param name="root" as="xs:string">requestProduct</xsl:param>
B <xsl:param name="keepAttr" static="yes" as="xs:string*"
select="'href', 'id'"/>
B <xsl:strip-space elements="*"/>
B <xsl:output indent="yes"/>
B <xsl:template match="/*">
B B B <xsl:element name="{$root}" namespace="{$namespace}">
B B B B B <xsl:apply-templates select="@*[local-name() = $keepAttr],
node()"/>
B B B </xsl:element>
B </xsl:template>
B <xsl:template match="*">
B B B <xsl:element name="{local-name()}" namespace="{$namespace}">
B B B B B <xsl:apply-templates select="@*[local-name() = $keepAttr],
node()"/>
B B B </xsl:element>
B </xsl:template>
B <xsl:template match="*[@* and text()[normalize-space()]]">
B B B <xsl:element name="{local-name()}" namespace="{$namespace}">
B B B B B <xsl:apply-templates/>
B B B </xsl:element>
B B B <xsl:apply-templates select="@*[local-name() = $keepAttr]"/>
B </xsl:template>
B <xsl:template match="@*">
B B B <xsl:element name="{local-name()}" namespace="{$namespace}">
B B B B <xsl:value-of select="."/>
B B B </xsl:element>
B </xsl:template>
</xsl:stylesheet>
As the built-in templates copy attribute values through I think you
would otherwise need to prevent that with `<xsl:template
match="@*[not(local-name() = $keepAttr)]"/>`.
|
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








