title: Link XML and XSLT files in an HTML file
body: <p>I am still learning how to use XML and XSL to create an HTML output file and have improved a lot thanks to stackoverflow.</p>
  
  <p>I have an XML file that is auto generated but I cannot tell the XML file where the XSLT file is every time a new XML is created.<br>
  Is there a way to create an HTML file that when a user opens it, the HTML will "href" to the XML and XSLT and output it as the intended HTML result, in the same way a CSS or Javascript is included in an HTML.</p>
  
  <p>Thank you,
  Robin</p>
  
  <p>This is the XML file when it is generated from a program we use...</p>
  
  <pre><code>&lt;Root&gt;
  &lt;Ticket&gt;
  &lt;TicketStart Date="2012-10-22" /&gt;
  &lt;Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="0" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="0" Date="2012-10-22" /&gt;
  &lt;ClubcardPoints Opcode="96" Function="28" SchemeNo="40" PromNo="0" CardNo="1042540000026" QualSpend="30005" PointSpend="0" Points="6" BonusPoints="0" PromCount="0" Date="2012-10-22" /&gt;
  &lt;Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="1" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="30005" Date="2012-10-22" /&gt;
  &lt;TicketEnd Date="2012-10-22" /&gt;
  &lt;/Ticket&gt;
  &lt;Ticket&gt;
  &lt;TicketStart Date="2012-10-22" /&gt;
  &lt;TicketEnd Date="2012-10-22" /&gt;
  &lt;/Ticket&gt;
  &lt;Events&gt;
  &lt;/Events&gt;
  &lt;Ticket&gt;
  &lt;TicketStart Date="2012-10-22" /&gt;
  &lt;Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="0" SchemeNo="40" CardNo="1042540000057" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="0" Date="2012-10-22" /&gt;
  &lt;ClubcardPoints Opcode="96" Function="28" SchemeNo="40" PromNo="0" CardNo="1042540000057" QualSpend="18025" PointSpend="0" Points="3" BonusPoints="0" PromCount="0" Date="2012-10-22" /&gt;
  &lt;Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="1" SchemeNo="40" CardNo="1042540000057" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="18025" Date="2012-10-22" /&gt;
  &lt;TicketEnd Date="2012-10-22" /&gt;
  &lt;/Ticket&gt;
  &lt;Events&gt;
  &lt;/Events&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>and currently I have to put this at the start of the XML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;?xml-stylesheet type="text/xsl" href="XSLnice.xsl"?&gt;
  </code></pre>
  
  <p>The XSL file looks like this...</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:output method="html"/&gt;
    &lt;xsl:template match="/"&gt;
      &lt;html&gt;
        &lt;head&gt;
      &lt;title&gt;StoreLine Loyalty Sales&lt;/title&gt;
        &lt;/head&gt;
      &lt;body&gt;
        &lt;br/&gt;
        &lt;br/&gt;
        &lt;br/&gt;
         &lt;b&gt;Loyal Customers&lt;/b&gt;
        &lt;br/&gt;
        &lt;br/&gt;
      &lt;table width="100%" border="3"&gt;
        &lt;THEAD&gt;
        &lt;TR bgcolor="RGB(0, 204, 51)"&gt;
        &lt;TD width="25%"&gt;
          &lt;font color="white"&gt;&lt;B&gt;Account Number&lt;/B&gt;&lt;/font&gt;
        &lt;/TD&gt;
        &lt;TD width="25%"&gt;
          &lt;font color="white"&gt;&lt;B&gt;Points&lt;/B&gt;&lt;/font&gt;
        &lt;/TD&gt;
        &lt;TD width="25%"&gt;
          &lt;font color="white"&gt;&lt;B&gt;Date&lt;/B&gt;&lt;/font&gt;
        &lt;/TD&gt;
        &lt;TD width="25%"&gt;
          &lt;font color="white"&gt;&lt;B&gt;Qualified Spent&lt;/B&gt;&lt;/font&gt;
        &lt;/TD&gt;
        &lt;/TR&gt;
        &lt;/THEAD&gt;
      &lt;TBODY&gt;
      &lt;xsl:for-each select="Root/Ticket/ClubcardPoints"&gt;
        &lt;TR&gt;
        &lt;TD width="25%"&gt;&lt;xsl:value-of select="@CardNo" /&gt;&lt;/TD&gt;
        &lt;TD width="25%"&gt;&lt;xsl:value-of select="@Points" /&gt;&lt;/TD&gt;
        &lt;TD width="25%"&gt;&lt;xsl:value-of select="@Date" /&gt;&lt;/TD&gt;
        &lt;TD width="25%"&gt;&lt;xsl:value-of select="format-number(@QualSpend div 100,'&amp;#x52;#.##')" /&gt;&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;/xsl:for-each&gt;
      &lt;/TBODY&gt;
      &lt;/table&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>With these files in the same folder, I double click the XML file and it presents me with a friendly report of the values I need in the XML. So rather if I could just double-click one HTML file and everytime a new XML is placed in the same folder, the HTML will find the XML and use the XSL as the style-sheet to present itself. Instead of having to manually update the XML everytime and tell it to use the XSL.</p>
  
  <p>Also I have tried but unsuccessfully group the 'CardNo' and report how many times it was used, how much in total 'Points' were earned and how much was the 'qualified amount'. Instead of this long list of entries, like a consolidated report.</p>
  
  <p>Thank you so much... </p>
  
  <p>Here is the preferred output file...</p>
  
  <pre><code>&lt;THEAD&gt;
                  &lt;TR bgcolor="RGB(0, 204, 51)"&gt;
                      &lt;TD width="25%"&gt;&lt;font color="white"&gt;&lt;B&gt;Account Number&lt;/B&gt;&lt;/font&gt;&lt;/TD&gt;
                      &lt;TD width="25%"&gt;&lt;font color="white"&gt;&lt;B&gt;Total Points&lt;/B&gt;&lt;/font&gt;&lt;/TD&gt;
                      &lt;TD width="25%"&gt;&lt;font color="white"&gt;&lt;B&gt;Date&lt;/B&gt;&lt;/font&gt;&lt;/TD&gt;
                      &lt;TD width="25%"&gt;&lt;font color="white"&gt;&lt;B&gt;Total Qualified Spent&lt;/B&gt;&lt;/font&gt;&lt;/TD&gt;
                  &lt;/TR&gt;
              &lt;/THEAD&gt;
              &lt;TBODY&gt;
                  &lt;TR&gt;
                      &lt;TD width="25%"&gt;1042540000002&lt;/TD&gt;
                      &lt;TD width="25%"&gt;100&lt;/TD&gt;
                      &lt;TD width="25%"&gt;2012-10-22&lt;/TD&gt;
                      &lt;TD width="25%"&gt;R750.32&lt;/TD&gt;
                  &lt;/TR&gt;
  </code></pre>