I want to dynamically choose the element to the variable $current_context.
If I hard-code in the element name it works just fine. The reference "content" in curly brackets is supposed to be a reference to the <record><content> element.
So I want the text in the <record><content> element to tell me which element from the $current_context variable to use.
Does that make sense? Sorry, but I'm new and my head is about to explode with all this Xpath stuff.
Can someone direct to the answer on how to dynamically reference an element?
What this allows me to do is dynamically reference an element. In this code we are within a for-each loop where "content" contains the name of a element in the lookup variable $current_context.
What I learned is when you use a predicate the context within the predicate is whatever is directly outside of it (to the left of your predicate). So the name() function is in reference to the elements within the $current_context variable and not the context of the template I am currently in.
I needed to use current() to tell the predicate that "content" will be in reference to the parent node which has context in the current template. Otherwise it will try to find "content" within the $current_context variable.
Thanks again to Michael Kay and a host of websites I visisted just like this one.