XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Fernando TorresSubject: XSL-FO XML to PDF with XSLT
Author: Fernando Torres
Date: 12 Mar 2009 05:14 PM
Hi guys i'm trying to convert an XML file to PDF File i'm using XSL-FO
my XML file have namespace and schemalocation if I remove those from the XML file de transformation works if I put those in the XML files the transformation fails with "A well-formed document requires a root element"

Here is my code of my XML file

<?xml version="1.0" encoding="UTF-8"?>
<Comprobante xmlns="http://www.sat.gob.mx/cfd/2" xsi:schemaLocation="http://www.sat.gob.mx/cfd/2 http://www.sat.gob.mx/sitio_internet/cfd/2/cfdv2.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fecha="2007-01-20T11:22:56" folio="0337515" noAprobacion="1" noCertificado="10001200000000022517" serie="A" version="2.0" anoAprobacion="2008" formaDePago="Efectivo" subTotal="2289.97" total="2633.47" tipoDeComprobante="ingreso" sello="DOk8TpozSBf4CIC0aQRaShYa2qcIo4+NWJZFntrkSVFlITNJIn4OGs7WMgrUR80Dm2+9YbRfhZ2XJC3ec7auhZ9UcXaRFOQMlBR67DgNgJ0s77CCUxPH6ymQsSfsid5HqSYHSvMqIo8X8pTk0xc4awR/EHGsnmeGfKgDIasuGIw=" >
<Emisor nombre="G.P. ELECTROMECÁNICA, S.A. DE C.V." rfc="GPE8410012I9">
<DomicilioFiscal calle="Blvd. a Zacatecas" noExterior="201" colonia="Col. Industrial" codigoPostal="20030" estado="Aguascalientes" municipio="Aguascalientes" pais="México"/>
<ExpedidoEn calle="Blvd. a Zacatecas" noExterior="201" colonia="Col. Industrial" codigoPostal="20030" estado="Aguascalientes" municipio="Aguascalientes" pais="México"/>
</Emisor>
<Receptor nombre="FRIGORIZADOS LA HUERTA S.A. DE C.V." rfc="FHU750301AR6">
<Domicilio calle="CALLE " noExterior="1 No. 140MEDIO KILO" colonia="RANCHO MEDIO KILO" codigoPostal="20350" estado="AGS" localidad="SAN FRANCISCO DE LOS ROMO" municipio="SAN FRANCISCO DE LOS ROMO" pais="MEX"/>
</Receptor>
<Conceptos>
<Concepto cantidad="6" descripcion="CONECTOR RECTO P/SAPA DE 19 mm" importe="26.94" unidad="Pieza" valorUnitario="4.49"/>
<Concepto cantidad="6" descripcion="CONECTOR CURVO P/SAPA DE 19 mm" importe="57.66" unidad="Pieza" valorUnitario="9.61"/>
<Concepto cantidad="6" descripcion="CONECTOR RECTO LIQUID TIGHT DE 25 mm" importe="129.36" unidad="Pieza" valorUnitario="21.56"/>
<Concepto cantidad="6" descripcion="CONECTOR CURVO LIQUID TIGHT DE 25 mm" importe="194.04" unidad="Pieza" valorUnitario="32.34"/>
<Concepto cantidad="6" descripcion="TUBO LIQUID TIGHT DE 13 mm CARRETE 350 MTS" importe="75.78" unidad="Metro" valorUnitario="12.63"/>
<Concepto cantidad="6" descripcion="CONECTOR RECTO LIQUID TIGHT DE 13 mm" importe="60.66" unidad="Pieza" valorUnitario="10.11"/>
<Concepto cantidad="6" descripcion="CONECTOR CURVO LIQUID TIGHT DE 13 mm" importe="97.32" unidad="Pieza" valorUnitario="16.22"/>
<Concepto cantidad="10" descripcion="CONDULET T-29 19 mm SERIE 9 C/TAPA DOMEX" importe="325.8" unidad="Pieza" valorUnitario="32.58"/>
<Concepto cantidad="5" descripcion="CONDULET 13 mm LL-19 SERIE 9 C/TAPA CROUSE HINDS" importe="117.45" unidad="Pieza" valorUnitario="23.49"/>
<Concepto cantidad="5" descripcion="CONDULET 13 mm LR-19 SERIE 9 C/TAPA DOMEX" importe="117.45" unidad="Pieza" valorUnitario="23.49"/>
<Concepto cantidad="5" descripcion="CONDULET 25 mm LR-39 SERIE 9 C/TAPA DOMEX" importe="193.25" unidad="Pieza" valorUnitario="38.65"/>
<Concepto cantidad="5" descripcion="CONDULET 25 mm LL-39 SERIE 9 C/TAPA CROUSE HINDS" importe="193.25" unidad="Pieza" valorUnitario="38.65"/>
<Concepto cantidad="1" descripcion="CONDULET T-39 25 mm SERIE 9 C/TAPA DOMEX" importe="43.19" unidad="Pieza" valorUnitario="43.19"/>
<Concepto cantidad="1" descripcion="CONTACTO DE CAJA P/PISO 4 UNIDADES SC3092" importe="351.65" unidad="Pieza" valorUnitario="351.65"/>
<Concepto cantidad="6" descripcion="MONITOR GALVANIZADO DE 13 mm" importe="8.34" unidad="Pieza" valorUnitario="1.39"/>
<Concepto cantidad="6" descripcion="MONITOR GALVANIZADO DE 19 mm" importe="12.24" unidad="Pieza" valorUnitario="2.04"/>
<Concepto cantidad="6" descripcion="MONITOR GALVANIZADO DE 25 mm" importe="17.16" unidad="Pieza" valorUnitario="2.86"/>
<Concepto cantidad="6" descripcion="MONITOR GALVANIZADO DE 51 mm" importe="55.38" unidad="Pieza" valorUnitario="9.23"/>
<Concepto cantidad="1" descripcion="INT.TERM. 2 POLOS 15A CLASE 730 QO215 SQUARE D" importe="176.17" unidad="Pieza" valorUnitario="176.17"/>
<Concepto cantidad="4" descripcion="REDUCCION DE 25 A 19mm" importe="36.88" unidad="Pieza" valorUnitario="9.22"/>
</Conceptos>
<Impuestos>
<Traslados>
<Traslado importe="343.5" tasa="15.0" impuesto="IVA"/>
</Traslados>
</Impuestos>
</Comprobante>



And Here is my XSL File


<?xml version="1.0" encoding="UTF-8" ?>

<!-- New document created with EditiX at Mon Nov 03 15:37:32 CST 2008 -->


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="Comprobante">
<fo:root>

<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body region-name="cuerpo" margin-top="8cm" margin-left="1cm" margin-right="1cm" margin-bottom="2cm"/>
<fo:region-before region-name="encabezado" extent="8cm" />
<fo:region-after region-name="piepagina" extent="1cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:static-content flow-name="encabezado" >

<xsl:apply-templates select="Emisor"/>
<fo:block space-after.optimum="40pt"><xsl:apply-templates select="Receptor"/> </fo:block>
</fo:static-content>
<fo:static-content flow-name="piepagina">
<fo:block margin-left="1cm" font-size="10pt" >Página <fo:page-number/></fo:block>
</fo:static-content>

<fo:flow flow-name="cuerpo">
<fo:block>
<fo:block space-after.optimum="50pt"><xsl:apply-templates select="Conceptos"/></fo:block>
</fo:block>
<fo:table space-after.optimum="50pt">
<fo:table-column column-width="14.5cm"/>
<fo:table-column column-width="1.83cm"/>
<fo:table-column column-width="2.5cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell >
<fo:block font-size="8pt" >"Debo(emos) y Pagare(mos) incondicionalmente por éste pagare a la orden de <xsl:value-of select="Emisor/@nombre"/> en la ciudad que se expide la presente, el importe de este documento."</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="8pt" color="white" text-align="center" font-weight="bold">SUBTOTAL:</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="8pt" text-align="center" font-weight="bold"><xsl:value-of select="./@subTotal"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt" >CANTIDAD CON LETRA</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="8pt" color="white" text-align="center" font-weight="bold">IVA 15%:</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="8pt" text-align="center" font-weight="bold"><xsl:value-of select="Impuestos/Traslados/Traslado/@importe"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt" ><xsl:value-of select="/Comprobante/Addenda/CantidadL/@valor"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="8pt" color="white" text-align="center" font-weight="bold">TOTAL:</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="8pt" text-align="center" font-weight="bold"><xsl:value-of select="./@total"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block font-size="10pt" text-align="start" start-indent="1cm" space-after.optimum="10pt" >
<fo:table >
<fo:table-column column-width="1cm" />
<fo:table-column column-width="15cm" />
<fo:table-body border-color="gray" >
<fo:table-row >
<fo:table-cell>
<fo:block font-size="8pt" text-align="start" start-indent="5pt" >Sello digital:</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="7pt" end-indent="10pt" ><xsl:value-of select="./@sello"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block font-size="8pt" text-align="center">"Este documento es una impresión de un Comprobante Fiscal Digital"</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="Emisor">
<fo:table margin-top="0.75cm" margin-left="1.5cm">
<fo:table-column column-width="2cm"/>
<fo:table-column column-width="12cm"/>
<fo:table-column column-width="3.5cm" />
<fo:table-body>
<fo:table-row>
<fo:table-cell >
<fo:block start-indent="0cm" >
<fo:external-graphic src="c:\FER\logo_gp.jpg" />
</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block font-size="18pt" color="#000099" text-align="center" font-weight="bold" margin-top="0.25cm" ><xsl:value-of select="./@nombre"/></fo:block>
<fo:block font-size="8pt" color="#000099" text-align="center" ><xsl:value-of select="DomicilioFiscal/@calle"/>, No. <xsl:value-of select="DomicilioFiscal/@noExterior"/> C.P.<xsl:value-of select="DomicilioFiscal/@codigoPostal"/>, <xsl:value-of select="DomicilioFiscal/@estado"/>,<xsl:value-of select="DomicilioFiscal/@municipio"/> ,<xsl:value-of select="DomicilioFiscal/@pais"/></fo:block>
<fo:block font-size="8pt" color="#000099" text-align="center" >TELS: (449) 914-45-14 al 17 FAX: (449) 914-37-99 R.F.C <xsl:value-of select="./@rfc"/></fo:block>
<fo:block font-size="8pt" color="#000099" text-align="center" >www.gpelectromecanica.com.mx email:gpventas@gpelectromecanica.com.mx</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block font-size="6pt" text-align="justify" space-after.optimum="3pt">PARA CUALQUIER DEVOLUCIÓN SE TENDRÁ UN PLAZO MÁXIMO DE 15 DIAS FECHA FACTURA</fo:block>
<fo:block font-size="7pt" text-align="center">Expedida en</fo:block>
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="ExpedidoEn/@estado"/>,<xsl:value-of select="ExpedidoEn/@municipio"/>.</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="Receptor">
<fo:table margin="1cm" >
<fo:table-column column-width="10cm" />
<fo:table-column column-width="4.5cm" />
<fo:table-column column-width="4.5cm" />
<fo:table-body border="solid" >
<fo:table-row>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center" >CLIENTE</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center">Serie</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center">Folio</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row >
<fo:table-cell>
<fo:block font-size="8pt"><xsl:value-of select="./@nombre"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center" ><xsl:value-of select="/Comprobante/@serie"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center"><xsl:value-of select="/Comprobante/@folio"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt">R.F.C. <xsl:value-of select="./@rfc"/></fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center" >Fecha y Hora</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center">No. Aprobación</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:apply-templates select="Domicilio"/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="Domicilio">
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt"><xsl:value-of select="./@calle"/> , <xsl:value-of select="./@noExterior"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center" ><xsl:value-of select="/Comprobante/@fecha"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center" ><xsl:value-of select="/Comprobante/@noAprobacion"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt"><xsl:value-of select="./@colonia"/> C.P.<xsl:value-of select="./@codigoPostal"/></fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center" >No. cliente</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#000099" border="solid">
<fo:block font-size="8pt" color="white" text-align="center" >Serie del Certificado</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="8pt" ><xsl:value-of select="./@referencia"/><xsl:value-of select="./@municipio"/> ,<xsl:value-of select="./@estado"/> ,<xsl:value-of select="./@pais"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center" ><xsl:value-of select="/Comprobante/Addenda/NoCte/@valor"/></fo:block>
</fo:table-cell>
<fo:table-cell border="solid">
<fo:block font-size="8pt" text-align="center" ><xsl:value-of select="/Comprobante/@noCertificado"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>

<xsl:template match="Conceptos">
<fo:table width="15cm" border="solid">
<fo:table-column column-width="0.75cm" />
<fo:table-column column-width="1.5cm" />
<fo:table-column column-width="2cm" />
<fo:table-column column-width="7cm" />
<fo:table-column column-width="1.5cm" />
<fo:table-column column-width="1.83cm" />
<fo:table-column column-width="1.83cm" />
<fo:table-column column-width="2.5cm" />
<fo:table-header border-color="gray">
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">P</fo:block>
</fo:table-cell>

<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">CLAVE</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">COD. PROV</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold" >DESCRIPCIÓN</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">UNIDAD</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">CANTIDAD</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">PRECIO U.</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" background-color="blue">
<fo:block font-size="7pt" color="white" text-align="center" font-weight="bold">IMPORTE</fo:block>
</fo:table-cell>
</fo:table-header>
<fo:table-body height="15cm" border-color="gray" >

<xsl:apply-templates select="Concepto"/>
<xsl:apply-templates select="Addenda/Codigo"/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="Addenda/Codigo">
<fo:table-row>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">1</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@Clave"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@CodProv"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="left"><xsl:value-of select="./@descripcion"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@unidad"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@cantidad"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">$<xsl:value-of select="./@valorUnitario"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">$<xsl:value-of select="./@importe"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="Concepto">
<fo:table-row>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">1</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">clave</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">cod prov</fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="left"><xsl:value-of select="./@descripcion"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@unidad"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center"><xsl:value-of select="./@cantidad"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">$<xsl:value-of select="./@valorUnitario"/></fo:block>
</fo:table-cell>
<fo:table-cell border-style="groove" border-color="gray">
<fo:block font-size="7pt" text-align="center">$<xsl:value-of select="./@importe"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>




Any help? I appreciate it


UnknownFacturaOK.xml
XML to transform

UnknownFacturas.xsl
XSL Transformation

Postnext
John BamptonSubject: XSL-FO XML to PDF with XSLT
Author: John Bampton
Date: 13 Mar 2009 01:21 AM
Hi, replace

<xsl:template match="Comprobante">

with <xsl:template match="/">

and then configure the other apply templates with the right xpaths

Thanks, John Bampton

Posttop
Fernando TorresSubject: XSL-FO XML to PDF with XSLT
Author: Fernando Torres
Date: 13 Mar 2009 01:21 PM
Can you put an example? please

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.