xsl-list
[Top] [All Lists]

Re: Re: [xsl] lookup table problem

2006-04-24 04:07:58
hi ken,

first of all thx for your answer.

  <seife>
     <at.sds.xc.reportService.ReportDaten>
        [...]
     <at.sds.xc.positionsreports.DaklOutput>
       <belegnummerList arraySize="1">
        [...]
       </belegnummerList>
       <depot>
        [...]
       </depot>
       <depotDaten>
        [...]
       </depotDaten>
       <verrechnungskonto>
        [...]
       </verrechnungskonto>
    <einzelPositionList arraySize="5">
     <element>
       <positionsDaten>
         <positSaldoGilt>19998</positSaldoGilt>
         <positVerwahrart>WR</positVerwahrart>
         <positLoco>DE</positLoco>
       [...]

here is a part of the lookup table SVZ_1001.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<getTables>
 <at.sds.xc.coreService.CodeTableList arraySize="1">
   <element>
    <codeTableNo>1001</codeTableNo>
    <codeTableType>ALLG</codeTableType>
    <codeTableName>code-table-name</codeTableName>
    <codes arraySize="97">
       <element>
         <code>0000</code>
        <hcode/>
        <sysstatus>0</sysstatus>
        <codeText>Wien</codeText>
      </element>
       <element>
        [...]

I need the  <codeText> (lookup) where   <positLoco> (source) equals 
<code>
(lookup). so, the output should look like
Loco: Wien
(and not '0000').

here is a part of my (wellformed) xsl (template will be called within
fo:root):



<?xml version="1.0" encoding="ISO-8859-1"?>



<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"; xmlns:fo="
http://www.w3.org/1999/XSL/Format";>
        <xsl:output method="xml" omit-xml-declaration="yes"/>


 
        <xsl:decimal-format 
separator="," 
separator="." 
separator=";"
sign="-"
="nummer">
        </xsl:decimal-format>
 
        <xsl:variable name="leer"/>


        <xsl:template match="/">
                <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
                        <fo:layout-master-set>
 


                                <fo:simple-page-master master-name="
blattA4" 
                        height="297mm" 
                        width="210mm" 
                        left="1cm" 
                        right="1cm" 
                        top="1cm" 
                        bottom="1cm">
                                        <fo:region-body margin-top="4cm" 
margin-bottom="3.5cm">
                                                <!-- margin-left="1.5cm" 
margin-right="2.5cm" !-->
                                        </fo:region-body>
                                        <fo:region-before extent="4cm"/>
                                        <fo:region-after extent="2cm"/>
                                        <!--fo:region-start 
extent="0.5cm"></fo:region-start!-->
                                        <!--fo:region-end 
extent="1.5cm"></fo:region-end!-->
                                </fo:simple-page-master>
                        </fo:layout-master-set>
                        <fo:page-sequence master-reference="blattA4">
 


                        <fo:static-content flow-name="xsl-region-before">



                <fo:block>
                        <xsl:call-template name="Kundenheader"/>
                </fo:block>

                        <fo:list-block>
                                <fo:list-item>
                                        <fo:list-item-label 
                                indent="8.5cm">
                                                <fo:block>
                                                <fo:external-graphic src="
geos.jpg"/></fo:block>
                                        </fo:list-item-label>
                                        <fo:list-item-body max-width="
12.2cm"
                                indent="11.8cm">
                                                <fo:blockalign="start">
                                                <xsl:call-template name="
Belegkopf"/></fo:block>
                                        </fo:list-item-body>
                                </fo:list-item>
                        </fo:list-block>

                        </fo:static-content>
 

 
                                <fo:static-content flow-name="
xsl-region-after">
                                        <fo:block font-size="8pt"><
xsl:call-template name="Footer"></xsl:call-template>
                                        </fo:block>
                                </fo:static-content>
 

                                <fo:flow flow-name="xsl-region-body">

 
                                        <fo:block>
                                                <xsl:call-template name="
Adresse"></xsl:call-template>
                                        </fo:block>
 
                                        <fo:block font="Helvetica"
                                size="10pt"
                                option="wrap">
                                                <xsl:call-template name="
Mandtext"></xsl:call-template>
                                        </fo:block>
 
                                        <fo:block text-align="center"
                                ="Helvetica"
                                size="10pt"
                                option="wrap">
                                                <xsl:call-template name="
AllgDaten"></xsl:call-template>
                                        </fo:block>
 
 
 
 
                                        <fo:block padding-before="1cm" 
font="Helvetica">
                                                <xsl:call-template name="
Posit"></xsl:call-template>
                                        </fo:block>
 
[...]
                                </fo:flow>
                        </fo:page-sequence>
                </fo:root>
        </xsl:template>

<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::-->  
<!-- Generierung der Inhalte--> 
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::--> 
 
 
<!-- Generierung Kundenheader--> 
 
        <xsl:template name="Kundenheader">
                <fo:block white-space-treatment="preserve" 
        treatment="preserve"
        size="8pt"
        align="left">
                        <xsl:for-each select="
//at.sds.xc.reportService.ReportDaten/belegBereiche/inhaltsListe/element">
                        <xsl:choose>
                                <xsl:when test="./belegBereich = 'KOPF'">
                                        <xsl:value-of select="
./textListe/element/inhalt"/>
                                </xsl:when>
                        </xsl:choose>
                        </xsl:for-each> 
                </fo:block>
        </xsl:template>
 
 
<!-- Generierung Belegkopf             -->
 
        <xsl:template name="Belegkopf">
                <fo:block 
        ="Helvetica"
        size="10pt"
        color="#9ECCFA"
        option="no-wrap"
        before="0.3cm">
 
                <!-- Belegbezeichnung             -->

 
                        <fo:block font-weight="bold">
 
                <xsl:variable name="belegBereich" select="
//inhaltsListe//belegBereich[. ='BBEZ']"></xsl:variable>
                <xsl:choose> 
                        <xsl:when test="$belegBereich">
                                <xsl:value-of select="
$belegBereich/../textListe/element/inhalt"/>
                        </xsl:when>

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

 
        <!-- Auszug-Nr., laufende Nummer, laufendes Jahr, Duplikat? 
fixTexte könnten auch wie bei Duplikat direkt codiert werden, dann wäre 
choose nicht notwendig         -->
 
                        <fo:block>
                        <xsl:for-each select="
//at.sds.xc.reportService.ReportDaten/fixTexte/element">
                        <xsl:choose>
                                <xsl:when test="./fixfmNr = '19'">
                                        <xsl:value-of select="
./textInhalte/element/fixText"/><xsl:text> </xsl:text>
                                        <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/belegnummerList/element/laufendeNummer
"/> / 
                                        <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/belegnummerList/element/laufendesJahr
"/><xsl:text> </xsl:text>
                                        <xsl:if test="//adressen//original 
='false' or //depot/nachdruck = 'true'"> D U P L I K A T        </xsl:if>
                                </xsl:when>
                        </xsl:choose>
                        </xsl:for-each> 
                </fo:block>
 
 
 
                <!-- Depotnummer             -->
 
                        <fo:block>Depot-Nr.:
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/nummer">
                                </xsl:value-of>
                        </fo:block>
 
                <!-- Depotbezeichnung 1            -->
 
                        <fo:block>
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/bezeichnung1"></xsl:value-of

                        </fo:block>
 
                <!-- Depotbezeichnung 2            -->
 
                        <fo:block>
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/bezeichnung2"></xsl:value-of

                        </fo:block>
 
                <!-- OE / Stelle / Kurzbezeichnung   -->
 
                        <fo:block>Betreuer:
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/orgehCode"></xsl:value-of><
xsl:text> </xsl:text>
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/orgehKurzbezeichn"></
xsl:value-of> / 
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depot/betreuendeStelle"></
xsl:value-of>
                        </fo:block>
 
 
                </fo:block>
 
        </xsl:template>
 
 
<!-- Generierung Adresse             -->
 
        <xsl:template name="Adresse">
                <fo:block 
        space-treatment="preserve" 
        treatment="preserve" 
        ="Helvetica"
        size="10pt"
        indent="12cm">
                        <xsl:value-of select="
//at.sds.xc.reportService.ReportDaten/adressen/element/adresse"/>
                </fo:block>
        </xsl:template>


<!-- Generierung Mandantentext             --> 
 
        <xsl:template name="Mandtext">
        <fo:block white-space-treatment="preserve" 
        treatment="preserve"
        align="left"
        before="2cm">
                        <xsl:for-each select="
//at.sds.xc.reportService.ReportDaten/belegBereiche/inhaltsListe/element">
                        <xsl:choose>
                                <xsl:when test="./belegBereich = 'MANF'">
                                        <xsl:value-of select="
./textListe/element/inhalt"/>
                                </xsl:when>
                        </xsl:choose>
                        </xsl:for-each> 
                </fo:block>
        </xsl:template>

<!-- Generierung Allgemeine Daten (Aufstellungsüberschrift)             
-->

        <!-- Aufstellung per 99.99.999 99:99 Uhr - Ausgabe Uhrzeit nur 
wenn stichtabVon=stichtagBis            -->
<xsl:template name="AllgDaten">
                <fo:block 
        before="1cm"
        weight="bold">AUFSTELLUNG per
                        <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/stichtagVon"/>
                        <xsl:if test="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/stichtagVon = 
//at.sds.xc.positionsreports.DaklOutput/depotDaten/stichtagBis">
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/tageszeit"/>
                                        <xsl:text> Uhr</xsl:text>
                        </xsl:if>
                        </fo:block>

        <!-- Depottyp        Andruck nur bei Schattendepot     --> 
 
                <fo:block font-weight="bold">
                        <xsl:if test="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/depotTyp = 'SCHA'">
Schattendepot</xsl:if>
                </fo:block>
 
 
        <!-- KESTfrei?             Andruck nur bei 'true'  --> 
 
                <fo:block>
                        <xsl:if test="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/kestFrei = 'true'">
Dieses Depot ist KEST-frei.</xsl:if>
                        </fo:block> 
 
 
        <!-- Sperre vorhanden?    Andruck nur bei 'true'         --> 
 
                <fo:block>
                        <xsl:if test="
//at.sds.xc.positionsreports.DaklOutput/depotDaten/sperre = 'true'">Dieses 
Depot ist mit einer Sperre belegt.</xsl:if>
                        </fo:block>
 
 
        <!-- Standardverrechnungskonto, WHG, BLZ  --> 
 
                <fo:block>
                : <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/verrechnungskonto/kontonummer"/>
                        <xsl:text> </xsl:text>
                        <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/verrechnungskonto/waehrung"/>
                        <xsl:text> </xsl:text>
                        <xsl:if test="/dakl//bankleitzahl != ''"> 
                .: <xsl:value-of select="
//at.sds.xc.positionsreports.DaklOutput/verrechnungskonto/bankleitzahl"/>
                        </xsl:if>
                </fo:block> 
 
        </xsl:template>

<xsl:template name="Posit">
        <xsl:choose>
                <xsl:when test="//einzelPositionList">

Is it true that your instance always has such a list?  You don't 
indicate what your current node is at the time of doing this 
test.  And you are probably inappropriately using "//" here, but I 
cannot tell for sure.


first of all i already read some articles about using "//" (i think some 
of them were from you in the list), so i tried using the xsl without, but 
then the template produced no output at all (maybe another mistake in my 
code???).

i'm not quite sure what you mean with "Is it true that your instance 
always has such a list?". since all information for this part of my xml 
are child-nodes of <einzelPositionList arraySize="5"> i think the answer 
is YES.

sorry, but since i'm a newbie with xsl i can't tell what the current node 
is - i expect "einzelPositionList/element" to be the current node, since 
"./positionsDaten/..." delivers the date i expect.
i tried not to send every line of code of my xsl to the list, since it 
already is over 500 lines long. i pasted more code right before 
<xsl:template name="Posit"> - the variable 'leer' is also defined at the 
beginning (actually an empty variable to test against elements without any 
value).




                        <fo:table table-omit-header-at-break="false"
table-layout="fixed" border-collapse="separate" font-size="8pt" width="
100%">
                        <fo:table-column column-width="35mm"/>
                        <fo:table-column column-width="10mm"/>
                        <fo:table-column column-width="90mm"/>
                        <fo:table-column column-width="30mm"/>
                        <fo:table-column column-width="25mm"/>

                        <fo:table-header>
                                [...]
                        </fo:table-header>
                        <fo:table-body>
                                <xsl:for-each select="
//einzelPositionList/element">
                                        <fo:table-row>
                                        <xsl:choose>
                                                <xsl:when test="
(position() mod 2) = 0">#ffffff</xsl:when>
<xsl:otherwise>#9ECCFA</
xsl:otherwise>
                                        </xsl:choose>
                                        </xsl:attribute>
                                        <fo:table-cell>
                                                [...]
                                        </fo:table-cell>
                                        <fo:table-cell>
                                                [...]
                                        </fo:table-cell>
                                        <fo:table-cell>
<fo:block>
        <xsl:variable name="loco-svz" select="
document('SVZ_1001.xml')//codes/element = //positDaten/positLoco"/>

Your use of "//" is both wasteful (execution wise) and inappropriate 
in the above comparison, as the result is not a node set, it is a 
boolean (which is what you are reading in your error message).

You probably need a predicate something like:

document('SVZ_1001.xml')//codes
              [element = current()/element/positDaten/positLoco]"

But, unfortunately, you don't give enough of your code, and your 
constant jumping back to the root using "//" is probably losing your 
context for the purposes of efficient testing and navigation.


as already written above, if i don't use "//" the template doesn't return 
any data in the output-document. i tried your suggestion regarding the 
predicate, unfortunately no output is generated by this statement:
                                                        <fo:table-cell 
padding-after="5mm">
                                                                <fo:block 
padding-before="3mm+10pt"> </fo:block>
                                                                <fo:block 
font-weight="bold">Austrian Airlines Österr. Luftverke</fo:block>
                                                                <fo:block>
hrs AG Stammaktie</fo:block>
                                                                <fo:block>
Kup. 2 </fo:block>
                                                                <fo:block>
Loco: </fo:block>
                                                                <fo:block
/>
                                                                <fo:block
/>
                                                                <fo:block
/>
                                                                <fo:block
/>
                                                        </fo:table-cell>



        <xsl:if test="normalize-space(./positionsDaten/positLoco) != 
$leer
">

You don't show the setting of the variable $leer, so I'm not sure how 
this helps.

it's an empty variable - see above.


fop - message:
Exception
org.apache.xpath.XPathException: #BOOLEAN kann nicht in NodeList
konvertiert werden!
(means: boolean can not be coverted into nodelist)

Right ... because you were initializing your variable to the result 
of a comparison operator ... not a selection of a qualified node list.

how do i need to write my xsl to get things working as i expect?

Probably quite a few changes are needed.

I tell my students "if you think you need "//" then think again ... 
you probably don't ... which isn't to say it is evil, just that it 
has its role and it is too often abused".

I hope this helps.

. . . . . . . . . Ken

again, when writing my xsl, i never ignored this issue with jumping back 
to the root node. at first, i addressed every node with an absolute path 
(from the root-node to node i need to be processed), then i substituted 
the abolute path with "//" to make the code more readable. any try to drop 
"//" resulted in no output. 
i hope the additional code i pasted above helps you helping me ;o]

cheers
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>