Team,
I'm using XLST 2.0 to create MS Word documents from XML data. I'm working on creating a header and want to call in image file from a local directory to display our company logo. With the software I'm using, I am unable to use an MS Word Template to call. This is billing software and needs to create each MS word document on the fly each time a bill (using XML data) get's thrown at it.
I've searched this site extensively and tried a majority of the examples given to no avail. Any assistance or guidance would be greatly appreciated.
Here is the result of the header in the MS Word doc I want to create...
Here is my XSL for the header...
<xsl:stylesheet xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:kmf="http://www.kleinmundo.com/functions"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:tlr="http://www.elite.com/functions"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template name="XS_Header" xml:space="default">
<xsl:variable name="TW" select="1440" />
<xsl:variable name="image-dir" select="'/Images'" />
<w:sectPr>
<w:hdr w:type="first">
<w:tbl>
<xsl:variable name="Col1" select="2 * $TW" />
<xsl:variable name="Col2" select="5.5 * $TW" />
<w:tblPr>
<w:tblW w:w="0" w:type="dxa"/>
<w:tblCellMar>
<w:left w:w="0" w:type="dxa"/>
<w:right w:w="0" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="{$Col1}"/>
<w:gridCol w:w="{$Col2}"/>
</w:tblGrid>
<w:tr>
<w:trPr>
<w:cantSplit/>
<w:tblHeader/>
</w:trPr>
<!--LOGO COLUMN -->
<w:tc>
<w:tcPr>
<w:tcW w:w="{$Col1}" w:type="dxa"/>
<w:vAlign w:val="bottom"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:keepLines/>
</w:pPr>
<w:r>
<w:t>LOGO HERE</w:t>
</w:r>
</w:p>
</w:tc>
<!-- ADDRESS INFO COLUMN -->
<w:tc>
<w:tcPr>
<w:tcW w:w="{$Col2}" w:type="dxa"/>
<w:vAlign w:val="bottom"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:keepNext/>
<w:keepLines/>
<w:jc w:val="right" />
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="16" />
</w:rPr>
<w:t>Company Address | City, State ZIP | TEL 555.555.1234 | FAX 555.555.4321</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:sectPr>
<w:pgSz w:w="12240" w:h="15840" w:orient="portrait" w:code="1" />
<w:pgMar w:top="720" w:right="720" w:bottom="720" w:left="720" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" />
<w:titlePg />
<w:docGrid w:line-pitch="272" />
</w:sectPr>
</w:hdr>
<w:titlePg />
<w:hdr w:type="odd">
</w:hdr>
<w:ftr w:type="first">
<w:p>
<w:r>
<w:t />
</w:r>
</w:p>
</w:ftr>
<w:titlePg />
<w:ftr w:type="odd">
<w:p>
<w:r>
<w:t />
</w:r>
</w:p>
</w:ftr>
<w:pgNumType w:start="1" />
<w:cols w:space="720" />
</w:sectPr>
</xsl:template>
</xsl:stylesheet>
-Nick
Figured this one out on my own. Here's what I did.
I created a DOCX file with just the image in the body of document. I then created a bookmark with the image highlighted and named the bookmark "logo". I saved the DOCX file to C:\images\logo_template.docx
I then went into my XSLT file and called the DOCX file pointing to the bookmark as follows:
This tossed the image file into the generated MS Word file I'm compiling from my bill generating software.
Best Regards,
-Nick