0

Checked back again (hopefully pretty much for the last time with this issue) with this rather old (already) problem of mine about those share bills apartment tracking list. The "story" is here:

1 to n relationship between xml principal records and other bunch of related node values (III)

I'll try make it as brief as possible (resumed this "story" ..)

There were some/that tabular monthly payments tracking displayed. Data are kept through some .xml file presented down here:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="xml_style.xsl" type="text/xsl"?>
 <upkeepList> 
  <upkShare month_year="11_16-12_16" post_dte="01-20-17" due="02-04-17">
   <OpngBlnce>22</OpngBlnce>
   <mnthCrrntAmnt>77</mnthCrrntAmnt> 
    <Rcpt dte="01-26-17" No="5725">
     <amnt>22</amnt>
     <descrpt>"11/16" upkeep </descrpt>
    </Rcpt>
    <Rcpt dte="01-26-17" No="5726">
     <amnt>41</amnt>
     <descrpt>"12/16" upkeep </descrpt>
    </Rcpt>
  </upkShare>
  <upkShare month_year="01_17-02_17" post_dte="03-17-17" due="04-03-17">
   <OpngBlnce></OpngBlnce> 
   <mnthCrrntAmnt>74</mnthCrrntAmnt>
   <Rcpt dte="03-30-17" No="5783">
    <amnt>50</amnt>
    <descrpt>"01/17-02/17" upkeep</descrpt>
   </Rcpt>
  </upkShare>
  <upkShare month_year="03-17" post_dte="04-16-17" due="05-02-17"> 
   <OpngBlnce></OpngBlnce>
   <mnthCrrntAmnt>55</mnthCrrntAmnt>
   <Rcpt dte="05-10-17" No="5815">
    <amnt>40</amnt>
    <descrpt>"03/17-04/17" upkeep 1</descrpt>
   </Rcpt>
   <Rcpt dte="05-15-17" No="5825">
    <amnt>9</amnt>
    <descrpt>"03/17-04/17" upkeep 2</descrpt>
   </Rcpt> 
  </upkShare>
  <upkShare month_year="04_17-05_17" post_dte="06-05-17" due="06-30-17">
   <OpngBlnce></OpngBlnce>
   <mnthCrrntAmnt>64</mnthCrrntAmnt>
   <Rcpt dte="06-14-17" No="5858">
    <amnt>37</amnt>
    <descrpt>"05/17" upkeep 1</descrpt>
   </Rcpt>
   <Rcpt dte="06-18-17" No="5863">
    <amnt>21</amnt>
    <descrpt>"05/17" upkeep 2</descrpt>
   </Rcpt>
 </upkShare>
         .
         .
         .
<upkShare month_year="06_17" post_dte="07-16-17" due="07-30-17">
<OpngBlnce></OpngBlnce>
 <mnthCrrntAmnt>45</mnthCrrntAmnt>
  <Rcpt dte="07-28-17" No="5948">
   <amnt>38</amnt>
   <descrpt>"06/17" upkeep</descrpt>
  </Rcpt>
 </upkShare> 
</upkeepList>

And the way it's displayed is done through this .xsl file

<?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">
 <xsl:strip-space elements="*"/> <xsl:decimal-format name="coerce" NaN="0"/>
 <xsl:variable name="rcpts">  <!-- rcpts var -->
  <xsl:for-each select="//Rcpt">
   <eRcpt rcptno="{@No}" rcptdte="{@dte}" rcptamnt="{amnt}" rdscrpt="{descrpt}"/> 
  </xsl:for-each> 
 </xsl:variable> 
 <xsl:variable name="rcpts-set" select="exsl:node-set($rcpts)/eRcpt"/>

 <xsl:variable name="upkshr">   <!-- upkshr -->
  <xsl:for-each select="//upkShare"> 
   <upkp pstdte="{@post_dte}" rltedmnthyr = "{@month_year}" ob = "{format-number(OpngBlnce, '#', 'coerce')}"
     mcamnt = "{format-number(mnthCrrntAmnt, '#','coerce')}" term = "{@due}" rcptsum = "{format-number(sum(Rcpt/amnt), '#','coerce')}"/>
   </xsl:for-each> 
  </xsl:variable> 
 <xsl:variable name="upkp-set" select="exsl:node-set($upkshr)/upkp"/>

 <xsl:template match="upkeepList">
  <xsl:apply-templates select="$upkp-set[1]"> </xsl:apply-templates> 
 </xsl:template>

 <xsl:template match="upkp">
  <html>
   <head>
   <meta name="viewport" content="width=device-width, initial-scale=1"></meta>
   <xsl:element name="script">
     <xsl:attribute name="src">https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js</xsl:attribute>
    </xsl:element>
    <xsl:element name="script">
     <xsl:attribute name="src">https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js 
     </xsl:attribute>
    </xsl:element>  
  <link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> 
    </link>
  </head>
   <h4 style="margin-left:366px; margin-top:68px">Monthly Apartmnt. Upkeep Share Bills List</h4>
  <table border="1" id='content1' width="50px" height="170" style="text-align:center;position:relative;margin-left:204px;border-collapse:collapse;margin-top:28px"> 
   <tr bgcolor="#9acd32">
  <th></th> <th>UpkpShare_Prd</th> <th>PostDate</th> <th>InitBalance</th> 
  <th>UpkpShare_Amnt</th>
  <th>DueDate</th> <th>FullAmnt</th> <th>FullAmntPayed</th> <th>AmntDue</th>
  </tr>

 <xsl:for-each select=". | following-sibling::upkp[position()&lt;4]">
 <xsl:variable name="initblnc" select="sum(preceding-sibling::upkp/@ob) + sum(preceding-sibling::upkp/@mcamnt) - sum(preceding-sibling::upkp/@rcptsum) + @ob"/> 
  <tr data-toggle="collapse">
    <xsl:attribute name="data-target">    
     <xsl:value-of select="concat('#p-',@rltedmnthyr)"/>  
    </xsl:attribute>    

  <td>+</td>
  <td><div style="auto"> <xsl:value-of select="@rltedmnthyr"/> </div></td> <!-- relatd mnthly year -->
  <td> <xsl:value-of select="@pstdte"/> </td>  <!-- post date -->
  <td> <div style="width:30px">
   <xsl:value-of select="$initblnc"/>  <!-- initblnc = initial balance / opening balance -->
 </div> 
 </td>
 <td> <xsl:value-of select="@mcamnt"/> </td> <!-- monthly upkeep share amount -->
 <td> <div style="width:60px"> <xsl:value-of select="@term"/> </div> </td>  <!-- due -->
 <td> <xsl:value-of select="$initblnc + @mcamnt"/> </td>  <!-- full amount -->
 <td> <xsl:value-of select="@rcptsum"/> </td>    <!-- full amount payed -->
 <td> <xsl:value-of select="$initblnc + @mcamnt - @rcptsum"/> </td>  <!-- amount due / closing balance -->
  <tbody class="collapse"> 
    <xsl:attribute name="id">    
     <xsl:value-of select="concat('p-',@rltedmnthyr)"/>  
    </xsl:attribute>    
    <tr> <th>rcpt</th> <th>rcptDte</th> <th>rcptAmnt</th> <th>dscrpt</th> </tr>
   <!-- <xsl:for-each select="$rcpts-set">  select="@rpt"-->
    <tr> 
      <xsl:for-each select="."> 
       <td><xsl:value-of select="$rcpts-set/@rcptno"/></td>
       <td><xsl:value-of select="$rcpts-set/@rcptdte"/></td> 
       <td><xsl:value-of select="$rcpts-set/@rcptamnt"/></td>
       <td><xsl:value-of select="$rcpts-set/@rdscrpt"/></td>
      </xsl:for-each> 
     </tr>
     <!--</xsl:for-each> -->
    </tbody>
   </tr>
   </xsl:for-each>
  </table>   
 </html> 
 </xsl:template>
</xsl:stylesheet>  

As one would notice principal lines there are displayed just fine. With all columns details like opening balance, monthly current amount to be payed, amount related dates and so forth. Besides all those principal lines there are those related receipts through which certain payments were actually made. These are so called "the related part of relationship." As I already mentioned before, that sort of connection between principal line and all those related receipts is called 1-to-1 / 1-to-n relationship. Through use of bootstrap framework I somehow managed to visually simulate this sort of relationship. Thing is that I need to display these (principal) lines along with all related receipts (either one, two or more). So far I only succeeded to properly display just those principal lines. And I also manage to display only first receipt from first line which keeps repeating over all other principal lines; as could one notice through that .xsl file check.

Instead, I need to display all the related receipts like through this fiddle:

https://jsfiddle.net/MrcaS48/sv5pybdz

On to that "fiddle" I just showed (through some .html page) how exactly I wanted for everything to be displayed. I hope I did myself clear enough. I'll briefly repeat my request:

  • need to display all those principal xml lines (which I manage to display) along with all those related receipts (this part was unable to do it)

There is one xslt variable (and there is one more made it by myself) which ain't got no clue how to further customize in order to display all those related receipts of principal lines.

Please you guys help me with this as I'm in very much great need to do it ! I'm really sorry to say this, but is crucial important for me to solve it , as some other stuff depend on this. Thank you very much in advance !!

mcaS48
  • 33
  • 8
  • I suggest you narrow down your question to a specific problem and provide a [mcve]. In general, relationships (i.e. cross-references) are handled by [**keys**](https://www.w3.org/TR/1999/REC-xslt-19991116#key). – michael.hor257k Sep 10 '19 at 18:12
  • The only thing I forget to mention is that in order to see all those related receipts, one should click over each and every principal line; and as such, that particular line will expand and it will show that/those related receipts. Somewhere, inside the html table tag, down through there is a statement which is not correct, in order to correctly display that bunch of related receipts associated with first (some) line. And perhaps it's something to do also with that "rcpts" variable defined. I just tried a lot of possibilities, but I just haven't figure it out – mcaS48 Sep 10 '19 at 18:45
  • That has nothing to do with XSLT. – michael.hor257k Sep 10 '19 at 18:50
  • Regarding that way of expanding and collapsing lines, yes: it has nothing to do with xslt. You're right. Only I mentioned that as I forget to refer of it it up earlier through my question. Anyway .. if you understand my request, please help me with this. I'm struggling for a couple of weeks now ... Please ...mr. @michael.hor257k – mcaS48 Sep 10 '19 at 18:57
  • Sort this out ! Thank you guys for all of your support This thread can be close down. – mcaS48 Sep 27 '19 at 07:13

0 Answers0