Created
May 30, 2022 14:50
-
-
Save troelskn/db169d70cdd5f1582fd0406c944bd865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
document = Nokogiri::XML.parse(STDIN.read) { |c| c.noent.nonet.strict } | |
xsl =<<XSL | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml" encoding="UTF-8" indent="yes" /> | |
<xsl:strip-space elements="*" /> | |
<xsl:template match="/"> | |
<xsl:copy-of select="." /> | |
</xsl:template> | |
</xsl:stylesheet> | |
XSL | |
xslt = Nokogiri::XSLT(xsl) | |
xml = xslt.transform(document).to_xml(indent: 2) | |
puts Nokogiri::XML.parse(xml) { |c| c.noent.nonet.strict }.canonicalize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment