[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: copy attributes, except some
Hi Wendell,
True. The thing that still bothers me with this is that since nodes and content are compared, a variable like $excepted-attributes has to be defined for every attribute group, for every tree/subtree that may get copied which is getting to be quite an overhead here. The situation is more or less the same for the attribute() approach. Comparing attribute names is really what I require but is trickier in a namespace safe way. Consequently, by first declaring a variable with a "dummy" set of attributes to exclude, like <xsl:variable name="dummy-attributes"><xx name1="" name2="" name3="" name4=""/></xsl:variable> I can now declare: <xsl:variable name="excepted-attributes" select="$dummy-attributes//@*/node-name(.)"/> and later use: <xsl:copy-of select="@*[not(node-name(.) = $excepted-attributes)]"/> on as many trees as I need, bringing the variable overhead down to two per excepted attribute set, independently of the number of tree/subtree that need copying, which is a lot in this case. Also note that the example here copies attributes from the context node which implies, especially with many trees/subtrees and many excluded attributes that you would want to use a lot of <xsl:for-each select="$this-tree-or-subtree"> elements to set those context nodes. With an attribute name-based approach one can also spare most of these context setting instructions, just simply using the tree variable reference once, per tree. Again, it seems, quite a saving in a setting with many trees/subtrees. The solution still does not seem perfectly elegant, especially as it is a little twisted, but it seems like the best possible, and it works. Mind you, in a context where elements can have dynamic attribute sets from a wide potential range, from multiple namespaces, which I think should be casual with XML, it may be interesting to consider how this could be made more elegant. It works for now and I thank you, and everyone who contributed, for the insight. Cheers, ac ac,
|
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
|