简体   繁体   中英

How to assign XSL test result to variable

Here is our XML:

...

    <OBJECT_CONTACT_PLZ>2222</OBJECT_CONTACT_PLZ>
    <Kategorien>
        <Kategorie>
            <Bezeichnung>AAA</Bezeichnung>
            <Ebene>1</Ebene>
            <KategorieID>13</KategorieID>
        </Kategorie>
        <Kategorie>
            <Bezeichnung>BBB</Bezeichnung>
            <Ebene>2</Ebene>
            <KategorieID>35</KategorieID>
            <Parent>13</Parent>
        </Kategorie>
        <Kategorie>
            <Bezeichnung>XXX</Bezeichnung>
            <Ebene>3</Ebene>
            <KategorieID>55</KategorieID>
            <Parent>35</Parent>
        </Kategorie>
    </Kategorien>

...

And here our XSL:

<xsl:if test="(td2:Kategorien/Kategorie[contains(Bezeichnung, 'XXX')] or td2:Kategorien/Kategorie[contains(Bezeichnung, 'YYY')] or td2:Kategorien/Kategorie[contains(Bezeichnung, 'ZZZ')]) and ((td2:OBJECT_CONTACT_PLZ='0000') or (td2:OBJECT_CONTACT_PLZ='1111') or (td2:OBJECT_CONTACT_PLZ='2222') or (td2:OBJECT_CONTACT_PLZ='3333'))">

<xsl:variable name="plz">
    <xsl:value-of select="td2:CONTACT_PLZ"></xsl:value-of> </xsl:variable>

<xsl:variable name="betriebsart">
    <xsl:value-of select="td2:Kategorien/Kategorie/Bezeichnung"></xsl:value-of> </xsl:variable>

At the moment, the variable 'betriebsart' is always filled with the first 'Kategorie', in this case 'AAA'.

How do we fill the variable 'betriebsart' with the 'Kategorie' that has been matched in the 'if' clause, in this case 'XXX'?

Many thanks in advance for any help!

尝试:

<xsl:value-of select="td2:Kategorien/Kategorie[contains(Bezeichnung, 'XXX') or contains(Bezeichnung, 'YYY') or contains(Bezeichnung, 'ZZZ')]/Bezeichnung"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM