Hacker News new | ask | show | jobs
by sergeykish 2166 days ago
XML:

    ...
    <counter xmlns="my" />
XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="my">
      ...
      <xsl:template match="//my:counter">
        <form>
          <button onclick="form.counter.value -= 1;return false">-</button>
          <input name="counter" value="0">
          <button onclick="form.counter.value = 1 + +form.counter.value;return false">+</button>
        </form>
      </xsl:template>
    </xsl:stylesheet>
XSLT looks ugly but only because we should not edit plain text XML (same for markup). <template> is a limited version of XSLT.