繁体   English   中英

使用XSLT 2.0显示目录中的图像

[英]Use XSLT 2.0 to display an image from a directory

球队,

我正在使用XLST 2.0从XML数据创建MS Word文档。 我正在创建标题,并希望从本地目录中调用图像文件以显示我们的公司徽标。 使用我正在使用的软件,我无法使用MS Word模板进行呼叫。 这是计费软件,每次扔帐单(使用XML数据)时,都需要即时创建每个MS Word文档。

我已经对该网站进行了广泛搜索,并尝试了大部分示例,但都没有用。 任何帮助或指导将不胜感激。

这是我要创建的MS Word文档中标头的结果...

在此处输入图片说明

这是我的XSL标头...

<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>

-缺口

我自己想了这个。 这就是我所做的。

我创建的DOCX文件仅包含文档正文中的图像。 然后,我创建了一个突出显示图像的书签,并将其命名为“ logo ”。 我将DOCX文件保存到C:\\ images \\ logo_template.docx

然后,我进入XSLT文件,并按如下所示调用指向书签的DOCX文件:

<w:p>
  <w:r>
    <w:t>
      ~INS~<xsl:value-of select"'C:\images\logo_template.docx|logo'" />~/INS~
    </w:t>
  </w:r>
</w:t>

这将图像文件扔到我正在从账单生成软件编译的生成的MS Word文件中。

最好的祝福,

-缺口

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM