What is the difference between XslCompiledTransform for Word 2007 and 2010?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Michele Tedesco
    New Member
    • Nov 2010
    • 1

    #1

    What is the difference between XslCompiledTransform for Word 2007 and 2010?

    Hi!
    I have configured and programmed and InfoPath-form (2010), which programmaticall y creates a Word 2010 docx file.

    I use XslCompiledTran sform in the code behind of the infopath file and the XSLT was created out of the /word/document.xml file included in the root-Word-document.
    I followed this instructions <<http://www.bizsupporto nline.net/infopath2007/convert-infopath-form-into-word-2007-document-xslt-c-sharp.htm>> to create the XSLT.

    When I create the docx file I get the message <<The file ABC can not be opened because there are problems with the contents.>>
    After checking the transformed document.xml of the docx file, I could detect that at the end of the file the transformation had a "stream writing" problem. Because there are about 200-400 characters that are repeated.
    Here an example:
    Code:
    <w:docGrid w:linePitch="360"/>
            </w:sectPr>
          </w:body>
        </w:document>
      </xsl:template>
    </xsl:stylesheet>nt>
      </xsl:template>
    </xsl:stylesheet>
    The tutorial I mentioned above requires Infopath 2007 and word 2007.

    Is the XslCompiledTran sform different for Word 2010?

    Thank you for your help!

    Ciaooo
    Michee

    ps: here a snippet of the code behind
    Code:
    Package packWordPrint = Package.Open(wordPrintFilePath, FileMode.Open, FileAccess.ReadWrite);
                PackagePart part = packWordPrint.GetPart(new Uri("/word/document.xml", UriKind.Relative));
                
                DataSource ds = this.DataSources[DataSrc];
                XslCompiledTransform trans = new XslCompiledTransform();
                trans.Load(ds.CreateNavigator());
    
    
                using (StreamWriter partStream = new StreamWriter(part.GetStream(FileMode.Open, FileAccess.Write)))
                {
                    // Transform the InfoPath form and save the XML into the stream for the part
                    trans.Transform(this.MainDataSource.CreateNavigator(), null, partStream);
    
                    // Close the stream of the part
                    partStream.Close();
                }
Working...