RE: [xsl] [XSL 1.0] Copy node into of other

Subject: RE: [xsl] [XSL 1.0] Copy node into of other
From: "Jimenez, Luis" <Luis.Jimenez@xxxxxxxxx>
Date: Sat, 6 Nov 2010 13:28:07 -0400
Martin,

In the XML file within "PD" can come multiple times <picking>.

i.e.

*** XML File:

<?xml version="1.0" encoding="iso-8859-1"?> <spoolpd>
  <pd marca="REAL">
    <frmocs>
      <blqcon>
        <creg>15</creg>
        <czon>1509</czon>
        <tcon>02643714355</tcon>
      </blqcon>
    </frmocs>
    <frmbd>
      <pbd1>
        <blqcab>
           <nsec>1</nsec>
           <chq />
           <ccon>0303393</ccon>
           <ncon>TORRES CABRERA, MARIA </ncon>
        </blqcab>
        <blqimp>
           <txt>16</txt>
           <txt />
           <txt>415.06</txt>
           <txt />
           <txt />
        </blqimp>
        <detalle />
    </pbd1>
  </frmbd>
  <picking>
    <pagina>
       <cabecera>
          <numzona>09</numzona>
          <tamcaja>Caja Grande</tamcaja>
          <infocaja>1/1</infocaja>
          <infopagina>1/1</infopagina>
       </cabecera>
       <linea>
         <columna01 parameter="NONE">
           <anaquel>A01A1</anaquel>
           <cantidad>1</cantidad>
           <descrip>CDR L`BEL 2009</descrip>
         </columna01>
         <columna02 parameter="NONE">
           <anaquel />
           <cantidad />
           <descrip />
         </columna02>
       </linea>
    </pagina>
  </picking>
  <picking>
    <pagina>
       <cabecera>
          <numzona>09</numzona>
          <tamcaja>Caja Grande</tamcaja>
          <infocaja>2/2</infocaja>
          <infopagina>1/1</infopagina>
       </cabecera>
       <linea>
         <columna01 parameter="NONE">
           <anaquel>A01A1</anaquel>
           <cantidad>1</cantidad>
           <descrip>CDR L`BEL 2009</descrip>
         </columna01>
         <columna02 parameter="NONE">
           <anaquel />
           <cantidad />
           <descrip />
         </columna02>
       </linea>
    </pagina>
  </picking>
</pd>
<pd marca="REAL">
    <frmocs>
      <blqcon>
        <creg>16</creg>
        <czon>1510</czon>
        <tcon>02643714455</tcon>
      </blqcon>
    </frmocs>
    <frmbd>
      <pbd1>
        <blqcab>
           <nsec>2</nsec>
           <chq />
           <ccon>0303303</ccon>
           <ncon>Cordoba, Luis </ncon>
        </blqcab>
        <blqimp>
           <txt>16</txt>
           <txt />
           <txt>415.06</txt>
           <txt />
           <txt />
        </blqimp>
        <detalle />
    </pbd1>
  </frmbd>
  <picking>
    <pagina>
       <cabecera>
          <numzona>10</numzona>
          <tamcaja>Caja Grande</tamcaja>
          <infocaja>1/2</infocaja>
          <infopagina>1/1</infopagina>
       </cabecera>
       <linea>
         <columna01 parameter="NONE">
           <anaquel>A01A1</anaquel>
           <cantidad>1</cantidad>
           <descrip>CDR L`BEL 2009</descrip>
         </columna01>
         <columna02 parameter="NONE">
           <anaquel />
           <cantidad />
           <descrip />
         </columna02>
       </linea>
   </pagina>
  </picking>
</pd>
</spoolpd>

** I get the output:

<pd marca="REAL">
    <frmbd>
      <pbd1>
        <blqcab>
           <nsec>2</nsec>
           <chq />
           <ccon>0303303</ccon>
           <ncon>Cordoba, Luis </ncon>
           <infocaja>1/1</infocaja>  ==========> APPEARS 2 TIMES, IT MUST
APPEAR ONCE Y ONLY THE FIRST
           <infocaja>2/2</infocaja>  ==========> APPEARS 2 TIMES, IT MUST
APPEAR ONCE Y ONLY THE FIRST
        </blqcab>
        <blqimp>
           <txt>16</txt>
           <txt />
           <txt>415.06</txt>
           <txt />
           <txt />
        </blqimp>
        <detalle />
    </pbd1>
  </frmbd>
</pd>
<pd marca="REAL">
   <frmbd>
      <pbd1>
        <blqcab>
           <nsec>2</nsec>
           <chq />
           <ccon>0303303</ccon>
           <ncon>Cordoba, Luis </ncon>
           <infocaja>1/2</infocaja>
        </blqcab>
        <blqimp>
           <txt>16</txt>
           <txt />
           <txt>415.06</txt>
           <txt />
           <txt />
        </blqimp>
        <detalle />
    </pbd1>
  </frmbd>
</pd>

Thanks,

Luis Fdo.


-----Mensaje original-----
De: Martin Honnen [mailto:Martin.Honnen@xxxxxx]
Enviado el: Sabado, 06 de Noviembre de 2010 12:15 p.m.
Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Asunto: Re: [xsl] [XSL 1.0] Copy node into of other

Jimenez, Luis wrote:

> Works without problem, but when there is a PD node without the attribute
"marca" does not appear in the output, that changes must be made in the XSL to
display too.

Sorry, I don't understand that requirement. Please explain in more
detail what the problem is.

> Also if there are two nodes picking in PD, I get two nodes in the output
"infocaja", as could choose only the first "infocaja" of node picking.
> .....
> <femi>01/10/2010</femi>
> <infocaja>1/1</infocaja>
> <infocaja>2/2</infocaja>

The only process the first by adding [1] i.e.

   <xsl:template match="blqcab">
     <xsl:copy>
       <xsl:apply-templates
         select="@* |
                 node() |

parent::pbd1/parent::frmbd/following-sibling::picking[1]/pagina/cabecera/info
caja[1]"/>
     </xsl:copy>
   </xsl:template>

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread