logoalt Hacker News

Linux-Fan05/03/20251 replyview on HN

Unlike Framesets I think XML includes were never really supported in many browsers (or even any major browsers)?

I still like to use them occasionally but it incurs a "compilation" step to evaluate them prior to handing the result of this compilation to the users/browsers.


Replies

LegionMammal97805/03/2025

As it happens, the major browsers still can do XML 'includes' to some extent, since by some miracle they haven't torn out their support for XSLT 1.0. E.g. this outputs "FizzBuzz" on Firefox:

  <!-- fizz.xml -->
  <?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="application/xslt+xml" href="style.xslt"?>
  <fizz>Fizz<buzz/></fizz>
  
  <!-- style.xslt -->
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="buzz">
      <xsl:value-of select="document('buzz.xml')"/>
    </xsl:template>
  </xsl:stylesheet>
  
  <!-- buzz.xml -->
  <?xml version="1.0" encoding="UTF-8"?>
  <buzz>Buzz</buzz>
You can even use XSLT for HTML5 output, if you're careful. But YMMV with which XML processors will support stylesheets.
show 2 replies