title: correct syntax for an xslt transform
body: <p>here is my code, I am getting an error when I try and parse my xml and xslt file- however I just want to know if my syntax/ code is correct for the transform. I am getting an exception with something like - Page\r\n</p>
  
  <p>Using Visual studio when I manaully test the xslt transform everything works...</p>
  
  <pre><code>var XslFo = XElementPassedInAsAParamOrSomething;
  
                  //load the xsl
                  XslCompiledTransform xslTrans = new XslCompiledTransform();
                  using (XmlReader reader = XslFo.CreateReader())
                  {
                      xslTrans.Load(reader);
                  }
  
                  //create the output stream
                  MemoryStream result = new MemoryStream();
  
                  //do the actual transform of xml
                  using (XmlReader reader = XmlData.CreateReader())
                  {
                      xslTrans.Transform(reader, null, result);
                  }
  
                  //return result as XElement (for dumping  db etc)
                  using (XmlReader reader = XmlReader.Create(result))
                  {
                      return XElement.Load(reader);
                  }
  </code></pre>
  
  <p>NOTE: My exception is "Root Element is missing".</p>
  
  <p>EDIT: Thanks Dimitri - I will need to check your code, however just for clarity I think it is best I provide my code:</p>
  
  <p>I am loading both my Xmls via Embedded resourse (if that does make any difference)</p>
  
  <p>Xml:</p>
  
  <pre><code>    &lt;html&gt;   
  &lt;head&gt;
          &lt;title&gt;Spanish Review Handbook&lt;/title&gt;   
  &lt;/head&gt;   
  &lt;body&gt;
          &lt;h3&gt;Introduction&lt;/h3&gt;
          &lt;p&gt;
            This handbook covers the major topics in Spanish, but is by
            no means complete.
          &lt;/p&gt;   
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>Xsl:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:fo="http://www.w3.org/1999/XSL/Format"
                      version="1.0"&gt;
  
        &lt;xsl:output method="xml" indent="yes"/&gt;
        &lt;xsl:variable name="pagewidth" select="21.5"/&gt;
        &lt;xsl:variable name="bodywidth" select="19"/&gt;
        &lt;xsl:template match="html"&gt;
          &lt;fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
  
        &lt;fo:layout-master-set&gt;
          &lt;fo:simple-page-master master-name="leftPage"
            page-height="27.9cm"
            page-width="{$pagewidth}cm"
            margin-left="1cm"
            margin-right="2cm"
            margin-top="1cm"
            margin-bottom="1cm"&gt;
            &lt;fo:region-before extent="1cm"/&gt;
            &lt;fo:region-after extent="1cm"/&gt;
            &lt;fo:region-body
              margin-top="1cm"
              margin-bottom="1cm" /&gt;
          &lt;/fo:simple-page-master&gt;
  
          &lt;fo:simple-page-master master-name="rightPage"
            page-height="27.9cm"
            page-width="{$pagewidth}cm"
            margin-left="2cm"
            margin-right="1cm"
            margin-top="0.5cm"
            margin-bottom="0.5cm"&gt;
            &lt;fo:region-before extent="1cm"/&gt;
            &lt;fo:region-after extent="1cm"/&gt;
            &lt;fo:region-body
              margin-top="1cm"
              margin-bottom="1cm" /&gt;
          &lt;/fo:simple-page-master&gt;
  
          &lt;!-- Set up the sequence of pages --&gt;
          &lt;fo:page-sequence-master master-name="contents"&gt;
            &lt;fo:repeatable-page-master-alternatives&gt;
              &lt;fo:conditional-page-master-reference
                master-name="leftPage"
                odd-or-even="odd"/&gt;
              &lt;fo:conditional-page-master-reference
                master-name="rightPage"
                odd-or-even="even"/&gt;
            &lt;/fo:repeatable-page-master-alternatives&gt;
          &lt;/fo:page-sequence-master&gt;
        &lt;/fo:layout-master-set&gt;
  
        &lt;fo:page-sequence master-name="contents" initial-page-number="1"&gt;
          &lt;xsl:apply-templates /&gt;
        &lt;/fo:page-sequence&gt;
      &lt;/fo:root&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="body"&gt;
      &lt;fo:flow flow-name="xsl-region-body"&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:flow&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="h3"&gt;
      &lt;fo:block font-size="14pt" font-weight="bold"
        space-before="6pt"&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:block&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="p"&gt;
      &lt;fo:block text-indent="1em"
        space-before="4pt" space-after="4pt"&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:block&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="b"&gt;
      &lt;fo:inline font-weight="bold"&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:inline&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="i"&gt;
      &lt;fo:inline font-style="italic"&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:inline&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>