Re: [xsl] can I *undefine* an attribute via xsl:attribute?

Subject: Re: [xsl] can I *undefine* an attribute via xsl:attribute?
From: "John Lumley john.lumley@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 1 Aug 2020 16:46:20 -0000
The essence of the XSLT model is that there is no bdeleteb operation,
merely a bdecline to copyb so you have to copy attributes except the one
you wish to remove/undefine/delete.

John Lumley
john@xxxxxxxxxxxxxx

> On 1 Aug 2020, at 16:47, G. Ken Holman g.ken.holman@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> o;?One cannot "undefine" an added attribute, but when I know I might have to
do so, I put the attributes in a temporary home and then work from there.
>
> I hope this helps.
>
> . . . . . Ken
>
> ~/t $ cat j.xsl
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>  version="2.0">
>
> <xsl:template match="/">
>  <output>
>    <xsl:call-template name="create-my-attributes"/>
>  </output>
> </xsl:template>
>
> <xsl:template name="create-my-attributes">
>  <xsl:variable name="attrs" as="element()">
>    <element>
>      <xsl:call-template name="create-their-attributes"/>
>    </element>
>  </xsl:variable>
>  <xsl:copy-of select="$attrs/@* except $attrs/@unwanted-attribute"/>
> </xsl:template>
>
> <xsl:template name="create-their-attributes">
>  <xsl:attribute name="a" select="'a'"/>
>  <xsl:attribute name="unwanted-attribute" select="'z'"/>
>  <xsl:attribute name="b" select="'b'"/>
> </xsl:template>
>
> </xsl:stylesheet>~/t $ xslt2 j.xsl j.xsl
> <?xml version="1.0" encoding="UTF-8"?><output a="a" b="b"/>~/t $
>
> At 2020-08-01 15:04 +0000, Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx wrote:
>> Hi all,
>>
>> I would like to call a template that creates various attributes, then
conditionally *undefine* certain attributes, using some **MAGIC** below:
>>
>> <xsl:template name="create-my-attributes>
>>  <xsl:call-template name="create-their-attributes"/>
>>  <xsl:attribute name="unwanted-attribute" select=**MAGIC**/>
>> </xsl:template>
>>
>> A later xsl:attribute definition overrides an earlier value. But can I
somehow define an attribute as "undefined" to uncreate it? The spec at
>>
>>
<https://www.w3.org/TR/xslt-30/#creating-attributes>https://www.w3.org/TR/xsl
t-30/#creating-attributes
>>
>> doesn't mention this as an option, but I'm a novice and perhaps I missed
something.
>>
>> Thanks!
>>
>> -----
>> Chris Papademetrious
>> Tech Writer, Implementation Group
>> (610) 628-9718 home office
>> (570) 460-6078 cell
>>
>> <http://www.mulberrytech.com/xsl/xsl-list>XSL-List info and archive
>> <http://lists.mulberrytech.com/unsub/xsl-list/96802>EasyUnsubscribe (<>by
email)
>
>
> --
> Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ |
> Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
> Streaming hands-on XSLT/XPath 2 training class @ US$45 (5 hours free) |
> Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |

Current Thread