0
votes

Actually I don't have really a question, I just want a conformation for my assumption. I guess it is not possible to get the node from the start of the select ./attribute inside the nested conditions at the place where I have written here you need the current attribute from the start of select, because I am already in the context of the variable $oldBaseline. Or is there any way? Of course I can store this node inside a variable but this is always possible...

    <xsl:variable name="changedMonitorSettings" 
        select="./attribute[($oldBaseline/module/object/object[attribute[@name='Object Text']=$currentObject/attribute[@name='Object Text']]
            /attribute[@name = "here you need the current attribute from the start of select"/@name]) !=.]"/>

I need to add some more details:
The object node looks like this. There are a lot of attribute nodes. I want to compare every attribute from one xml with the same named attribute of another xml.

        <object>
            <attribute name="CM_ABS">CM_NORMAL</attribute>
            <attribute name="CM_AVH">CM_AVH_INHIBIT</attribute>
            <attribute name="CM_BCM">CM_BCM_NORMAL</attribute>
            <attribute name="CM_BHM">CM_BHM_NORMAL</attribute>
            <attribute name="CM_BRAKE_AC">CM_BRAKE_AC_NORMAL</attribute>
            <attribute name="CM_CC">CM_CC_NORMAL</attribute>
            <attribute name="CM_EDTR">CM_EDTR_NORMAL</attribute>
            <attribute name="CM_EYT">CM_EYT_NORMAL</attribute>

Therfore I need during the xslt processing for every attribute, at the mentioned place inside the predicate, the attribute which is currently under investigation during this processing step. Because I need to check if the attribute from the oldBaseline has the same name like the attribute which is currently used in the processing step. I think the current() function will not work, because it just returns the object node, thus current()/attribute just returns the first attribute of the object node.
Thus I need to correct me, that I am already in the context of $oldBaseline is acutally not the point, I have faced this issue some months ago...

So the question is now:
It is possible to get the attribute node which is currently under investigation in the current processing step?

1

1 Answers

0
votes

XPath 3 has a let expression to bind variables (e.g. ./attribute[let $a := . return ($oldBaseline/module/object/object[attribute[@name='Object Text']=$currentObject/attribute[@name='Object Text']]/attribute[@name = $a/@name]) !=.] if I manage to handle that long expression, I have not tested whether there are parenthesis needed to structure it as intended).

In XPath 2 it might be possible to exploit the for .. return instead of let e.g. ./attribute[for $a in . return ($oldBaseline/module/object/object[attribute[@name='Object Text']=$currentObject/attribute[@name='Object Text']]/attribute[@name = $a/@name]) !=.].

A cross-reference/comparison based on an attribute or element value might also suggest that a key declared with xsl:key and the use of the key function could help simplify the expression and improve the lookup performance.