[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
Hi Martin, 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> </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> </picking> </pd> </spoolpd> *** 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:template match="/"> <spoolpd> <xsl:for-each select="/spoolpd/pd"> <xsl:if test="@marca='REAL'"> <pd marca='REAL'> <xsl:apply-templates select="frmbd"/> </pd> </xsl:if> </xsl:for-each> </spoolpd> </xsl:template> <xsl:template match="frmbd"> <xsl:copy> <xsl:apply-templates select="@* | node() | ../picking/cabecera/infocaja"/> </xsl:copy> </xsl:template> </xsl:stylesheet> *** Desired output: Must leave for each <pd>, only the content <frmbd> node, and within <frmbd <pbd1> <blqcab> the <infocaja> node of <picking> <?xml version="1.0" encoding="iso-8859-1"?> <spoolpd> <pd marca="REAL"> <frmbd> ==> ONLY FRMBD <pbd1> <blqcab> <nsec>1</nsec> <chq /> <ccon>0303393</ccon> <ncon>TORRES CABRERA, MARIA </ncon> <infocaja>1/1</infocaja> ==> NODE OF PICKING/CABECERA/INFOCAJA </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> </spoolpd> Thanks for you help. Luis Fdo. -----Mensaje original----- De: Martin Honnen [mailto:Martin.Honnen@xxxxxx] Enviado el: Sabado, 06 de Noviembre de 2010 09:30 a.m. Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Asunto: Re: [XSL 1.0] Copy node into of other Jimenez, Luis wrote: > Hi All, > > as a node can be copied to another location within the XML? > > * Processor XSLT 1.0 > > My XML file: > > <root> > <customer> > <personal> > <name>Luis</name> > <phone>1234567</phone> > <age>45</age> > </personal> > > <occupation> > <position>engineer</position> > <time>5 years</years> > </occupation> > </customer> > </root> > > Desired output: The node <position> is copied into customer/personal > > <root> > <customer> > <personal> > <name>Luis</name> > <phone>1234567</phone> > <age>45</age> > <position>engineer</position> > </personal> > > <occupation> > <position>engineer</position> > <time>5 years</years> > </occupation> > </customer> > </root> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="personal"> <xsl:copy> <xsl:apply-templates select="@* | node() | ../occupation/position"/> </xsl:copy> </xsl:template> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|