kristian / minify-xml

Fast XML minifier / compressor / uglifier with a command-line
Other
17 stars 5 forks source link

Remove standalone attribute when no external markup declarations are used. #23

Closed sdavids closed 1 year ago

sdavids commented 1 year ago
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://test.com/index.html</loc>
    <lastmod>2023-10-28T18:30:00Z</lastmod>
  </url>
</urlset>

could be minified to:

<?xml version="1.0" encoding="UTF-8">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://test.com/index.html</loc>
    <lastmod>2023-10-28T18:30:00Z</lastmod>
  </url>
</urlset>

https://www.w3.org/TR/xml/#sec-rmd

If there are no external markup declarations, the standalone document declaration has no meaning.

https://stackoverflow.com/questions/5578645/what-does-the-standalone-directive-mean-in-xml

kristian commented 1 year ago

Good one! If even the W3C spec. defines it as "has no meaning", it can be safely added to minify-xml 👍

Let me see what I can do in the afternoon. 💯

kristian commented 1 year ago

Added by bb3466c3f4e93890f1d80534dc246536311e4e97

sdavids commented 1 year ago

I verified my use case with 4.2.0, thanks!