X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/7d20ecc106db40a3c033bdc6260376628a24c0e2..f02b9f60518805daed701834903e4f8e82fee778:/platforma/static/js/xslt.js diff --git a/platforma/static/js/xslt.js b/platforma/static/js/xslt.js index 48543e6e..71a68598 100644 --- a/platforma/static/js/xslt.js +++ b/platforma/static/js/xslt.js @@ -168,8 +168,6 @@ function xml2html(options) { if (error.length > 0 && options.error) { options.error(error.text()); } else { - // console.log(options.xml); - console.log(doc, doc.firstChild); options.success(doc.firstChild); } }, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); @@ -183,18 +181,24 @@ function html2xml(options) { var serializer = new XMLSerializer(); var doc = parser.parseFromString(xml, 'text/xml'); var error = $('parsererror', doc.documentElement); - + if (error.length == 0) { - doc = html2xmlStylesheet.transformToDocument(doc, document); + doc = html2xmlStylesheet.transformToDocument(doc); error = $('parsererror', doc.documentElement); } if (error.length > 0 && options.error) { options.error(error.text()); - console.log(error); - $('#source-editor').html('
WystÄ piÅ bÅÄ d:
' + error.text()); } else { - options.success(serialize(doc.documentElement).join('')); + if (options.inner) { + var result = []; + for (var i = 0; i < doc.documentElement.childNodes.length; i++) { + result.push(serialize(doc.documentElement.childNodes[i]).join('')); + }; + options.success(result.join('')); + } else { + options.success(serialize(doc.documentElement).join('')); + } } }, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); };