[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Copy all attributes except except some
Subject: Re: [xsl] Copy all attributes except except some From: "Abel Braaksma (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 10 Jun 2014 23:49:31 -0000 |
On 11-6-2014 1:05, Philipp Kursawe phil.kursawe@xxxxxxxxx wrote: > I am using: > <xsl:copy-of select="@*[local-name() != 'signed']"/> Because of the way != works, this will usually give you all attributes regardless. > I assume I have to make a long list of "or local-name() != 'otherAtt'" > to exclude all my attributes that should not be copied over. Or is > there a smarter way to just define a list of attributes that are not > copied? There are many ways. "Long list" sounds to me that you want to configure it somewhere explicitly, or look for a pattern in the local-name. Also, in most XML I have seen, attributes are in no-namespace, but I haven't seen your input so I'm not sure. I would use the except keyword, which works just the way you expect it to work: <xsl:copy-of select="@* except (@signed, @unsigned)"/> Or if you cannot use nametests, you can continue to using local-name(), but you should reverse the test and use '=' on a sequence, instead of '!=', like this: <xsl:copy-of select="@*[not(local-name() = ('signed', 'unsigned'))]"/> Though, if you do have attributes in namespaces and if you do know the names you want to exclude, I can advice you to use nametests instead. Consider your input looks like: <foo x:signed="true" y:signed="false" z:signed="always" /> And you the prefixes x, y, z are each bound to different namespaces, you will remove too many attributes if you use local-name(). Instead, write it as follows: <xsl:copy-of select="@* except (@z:signed, @y:signed)"/> which will leave x:signed in place and remove the rest. There are many more ways in XSLT to tackle this issue. To help you better for your situation, it would help us help you if you show us a (small, but complete) sample of your input data. Cheers, Abel Braaksma Exselt XSLT 3.0 streaming processor http://exselt.net
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Copy all attributes excep, Graydon graydon@xxxx | Thread | Re: [xsl] Copy all attributes excep, Abel Braaksma (Exsel |
Re: [xsl] Copy all attributes excep, Graydon graydon@xxxx | Date | Re: [xsl] Copy all attributes excep, Abel Braaksma (Exsel |
Month |