javascript - The processing instruction target matching "[xX][mM][lL]" is not allowed. XML error -
i have error :
error parsing /web-inf/includes/verdatosproyeccion.xhtml: error traced[line: 4302] processing instruction target matching "[xx][mm][ll]" not allowed.
i using code of same code of : http://jsfiddle.net/qxln3h86/. cuted code , past code.
my code looks :
<table id="tbl1"> <tr> <td>name</td> <td>birthday</td> <td>amount</td> <td>rebate (10%)</td> </tr> <tr> <td>smith</td> <td data-type="datetime" data-style="date" data-value="1980-03-23">mar 23 1980</td> <td data-type="number" data-style="currency" data-value="1234.56">$ 1,234.56</td> <td data-formula="=rc[-1]/10" data-type="number" data-style="currency">$ 123.45</td> </tr> <tr> <td>doe</td> <td data-type="datetime" data-style="date" data-value="1978-11-05">nov 05 1978</td> <td data-type="number" data-style="currency" data-value="2345.67">$ 2,345.67</td> <td data-formula="=rc[-1]/10" data-type="number" data-style="currency">$ 234.56</td> </tr> </table> <table id="tbl2"> <tr> <td>product</td> <td>price</td> <td>available</td> <td>count</td> </tr> <tr> <td>bred</td> <td data-type="number" data-style="currency" data-value="1.89">$ 1.89</td> <td data-type="boolean" data-value="1">yes</td> <td data-type="number" data-value="123">123</td> </tr> <tr> <td>butter</td> <td data-type="number" data-style="currency" data-value=".89">$ .89</td> <td data-type="boolean" data-value="0">no</td> <td data-type="number" data-value="0">0</td> </tr> </table> <button onclick="tablestoexcel(['tbl1','tbl2'], ['customers','products'], 'testbook.xls', 'excel')">export excel</button> </h:panelgroup> <script> function exportarexcel(){ $("#tableproyeccion").table2excel({ exclude: ".excludethisclass", name: "worksheet name", filename: "proyeccion" //do not include extension }); } </script> <script> var tablestoexcel = (function() { var uri = 'data:application/vnd.ms-excel;base64,' , tmplworkbookxml ='<?xml version="1.0"?><?mso-application progid="excel.sheet"?><workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">' + '<documentproperties xmlns="urn:schemas-microsoft-com:office:office"><author>axel richter</author><created>{created}</created></documentproperties>' + '<styles>' + '<style ss:id="currency"><numberformat ss:format="currency"></numberformat></style>' + '<style ss:id="date"><numberformat ss:format="medium date"></numberformat></style>' + '</styles>' + '{worksheets}</workbook>' , tmplworksheetxml = '<worksheet ss:name="{namews}"><table>{rows}</table></worksheet>' , tmplcellxml = '<cell{attributestyleid}{attributeformula}><data ss:type="{nametype}">{data}</data></cell>' , base64 = function(s) { return window.btoa(unescape(encodeuricomponent(s))) } , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } return function(tables, wsnames, wbname, appname) { var ctx = ""; var workbookxml = ""; var worksheetsxml = ""; var rowsxml = ""; (var = 0; < tables.length; i++) { if (!tables[i].nodetype) tables[i] = document.getelementbyid(tables[i]); (var j = 0; j < tables[i].rows.length; j++) { rowsxml += '<row>' (var k = 0; k < tables[i].rows[j].cells.length; k++) { var datatype = tables[i].rows[j].cells[k].getattribute("data-type"); var datastyle = tables[i].rows[j].cells[k].getattribute("data-style"); var datavalue = tables[i].rows[j].cells[k].getattribute("data-value"); datavalue = (datavalue)?datavalue:tables[i].rows[j].cells[k].innerhtml; var dataformula = tables[i].rows[j].cells[k].getattribute("data-formula"); dataformula = (dataformula)?dataformula:(appname=='calc' && datatype=='datetime')?datavalue:null; ctx = { attributestyleid: (datastyle=='currency' || datastyle=='date')?' ss:styleid="'+datastyle+'"':'' , nametype: (datatype=='number' || datatype=='datetime' || datatype=='boolean' || datatype=='error')?datatype:'string' , data: (dataformula)?'':datavalue , attributeformula: (dataformula)?' ss:formula="'+dataformula+'"':'' }; rowsxml += format(tmplcellxml, ctx); } rowsxml += '</row>' } ctx = {rows: rowsxml, namews: wsnames[i] || 'sheet' + i}; worksheetsxml += format(tmplworksheetxml, ctx); rowsxml = ""; } ctx = {created: (new date()).gettime(), worksheets: worksheetsxml}; workbookxml = format(tmplworkbookxml, ctx); console.log(workbookxml); var link = document.createelement("a"); link.href = uri + base64(workbookxml); link.download = wbname || 'workbook.xls'; link.target = '_blank'; document.body.appendchild(link); link.click(); document.body.removechild(link); } })(); </script>
trying wrapping code within script
cdata
:
<script> //<![cdata[ ...code containing xml declaration (`<?xml version="1.0"?>`) //]]> </script>
so xml declaration isn't interpreted part of enclosing document. xml declarations can appear @ top of xml document (and there can 1 of them @ most).
if doesn't resolve problem, examine you're outputting xml declaration. make sure there no visible or invisible content ahead of xml declaration, , make sure there not multiple xml declarations in output. more details see:
- are multiple xml declarations in document well-formed xml?
- the key causes , resolutions of error,
the processing instruction target matching "\[xx\]\[mm\]\[ll\]" not allowed.
Comments
Post a Comment