title: Using jQuery to Update XML Doc and Perform XSLT
body: <p>I'm writing a small web app to display mail server settings to my users.  They input their email address, submit the form, and it should return the correct settings.</p>
  
  <p>The tools I'm using are XML + XSL for the UI, and jQuery to handle the data retrieval.  Initially, my application has no context so the XML data is not available.  I just load a basic XML document linked to my XSL stylesheet to show the user the form.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="mail-settings.xsl" ?&gt;
  &lt;Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006"&gt;
      &lt;Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"&gt;
          &lt;Account/&gt;
      &lt;/Response&gt;
  &lt;/Autodiscover&gt;
  </code></pre>
  
  <p>When the form is submitted, the jQuery ajax call fetches the account settings as XML.  What I want to do after I get the response is to update the current document to include the Account info and then have the XSL stylesheet update the page.</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "https://myfooserver.com/maildata.xml", //actually points to a wsgi app that returns XML
      data: xml_request,
      dataType: "xml",
      async: false,
      success: function(account_data){
          $( "Account" ).replaceWith(account_data);
      },  
      error: function (request, status, error){
          alert("Error handler request.responseText: " + request.responseText);
      }   
  }); 
  </code></pre>
  
  <p>But as I'm discovering, nothing is "refreshing" the XSL transformation after I modify the DOM.</p>
  
  <p>Other options I've thought of include:</p>
  
  <ul>
  <li>Instead of depending on XSLT after the $.ajax call, I could just parse the XML returned and manually emit HTML table rows (yuck).</li>
  <li>Do a POST without Ajax and fetch the transformed XML with the account data included</li>
  </ul>
  
  <p>I was hoping there was some way I could update the XML dynamically on the client side to have the settings appear, as HTML using XML + XSLT. Any thoughts on getting my preferred solution to work?</p>