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

Re: [XSL 1.0] Copy node into of other

Subject: Re: [XSL 1.0] Copy node into of other
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 06 Nov 2010 17:37:35 +0100
Re:  [XSL 1.0] Copy node into of other
Jimenez, Luis wrote:

The XSL 1.0 not working. Sending the XML file, XSL file and the desired output

*** 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>

The </pagina> is missing here and below:


  </picking>
</pd>

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

Assuming you have well-formed XML with a pagina element then you can solve that as follows:


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

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

  <xsl:template match="spoolpd">
    <xsl:copy>
      <xsl:apply-templates select="@* | pd[@marca = 'REAL']"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="pd">
    <xsl:copy>
      <xsl:apply-templates select="@* | frmbd"/>
    </xsl:copy>
  </xsl:template>

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

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

</xsl:stylesheet>

--

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

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.