【问题标题】:Writting XSL-t in a XSL FO document在 XSL FO 文档中编写 XSLt
【发布时间】:2011-05-25 10:09:28
【问题描述】:

我是 XSL FO 的初学者。 我有一个非常简单的 XML 文档:

<?xml version= "1.0" ?>
<test>
TEST
</test>

我想打印标签&lt;test&gt;之间的内容

我编写了以下要由 FOP 处理的 XLS FO 文档。

<fo:root xmlns:yt="http://www.yseop.com/text/2" 
xmlns:y="http://www.yseop.com/engine/3" 
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


   <fo:layout-master-set>
      <fo:simple-page-master master-name="rapport">
         <fo:region-body margin-top="0.75in" margin-left="0.75in" margin-right="0.75in" margin-bottom="0.75in"/>
         <fo:region-after extent="0.25in"/>
         <fo:region-start/>
      </fo:simple-page-master>
   </fo:layout-master-set>

   <fo:page-sequence master-reference="rapport">

       <fo:flow flow-name="xsl-region-body">
            <fo:block>
            XXX
                <xsl:apply-templates select="document('D:\XXX-conseilVente\xmlBatch\input_test1.xml')/test"/>
            </fo:block>
      </fo:flow>
   </fo:page-sequence>



</fo:root>

我收到以下警告:

      [fop] 25 mai 2011 12:05:10 org.apache.fop.events.LoggingEventListener processEvent
      [fop] ATTENTION: Unknown formatting object "{http://www.w3.org/1999/XSL/Transform}apply-templates" encountered (a child of fo:block}. (See position 22:99)

我的输出 pdf 中没有任何内容。

我想我没有使用正确的函数来使用 xsl-t 解析文档

你能告诉我要使用什么功能吗?

提前致谢

【问题讨论】:

    标签: xml xslt xsl-fo


    【解决方案1】:

    XSLT 和 XSL-FO 是两种不同的语言。基本上,它的工作方式与您目前所做的相反:FO 嵌入在 XSLT 样式表中,然后用于处理原始 XML 以创建 XSL-FO 文档(没有任何 XSLT)。它被扔给 XSL-FO 处理器来创建,例如 PDF。

        XSLT     processing
         |           |
    XML ---> XSL-FO ---> PDF
    

    所以你从一个这样的 XSLT 样式表开始(没有命名空间之类的,只是为了给你一个想法):

    <xslt:stylesheet>
    
      <xslt:template match="/">
        <fo:root>
          <!-- fo head -->
          <fo:page-sequence>
            <fo:flow>
              <xslt:apply-templates /> <!-- process the rest of the doc-->
            </fo:flow>
          </fo:page-sequence>
        </fo:root>
      </xslt:template>
    
      <xslt:template match="test">
        <fo:block>
          <xslt:value-of select="." />
        </fo:block>
      </xslt:template>
    
    </xslt:stylesheet>
    

    您可以在Dave Pawson's XSL FAQ 找到许多问题。

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      相关资源
      最近更新 更多