2015-03-30 66 views
0

我正在尝试将xsl:fo转换为xslt(用于HTML输出)。然后,我将应用xslt而不是xsl:fo获取HTML输出而不是PDF。从xsl生成html xslt:fo

这怎么办?

我需要XML处理API或将XML和XSL转换为另一个输出的JAXP。于是,我试着写的XSLT模板:

<xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo" 
> 

<xsl:template match="/xsl:template[@match='/root']/fo:root"> 
<xsl:apply-templates select="fo:page-sequence"/> 
</xsl:template> 

<xsl:template match="fo:page-sequence"> 

<xsl:for-each select="fo:flow[@flow-name='xsl-region-body']"> 
    <xsl:call-template name="xsl-regional-body"> 
      <xsl:with-param name="fontsize"><xsl:value-of select="@font-size"/></xsl:with-param> 
     </xsl:call-template> 
    </xsl:for-each> 
</xsl:template> 

<xsl:template name="xsl-regional-body"> 
    <xsl:param name="fontsize" /> 
    <body>  
     <xsl:if test="$fontsize"> <!-- costruisce <font size=""> --> 
      <font> 
      <xsl:attribute name="size"> 
       <xsl:value-of select="$fontsize"/> 
      </xsl:attribute> 
      </font> 
     </xsl:if> 
     <xsl:for-each select="*/xsl:choose"> 
       <xsl:call-template name="xsl-choose"/> 
     </xsl:for-each> 
     <xsl:apply-templates select="."/> 
    </body> 
</xsl:template> 

<xsl:template name="xsl-choose"> 
    <xsl:value-of select="."/> 
</xsl:template> 

我获得类似

 <body><font size="10pt"/> 
     ... 
     text words.. 
     </body> 

但它删除所有的xsl:选择XSL:当与其他标签,如 我需要所有这些标签,因为我需要传递xml数据,第二次使用Jaxp并生成html .. 我将获得

 <body><font size="10pt"/> 
     <xsl:choose> 
     <xsl:when test="ddx[@id='LET.....> 
      <xsl::value-of select="ddx[@id='Lx']/r/PE...> 
     </xsl:when>.. 
     </xsl:choose> 
     text words.. 
     </body> 

如何获取文本节点的XSL节点?

+0

只是要清楚......我相信你正在试图创造条件,设计制作XSL FO的XSL转换为XSL是将一个XSL生成HTML,更正?意思是你想映射所有的结构像fo:block到p和fo:table到table等等? – 2015-03-31 03:53:01

+0

您无权访问用作FO转换输入的XML?如果你这样做,那将是一个更简单的起点。 – Hobbes 2015-04-02 09:53:27

回答

1

如果你想使用XSLT输出XSLT元素(即元素在XSLT命名空间),那么你需要使用一个命名空间别名如图http://www.w3.org/TR/xslt#literal-result-element

<xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format" 
    xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"> 

<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> 

<xsl:template match="/"> 
    <axsl:stylesheet> 
    <xsl:apply-templates/> 
    </axsl:stylesheet> 
</xsl:template> 

<xsl:template match="block"> 
    <axsl:template match="{.}"> 
    <fo:block><axsl:apply-templates/></fo:block> 
    </axsl:template> 
</xsl:template> 

</xsl:stylesheet> 
0

我把XSL:代码<之间! CDATA [...]]>

反正使用另一个命名空间