I have an xml document following this overall pattern:
<A b="c" d="e" f="g" h="i">
<!-- plenty of children -->
</A>
I would like to copy the A
node with only some of it's attributes:
<A b="c" f="g">
<!-- some of the children -->
</A>
Other answers here have come close to solving my challenge but have not quite been enough:
- This answer gave me a solution that would work but would be very long: https://stackoverflow.com/a/672962/145978
- so I could go with
<xsl:copy-of select="@*[(name()!='d') or (name()!='h']"/>
but my actual attribute list is very long. - I did try finding a 'is-a-member-of-this-list'-type function but got lost rather quickly.
- so I could go with
- This answer seemed to discuss a Whitelist but I am apparently not smart enough to be able to apply it to attribute selection: https://stackoverflow.com/a/5790798/145978
Please help