Subject: [xsl] copy nodes() of other XML file From: "Jimenez, Luis" <Luis.Jimenez@xxxxxxxxx> Date: Sat, 11 Dec 2010 17:51:28 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] template match question, Ciarán Ó Duibhín | Thread | Re: [xsl] copy nodes() of other XML, G. Ken Holman |
Re: [xsl] template match question, Ciarán Ó Duibhín | Date | Re: [xsl] copy nodes() of other XML, G. Ken Holman |
Month |