I have an input xml document out of which most of the tags are to be copied over to the output xml as such. At some places(Xpaths), there is a need to make some modifications / add additional entries. This is done using a recursive loop until the matching template is found for the Xpath. I am not sure if this is an effective way of doing this. Do you have any better suggestions/solution? How are these things generally handled? Any pointers/link would really help. I have pasted a gist of the xsl below,
You took an identity transformation and added a new template to make specific changes, right? That's a perfectly reasonable way to do things.
posted 13 years ago
Yes, I applied the modifications on the new template. But my concern was on the recursive looping. The recursive loop runs through to find a matching template and if it finds one it applies the template, else it just copies over(starting from the leaf node). I was thinking of a better way for running the recursive loop. Say, if the program realizes the parent node it is trying to match doesn't match with any of the templates then it should just copy it over and should not even recurse further. If it finds one, then it should go to the child node and find for the next match. This might significantly reduce time. But I was looking for a better way of accomplishing this. For eg.,
If I have to modify <d> node, then the loop should not even go inside <a>. It should just copy <a>. It should go inside a node only if it realizes a node under it needs to be modified.