xsl-list
[Top] [All Lists]

[xsl] xsl:choose and multiple (sibling) elements

2006-04-13 06:28:53
hi,

first of all: i'm quite new to xsl so please forgive me any 'awkward' 
expressions in my question.
i'm using xml version 1.0 with apache fop 0.90.

this is my xml:
<inhaltsListe arraySize="8">
                                <element>
                                        <belegBereich>BKOP</belegBereich>
                                </element>
                                <element>
                                        <belegBereich>DETA</belegBereich>
                                </element>
                                <element>
                                        <textListe arraySize="1">
                                                <element>
                                                        <sprache>D</
sprache>
                                                        <inhalt>line1
line2
line3</inhalt>
                                                </element>
                                        </textListe>
                                        <belegBereich>FUSZ</belegBereich>
                                </element>
                                <element>
                                        <textListe arraySize="1">
                                                <element>
                                                        <sprache>D</
sprache>
                                                        <inhalt>OE: 1000   
      Depot: Standard</inhalt>
                                                </element>
                                        </textListe>
                                        <belegBereich>KOPF</belegBereich>
                                </element>

[...]
                                <element>
                                        <textListe arraySize="1">
                                                <element>
                                                        <sprache>D</
sprache>
                                                        <inhalt>BBEZ ist 
vorhanden</inhalt>
                                                </element>
                                        </textListe>
                                        <belegBereich>BBEZ</belegBereich>
                                </element>
                        </inhaltsListe>

the parent tag <inhaltsListe> has 8 <element> children, as you can see 
(irrelevant cropped).

i need to get the value (here--> 'BBEZ ist vorhanden') of the <inhalt> tag 
of the last <element>, where <belegBereich> has the value BBEZ. otherwise 
(if such an <belegBereich> doesn't exist) , the text should be retrieved 
elsewhere in the xml.

here is the relevant part of my xsl:

<!-- Belegbezeichnung             -->
 
                        <fo:block font-weight="bold">
 
                <!-- here comes the part that's troubling me  --> 
 
                        <xsl:choose>
                                <xsl:when test="//belegBereich = 'BBEZ'">
                                        <!--xsl:value-of 
select="./textListe/element/inhalt"/-->
                                        <xsl:value-of select="
../textListe/inhalt"></xsl:value-of>
                                </xsl:when>

                <!-- here comes the part to look für 'Belegbezeichnung' 
elsewhere in the xsl, if it wasn't found by xsl:when --> 

                                <xsl:otherwise>
                                        <xsl:value-of select="
/dakl/at.sds.xc.positionsreports.DaklOutput/depot/bezeichnung">
                                        </xsl:value-of>
                                </xsl:otherwise>
                        </xsl:choose>

 
                        </fo:block>

the xsl:when seems to work, since in my resulting file (XSL-FO 
respectively PDF after converting with apache FOP) the relevant line is 
blank and not filled by the xsl:otherwise. unfortunately the xsl:value-of 
doesn't work, i hoped that the ../inhalt would lead the processor to <
inhalt>BBEZ ist vorhanden</inhalt>, since <textListe> is also a child of <
element> as <belegBereich> is. didn't work.

how do i need to write the xpath-adressing in the xsl:value-of select in 
order to get my desired value?

i tried many different approaches, including to wrap a xsl:for-each (with 
an absolute path until <element>) around the xsl:choose, which ended up in 
printing the desired text 8 times next to each other (= number of 
<element> tags)... but at least 


thx a lot in advance
alex


______________________________________________________________________
Der Austausch von Nachrichten mit Software Daten Service via E-Mail dient 
ausschliesslich Informationszwecken. Rechtsgeschaeftliche Erklaerungen duerfen 
ueber dieses Medium nicht ausgetauscht werden.

Correspondence with Software Daten Service via e-mail is only for information 
purposes. This medium is not to be used for the exchange of legally-binding 
communications. 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>