[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

lookup table problem

Subject: lookup table problem
From: Alexander.RACHER@xxxxxxxx
Date: Fri, 21 Apr 2006 14:31:45 +0200
state lookup table
hi,

i'm using xml version 1.0 with apache fop 0.90.

i read many description how to use the document() function with a lookup
table (a second xml file containing information i need to process my xml
source-document), but despite all efforts it didn't work.

following scenario:

in my source-xml i can find following code <positLoco>DE</positLoco>,
whose meaning ( <codeText>) i need to be printed in my resulting fo-file.

this is part of my source file 'dakl.xml' including the code:

  <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):

<xsl:template name="Posit">
        <xsl:choose>
                <xsl:when test="//einzelPositionList">
                        <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:attribute name="
background-color">
                                        <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"/>
        <xsl:if test="normalize-space(./positionsDaten/positLoco) != $leer
">
                <xsl:text>Loco: </xsl:text>
                <xsl:for-each select="$loco-svz"/>
                        <xsl:value-of select="$loco-svz/codeText"/>
        </xsl:if>
</fo:block>
[...]

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


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

i also tried the suggestion of
http://www-128.ibm.com/developerworks/library/x-xsltip.html (see later)
with this xsl. this solution didn't work - apache fop 0.90 didn't like the
position of the templates. maybe this is becaus there already is a
template around the table.


thx in advance
alex

<?xml version="1.0"?>
<xsl:transform
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0">
 <xsl:output method="text"/>

<!-- A -->
 <xsl:key name="state-lookup" match="state" use="abbr"/>

<!-- B -->
 <xsl:variable name="states-top" select="document('states.xml')/states"/>
 <xsl:template match="label">
  <xsl:value-of select="name"/>
  <xsl:text> of </xsl:text>

<!-- C -->
  <xsl:apply-templates select="$states-top">
   <xsl:with-param name="curr-label" select="."/>
  </xsl:apply-templates>
 </xsl:template>

<!-- D -->
 <xsl:template match="states">
  <xsl:param name="curr-label"/>
  <xsl:value-of select="key('state-lookup',
$curr-label/address/state)/name"/>
 </xsl:template>
</xsl:transform>



______________________________________________________________________
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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.