XSLT Intersection

I am not sure how to solve this problem, as I am pretty new to XSLT.

I use xsl:for-eachto loop through Types, which is good, but when I am in this loop (Type), how would I select Rateusing the attribute in TypeCode? Am I right in thinking that the choice only has the area for everyone that I am in at the time? There may also be many bag elements.

<Bags>
<Bag>
    <Types>
        <Type TypeCode="DBL">
            <Description Name="BLAH">
                <Text>BLAH</Text>
                <Image/>
            </Description>
        </Type>
        <Type TypeCode="JRS">
            <Description Name="BLAH">
                <Text>BLAH BLAH</Text>
                <Image/>
            </Description>
        </Type>
    </Types>
    <Plans>
        <Plan PlanCode="DISC" PlanName="Best rate">
            <Description Name="Best rate">
                <Text>Best available rate</Text>
            </Description>
        </Plan>
        <Plan PlanCode="NOCC" PlanName="No CC Required">
            <Description Name="No CC Required">
                <Text>Rate- No CC Required</Text>
            </Description>
        </Plan>
    </Plans>
    <Rates>
        <Rate TypeCode="DBL" PlanCode="DISC">
            <Rates>
                <Rate>
                    <Base AmountBeforeTax="0" CurrencyCode="EUR"/>
                </Rate>
            </Rates>
        </Rate>
        <Rate TypeCode="JRS" PlanCode="DISC">
            <Rates>
                <Rate>
                    <Base AmountBeforeTax="0" CurrencyCode="EUR"/>
                </Rate>
            </Rates>
        </Rate>
    </Rates>
</Bag>
    </Bags>
+3
source share
1 answer

I understand correctly that in the selection element there is only an area for everyone, what am I at this time?

Not really , an XPath expression can be relative, in which case it is evaluated from the current node or absolute (starting from /), in which case it is evaluated from the current node document.

XPath , node, following:: following-sibling::.

ancestor::Bag/Rates/Rate[@TypeCode = current()/@TypeCode]

, , :

ancestor::Bag[1]/Rates/Rate[@TypeCode = current()/@TypeCode]
+1

All Articles