Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
murrayju committed Jun 23, 2015
2 parents 5a5f0d8 + f75094d commit c96d8e0
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
25 changes: 16 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ env:
- secure: Nvi1f97+rXj7eW39Wu+YsCVPsLUSW+Zj3AiAgKpxY+vgy64Bw103982gdcbDPZfmhqIQSUYAE+LMuudD7zpnF89Ib0QP9aH2ksSMH5+tP7+MLhshqxd4PlJRNU5dqmknawIGUGDGfHCc6fXpp9CCHpfHy5GstKdCkh6LPegIqGxzp7UFhXeKCUcmCz2hFp0oB6vDtPJ8HCupCFkcQRM0rQetY7uZXfBdFZAAK4rtWgu2i09tTdYBCwn+iVrZjjTJvSixM/7ks5coFmkSmzr0UoiN2wxvYQanws8pg3zYiL65eJN46J1zu9UdTPLZ0gS9VmhPQbHHUkETjHYnT0ztqPlxc0K2BxQwkqLBdC/g7KQ3RQgOzsfbRlGQTTXlp1+AxXbRLhS+RSP+w9HFFffb8wc3SXd05NyEnFIuvxyy0qAQlw/6WxWHxC/zII0FacK5iC+9ZYe0RIEUnUQ7BczaJhFalUqn5IX5PMqwJ3c8b0YaXhe09QXd1eqC0CG69kCRbF8dzW7UE2dL94Lj7aGx4VWNc0gYcwr3d0jB1pyQqUyp6ETYqUTpIRsOOWJF7FpELqchMsOIJucfDLN2kh3+sYR4jjbPmry4bmLMekCVEEYtbBSdAd+XGLFwzwaKzBPNhxiTS211xGY9n2haytQ2sOHX7yoTJZ42Kn659QHPfi0=
- secure: Ta4d95k2C3TsLl8q7vZMmXgUBN77WHU6jZGGprPUztHiL9Pj/c3E5AvL7ypaL2lisL7a3dHqP2rriYgfmOv0ZGiUcn9Hsx+ButYWBucYU5sugYHglUb9LQnjJP22xJBTLFonLHPEs6MqzeKQSN056KlyY3s86dA3P5BfgIEUZAg/H/72+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SqZLasWSVC6LewrxoshyFXAkkV3Q2G2TY5BK3Y/6iovf/QLlu71v7ZDN0WIvCNoaRy4Otod9kRlhIsSo92b5X5hq48k/3E5ZrUYbQ2oZusETUt38ogI9SCbcR6FAKQLO7k4=
file: dist/*.zip
skip_cleanup: true
on:
repo: murrayju/xslt
tags: true
- provider: releases
file_glob: true
api_key:
secure: BK4uk/HK2vC8h46/GMkw8hN8IZheQu2f2DQ9gE/CTYZqe2uy3xwbcXCGrYFa2Cz7rWnfuP3Zm8w4e1z0LyXL3iptqmjvqEWxuoilLOhkjQaVbbkPbQUye/TxiW6RO4OB0GF09YopqT+sIDQdzJkyk5s/TvszbWGRMjU/Bfore3x2Z0EBtK9/2xCQyC6mo7WBrPGP8IAC0BhPCGGmM0R50ve56xdbxx8F1WzJRKBKZtztFa2Ql+GEk8Yn7rfHwfUmfasb5qYX7eGmMJQERiwMmBm8nVrg5dUt/itqyAjLtXE2xFSvp7kDs+HTIPd+8Uh93XGgREucXUK/+71nuN2oz84mhEXaSzSEGPNGHxiZGZ3Ihibv4eq/XJuR9TGijmo6mhPPgZuMEhtuJz41JSGPCwVyXA9/8ZIQRqdD12oJqoxWepMbuCPhkzQ1fQfkQu6WR4saUfK64JsJmcfxeQNU8kUXSdw+nmi65p/JixzQt/QnxHKJlQIoHV9Km0itCsVJfTxOZUYHBsV1fck37nL2Xe3zqiMBUBeZo68c0e+oSqZLasWSVC6LewrxoshyFXAkkV3Q2G2TY5BK3Y/6iovf/QLlu71v7ZDN0WIvCNoaRy4Otod9kRlhIsSo92b5X5hq48k/3E5ZrUYbQ2oZusETUt38ogI9SCbcR6FAKQLO7k4=
file: dist/*.zip
skip_cleanup: true
on:
repo: murrayju/xslt
tags: true
- provider: npm
email: murrayju@addpcs.com
api_key:
secure: pxKis/Q588HnyH8Nyrt1N3bCkmOQtudYIfZowVAIy6RQw6yN48vzmTj/D8RmGkJFdFgaz1ofOSgxjAoLr3qj2v7nUgWH323ixMtnAUISaydokE9gFdbjpg7bhxT3dNWwCCv0z3v02xHYWTTFKI1K/9U4guHdvnbSfciW5zjS8gkQ3QilysCB07ipFpXb9f4ZoKlI3+qa/32jiVdUPkIweMlLLXyUqR1PfYRsxpsPaYGRTDIXR5NU0uKJJnUB5qOImef1DociQ5Ahr+kyAP4K9Wnnys5Xe9on7M6k8ITWKbtlWfsbCXW/49oln0v5f/hTDrhTVyPr5bVX6y/whGHaEmWg0FrglYo6vzpL6jJckFyqlH+HKTSpqZZA2xIJGr+YyHJGX9WHXgXF1A44TTnmDqrWapeCYgrjyqp4KbnVZPWP47Bf1KVqp60dNQ3cYDrclgLlDsMlqLgfhj21lHZalUh8rYAPCr5medjNyzL8+3b0dguOo+5kbD+hRNxpgRE0tA9KTf2G5ZVp8f3WLmuZ4q3j9OlTaW8332wPAF7uh9tPIVjuC1vzoj3HKv7SZY5euJquCWwKVRe7ZqrR3+M0KPo9eiCXDyrCEcgC3mmNuD9MgPOI0ilivtK8oTe+llQHcDF0Te38SXzWlEaovdKukjbB+n+yuvTkcyh6IPtfIuE=
on:
repo: murrayju/xslt
tags: true
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ module.exports = function (grunt) {
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'Chrome',
'Firefox'
'Firefox',
'IE'
],

customLaunchers: {
Expand Down Expand Up @@ -280,8 +281,7 @@ module.exports = function (grunt) {
var browsers = _.union(_.keys(opts.customLaunchers), opts.browsers, [
'PhantomJS',
'Opera',
'Safari',
'IE'
'Safari'
]);
if (grunt.option('all-bs')) {
opts.browsers = _.filter(browsers, function (b) {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Several options are available to get started:
```js
options = {
fullDocument: false, // Is the output a complete document, or a fragment?
xmlHeaderInOutput: true,
cleanup: true, // false will disable all of the below options
removeDupNamespace: true,
removeDupAttrs: true,
Expand Down
13 changes: 11 additions & 2 deletions src/xslt.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
needsHeader = (str) -> isXml(str) && !hasXmlHeader(str)
xmlHeader = '<?xml version="1.0" ?>'
prependHeader = (str) -> xmlHeader + str
stripHeader = (str) -> str.replace(/\s*<\?xml[^<]+/, '')
activeXSupported = ActiveXObject? || 'ActiveXObject' of window

tryCreateActiveX = (objIds...) ->
Expand Down Expand Up @@ -83,7 +84,10 @@

docToStr = (doc) ->
return null unless doc?
xml = doc?.xml || new XMLSerializer?()?.serializeToString?(doc)
xml = if (typeof doc) == 'string'
doc
else
doc?.xml || new XMLSerializer?()?.serializeToString?(doc)
if xml?.indexOf?("<transformiix::result") >= 0
xml = xml.substring(xml.indexOf(">") + 1, xml.lastIndexOf("<"))
return xml
Expand Down Expand Up @@ -143,6 +147,7 @@

defaults =
fullDocument: false
xmlHeaderInOutput: true
cleanup: true
removeDupNamespace: true
removeDupAttrs: true
Expand All @@ -167,7 +172,7 @@
else
processor.transformToFragment(xmlDoc, document)
else if 'transformNode' of xmlDoc
return xmlDoc.transformNode(xsltDoc)
trans = xmlDoc.transformNode(xsltDoc)
else if activeXSupported
xslt = createXSLTemplate()
xslt.stylesheet = xsltDoc
Expand All @@ -178,6 +183,10 @@

outStr = docToStr(trans)
if opt.cleanup
outStr = if opt.xmlHeaderInOutput and needsHeader(outStr)
prependHeader(outStr)
else
stripHeader(outStr)
outStr = cleanupXmlNodes(outStr, opt)
outStr = stripRedundantNamespaces(outStr) if opt.removeDupNamespace
return outStr
Expand Down
1 change: 1 addition & 0 deletions test/data/hello.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" ?>
<doc>
<h1>Hello, World!</h1>
<div>from <i>An XSLT Programmer</i></div>
Expand Down
7 changes: 7 additions & 0 deletions test/karma/specs/xsltSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ define [
it 'can do a simple transform', ->
str = xslt(helloXml, helloXsl, {removeAllNamespaces: true})
util.xmlDiff(helloOutput, str, true)

it 'can strip xml header', ->
str = xslt(helloXml, helloXsl, {
removeAllNamespaces: true
xmlHeaderInOutput: false
})
util.xmlDiff(helloOutput.replace(/\s*<\?xml[^<]+/, ''), str, true)
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"major": 0,
"minor": 1,
"minor": 2,
"patch": 0
}

0 comments on commit c96d8e0

Please sign in to comment.