How do I alter the XML DOM with javascript, when using XML+XSLT client side.
For example:

XML:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="example.xsl"?>
    <document>
      <foo>bar</foo>
    </document>

XSL:

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <head>
            <title>example</title>
            <script type="text/javascript">
              /* magic javascript that alters the foo-node to contain something else */
            </script>
          </head>
          <body>
            <p>Foo: <xsl:value-of select="foo" /></p>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>

I want that javascript to modify the XML DOM, NOT the HTML DOM!


How do I alter the XML DOM with javascript, when using XML+XSLT client side.
===

For example:

XML:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="example.xsl"?>
    <document>
      <foo>bar</foo>
    </document>

XSL:

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <head>
            <title>example</title>
            <script type="text/javascript">
              /* magic javascript that alters the foo-node to contain something else */
            </script>
          </head>
          <body>
            <p>Foo: <xsl:value-of select="foo" /></p>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>

I want that javascript to modify the XML DOM, NOT the HTML DOM!

