Access parent node of dynamic table in xslt

0

I have the following xml structure:

<pago10:Pagos Version="1.0">
      <pago10:Pago FechaPago="2017-09-09T12:00:00" FormaDePagoP="03" MonedaP="MXN" Monto="14000.00" NumOperacion="012180004457813372" RfcEmisorCtaOrd="BBA830831LJ2" NomBancoOrdExt="Banco patito" CtaOrdenante="0445781337" RfcEmisorCtaBen="BMN930209927" CtaBeneficiario="0560877">
        <pago10:DoctoRelacionado IdDocumento="8A2D55A5-XXXX-4B28-AC8C-6E72EFBCFA61" Serie="A" Folio="1132" MonedaDR="MXN" MetodoDePagoDR="PUE" ImpSaldoAnt="14000" ImpPagado="14000" ImpSaldoInsoluto="0" />
      </pago10:Pago>
      <pago10:Pago FechaPago="2017-09-09T12:00:00" FormaDePagoP="04" MonedaP="MXN" Monto="14000.00" NumOperacion="012180004457813372" RfcEmisorCtaOrd="BBA830831LJ2" NomBancoOrdExt="Banco patito" CtaOrdenante="0445781337" RfcEmisorCtaBen="BMN930209927" CtaBeneficiario="0560877">
        <pago10:DoctoRelacionado IdDocumento="8A2D55A5-XXXX-4B28-AC8C-6E72EFBCFA62" Serie="A" Folio="1132" MonedaDR="MXN" MetodoDePagoDR="PUE" ImpSaldoAnt="14000" ImpPagado="14000" ImpSaldoInsoluto="0" />
        <pago10:DoctoRelacionado IdDocumento="8A2D55A5-XXXX-4B28-AC8C-6E72EFBCFA63" Serie="A" Folio="1132" MonedaDR="MXN" MetodoDePagoDR="PUE" ImpSaldoAnt="14000" ImpPagado="14000" ImpSaldoInsoluto="0" />
      </pago10:Pago>
</pago10:Pagos>

and I paint a table with all DoctoRelacionado tags:

IdDocumento*** Serie *** Folio ** etc

8A........FA61 ** A ** 1123 ** ...

8A........FA62 ** A **  1132 ** ...

8A........FA63 ** A **  1132 ** ...

Asterisks would be like the division of columns. The problem is that I need to add a column with an attribute of the node pago that is the parent of DoctoRelacionado , in specific with FormaDePagoP so that the table looks like this:

IdDocumento*** Serie *** Folio ** FormaDePagoP

8A........FA61 ** A ** 1123 ** 03

8A........FA62 ** A **  1132 ** 04

8A........FA63 ** A **  1132 ** 04

How could I do this with xpath or with xslt ? I'm restricted to xslt 1.0 . and I can support Altova stylevision .

    
asked by abrahamhs 13.02.2018 в 01:21
source

1 answer

0

I have already solved it, I answer it in case someone needs it, in the end I made a table of a column for the node pago10:Pago and inside that cell I made the other table pago10:DoctoRelacionado , in this way I could extract FormaDePagoP and place it as a subtitle of the table and no longer as a column. For each different value of FormaDePagoP a table with its corresponding value will appear. The table of a pago10:Pago cell removes borders and background so that it does not appear to exist. This is the main idea of the code (do not put all the columns):

<table border="0">
    <tbody>
        <xsl:for-each select="pago10:Pagos">
            <xsl:for-each select="pago10:Pago">
                <tr>
                    <td>
                        <table style="font-size:8px; " border="1">
                            <thead>
                                <tr style="height:0.13in; line-height:normal; ">
                                    <th colspan="8" style="background-color:#0071bb; font-size:6px; width:1.80in; ">
                                        <br/>
                                        <span style="font-size:10px; vertical-align:middle; ">
                                            <xsl:text>Forma de pago: </xsl:text>
                                        </span>
                                        <xsl:for-each select="@FormaDePagoP">
                                            <span style="font-size:10px; ">
                                                <xsl:value-of select="string(.)"/>
                                            </span>
                                        </xsl:for-each>
                                    </th>
                                </tr>
                                <tr style="background-color:#0071bb; height:0.13in; ">
                                    <th style="width:1.80in; ">
                                        Columna 1
                                    </th>
                                    <th style="width:0.60in; ">
                                        Columna 2
                                    </th>
                                    ...
                                    <th style="width:0.60in; ">
                                        Columna n
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <xsl:for-each select="pago10:DoctoRelacionado">
                                    <tr align="center">
                                        <td style="width:1.80in; ">
                                            <xsl:for-each select="@IdDocumento">
                                                <span>
                                                    <xsl:value-of select="string(.)"/>
                                                </span>
                                            </xsl:for-each>
                                        </td>
                                        <td style="width:0.60in; ">
                                            <xsl:for-each select="@Serie">
                                                <span>
                                                    <xsl:value-of select="string(.)"/>
                                                </span>
                                            </xsl:for-each>
                                            <span>
                                                <xsl:text>-</xsl:text>
                                            </span>
                                            <xsl:for-each select="@Folio">
                                                <span>
                                                    <xsl:value-of select="string(.)"/>
                                                </span>
                                            </xsl:for-each>
                                        </td>
                                        ...
                                    </tr>
                                </xsl:for-each>
                            </tbody>
                        </table>
                        <br/>
                    </td>
                </tr>
            </xsl:for-each>
        </xsl:for-each>
    </tbody>
</table>

    
answered by 01.03.2018 / 18:18
source