0

I have a question about xsl-fo. I am a little new to it though. I have raw text data that I convert to an xml document utilizing an awk script. The xml structure looks like this:

-<entry>
    <TimeStamp>"5/4/2017 9:00:00 AM"</TimeStamp>
    <PlateVolts>44.66</PlateVolts>
    <PlateCurrent>144.3</PlateCurrent>
    <ForwardPower>98.51</ForwardPower>
    <ReflectivePower>2.62</ReflectivePower>
    <IntakeAirTemp>79.42</IntakeAirTemp>
    <ExhaustAirTemp>90.06</ExhaustAirTemp>
    <WestRoomTemp>67.7</WestRoomTemp>
    <TowerLightCurrent>76.21</TowerLightCurrent>
    <EastRoomTemp>65.35</EastRoomTemp>
    <NotMonitrd1>117.08</NotMonitrd1>
    <RackVoltage>1.55</RackVoltage>
    <BkupFwd>0.12</BkupFwd>
    <BkupRef>120.15</BkupRef>
    <SpsGen>0</SpsGen>
    <AudioLevel>96.81</AudioLevel>
 </entry>
-<entry>
    <TimeStamp>"5/4/2017 8:59:45 AM"</TimeStamp>
    <textTag>"Priority 0 Warning Status Alarm : Gen ON (Ch 8)"</textTag>
</entry>
-<entry>
    <TimeStamp>"5/4/2017 9:01:49 AM"</TimeStamp>
    <textTag>"Status change (Ch 8): Gen ON"</textTag>
</entry>
-<entry>
     <TimeStamp>"5/4/2017 9:02:49 AM"</TimeStamp>
     <PlateVolts>44.66</PlateVolts>
     <PlateCurrent>144.21</PlateCurrent>
     <ForwardPower>98.57</ForwardPower>
     <ReflectivePower>2.86</ReflectivePower>
     <IntakeAirTemp>78.9</IntakeAirTemp>
     <ExhaustAirTemp>90.18</ExhaustAirTemp>
     <WestRoomTemp>67.48</WestRoomTemp>
     <TowerLightCurrent>69.15</TowerLightCurrent>
     <EastRoomTemp>64.91</EastRoomTemp>
     <NotMonitrd1>117.39</NotMonitrd1>
     <RackVoltage>1.55</RackVoltage>
     <BkupFwd>0.12</BkupFwd>
     <BkupRef>120.15</BkupRef>
     <SpsGen>0</SpsGen>
     <AudioLevel>91.78</AudioLevel>
</entry>

I use the entries to create a table with the tags as the column headers but when I come to an entry with texTag, it crams it all into one itty-bitty cell which is adding pages to the PDF document and it doesn't look real neat and is in most cases impractical. I found the xsl:choose / xsl:otherwise commands but I'm not sure as to how to set it up in the table that way the textTags will just come out as a single cell that spans across the table.

The table Column count are as follows<fo:block> <fo:table table-layout="fixed" width="100%" border-style="solid" border="0.2cm"> <fo:table-column column-width="12.5%"/> <!-- Timestamp--> <fo:table-column column-width="5.83%"/> <!-- PlateVolts --> <fo:table-column column-width="5.83%"/> <!-- PlateCurrent --> <fo:table-column column-width="5.83%"/> <!-- ForwardPower--> <fo:table-column column-width="5.83%"/> <!-- ReflectivePower --> <fo:table-column column-width="5.83%"/> <!-- IntakeAirTemp --> <fo:table-column column-width="5.83%"/> <!-- TowerLightCurrent --> <fo:table-column column-width="5.83%"/> <!-- ExhaustAirTemp --> <fo:table-column column-width="5.83%"/> <!-- WestRoomTemp --> <fo:table-column column-width="5.83%"/> <!-- EastRoomTemp --> <fo:table-column column-width="5.83%"/> <!-- NotMonitrd1 --> <fo:table-column column-width="5.83%"/><!-- RackVoltage --> <fo:table-column column-width="5.83%"/> <!-- BkupFwd --> <fo:table-column column-width="5.83%"/> <!-- BkupRef --> <fo:table-column column-width="5.83%"/> <!-- SpsGen --> <fo:table-column column-width="5.83%"/> <!-- AudioLevel -->

The Table column headers reflect the comments. I will leave that part out for brevity.

Below is what the meat of the table looks like.

<xsl:for-each select="entry">
               <fo:table-row>
                <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="TimeStamp" />
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="PlateVolts" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="PlateCurrent" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="ForwardPower" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="ReflectivePower" />
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="IntakeAirTemp" />
                    </fo:block>
        </fo:table-cell>
                <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="ExhaustAirTemp" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="WestRoomTemp" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="TowerLightCurrent" />
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="EastRoomTemp" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="NotMonitrd1" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="RackVoltage" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="BkupFwd" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="BkupRef" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="SpsGen" />
                    </fo:block>
                </fo:table-cell>
        <fo:table-cell border="solid .5px black" 
        text-align="center" >
                    <fo:block>
                        <xsl:value-of select="AudioLevel" />
                    </fo:block>
                </fo:table-cell>    
       </fo:table-row>
         </xsl:for-each>
      </fo:table-body>
    </fo:table>

Thank you everyone for your help!

Geerdes
  • 9
  • 3
  • There are two branches of XSL: XSLT and XSL-FO. If you want a term that covers both then you could try just XSL, but "XSLT-FO" doesn't make sense. See http://stackoverflow.com/questions/740404/whats-the-difference-between-xslt-and-xsl-fo – John Bollinger May 11 '17 at 20:19
  • In any case, if you have a question about transforming or formatting your XML, then presenting your current XSL -- not just a description of its result -- would be a good place to start. – John Bollinger May 11 '17 at 20:20
  • I'd be happy to but posting all 304 lines of code and having to add 4 spaces to each line is a little rough, is there an easier way to post it? – Geerdes May 11 '17 at 20:29
  • 1
    Ideally, you would reduce your code to a [mcve]. 300 lines is considerably longer than we generally want to see. With that said, you should not have to indent each line individually. The editor has a button for doing it all at once: select the code you want to indent, and click the `{}` button on the toolbar. – John Bollinger May 11 '17 at 20:42

0 Answers0