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

copy nodes() of other XML file

Subject: copy nodes() of other XML file
From: "Jimenez, Luis" <Luis.Jimenez@xxxxxxxxx>
Date: Sat, 11 Dec 2010 17:51:28 -0500
 copy nodes() of other XML file
Hi all,

I'm trying to copy the contents of a node that is in one file to another, but
must be copied into a document.

XSLT version 1.0

******
My main XML file:

<?xml version="1.0" encoding="iso-8859-1"?>
<spoolpd>
<pd>
  <frmocs>
    <blqcon>
       <creg>15</creg>
       <czon>1509</czon>
       <csec>B</csec>
    </blqcon>
  </frmocs>
  <frmecc>
     <cab>
       <ccon>0303393</ccon>
       <ncon>MARIA</ncon>
     </cab>
     <detalle>
       <txt>14/09/2010<t/>Saldo anterior a
pagar<tr/>0.00<tr/>0.00<tr/>328.69</txt>
       <txt>30/09/2010<t/>Pago en banco<tr/>0.00<tr/>-328.69<tr/>0.00</txt>
       <txt>01/10/2010<t/>Ped. 201015 B.Despacho
1006313633<tr/>415.06<tr/>0.00<tr/>415.06</txt>
       <txt><t/><tr/><tr/><tr/></txt>
       <txt><t/><tr/><tr/><tr/></txt>
     </detalle>
  </frmecc>
</pd>
<pd ps="1">
  <frmecc>
     <cab>
       <ccon>1234567</ccon>
       <ncon>JOSE</ncon>
     </cab>
     <detalle>
       <txt>14/09/2010<t/>Saldo anterior a
pagar<tr/>0.00<tr/>0.00<tr/>328.69</txt>
    </detalle>
  </frmecc>
  <frmocs>
    <blqcon>
       <creg>15</creg>
       <czon>1509</czon>
       <csec>B</csec>
    </blqcon>
  </frmocs>
</pd>
</spoolpd>

******
My Second XML File - which should make the information:

<?xml version="1.0" encoding="iso-8859-1"?>
<spoolpd>
<pd>
  <ccon>0303393</ccon>
  <detctacte>
    <txt>SALDO ANTERIOR<t/><t/><t/><t/><tr/><tr/><tr/>1234567</txt>
  </detctacte>
</pd>
<pd>
  <ccon>1234567</ccon>
  <detctacte>
    <txt>SALDO ANTERIOR<t/><t/><t/><t/><tr/><tr/><tr/>8901234</txt>
  </detctacte>
</pd>
<spoolpd>

******
My XSL File:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:param name="f1" select="'VELCTACTE_201010010002.val'"/> <!-- My Second
XML File - which should make the information -->

<xsl:variable name="doc1" select="document($f1)"/>

<xsl:key name="k1" match="spoolpd/pd" use="ccon"/>

<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"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="pd">
  <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:variable name="id" select="frmecc/cab/ccon"/>
      <xsl:for-each select="$doc1">
        <xsl:copy-of select="key('k1', $id)/detctacte"/>
      </xsl:for-each>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

******
My Desired Output:

<?xml version="1.0" encoding="iso-8859-1"?>
<spoolpd>
<pd>
  <frmocs>
    <blqcon>
       <creg>15</creg>
       <czon>1509</czon>
       <csec>B</csec>
    </blqcon>
  </frmocs>
  <frmecc>
     <cab>
       <ccon>0303393</ccon>
       <ncon>MARIA</ncon>
     </cab>
     <detalle>
       <txt>14/09/2010<t/>Saldo anterior a
pagar<tr/>0.00<tr/>0.00<tr/>328.69</txt>
       <txt>30/09/2010<t/>Pago en banco<tr/>0.00<tr/>-328.69<tr/>0.00</txt>
       <txt>01/10/2010<t/>Ped. 201015 B.Despacho
1006313633<tr/>415.06<tr/>0.00<tr/>415.06</txt>
       <txt><t/><tr/><tr/><tr/></txt>
       <txt><t/><tr/><tr/><tr/></txt>
     </detalle>
     <detctacte>
       <txt>SALDO ANTERIOR<t/><t/><t/><t/><tr/><tr/><tr/>1234567</txt>
     </detctacte>
  </frmecc>
</pd>
<pd ps="1">
  <frmecc>
     <cab>
       <ccon>1234567</ccon>
       <ncon>JOSE</ncon>
     </cab>
     <detalle>
       <txt>14/09/2010<t/>Saldo anterior a
pagar<tr/>0.00<tr/>0.00<tr/>328.69</txt>
    </detalle>
    <detctacte>
      <txt>SALDO ANTERIOR<t/><t/><t/><t/><tr/><tr/><tr/>8901234</txt>
    </detctacte>
  </frmecc>
  <frmocs>
    <blqcon>
       <creg>15</creg>
       <czon>1509</czon>
       <csec>B</csec>
    </blqcon>
  </frmocs>
</pd>
</spoolpd>


Thanks to everyone for the help.

Luis Fdo.

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.