0

I'm tring to transform an xsl:fo into xslt (for HTML output). Then, I would apply xslt instead of xsl:fo obtaining the HTML output instead of a PDF.

How can do this?

I need API for XML Processing, or JAXP that transforms XML and XSL to another output. So, I tried to write the xslt template:

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

I obtain something like

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

But it delete all xsl:choose xsl:when and other tags like I need all these tags because i need to pass xml data in second pass using Jaxp and producing html.. I would obtain

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

How can get the XSL nodes like text node?

AstroCB
  • 12,337
  • 20
  • 57
  • 73
robyp7
  • 481
  • 2
  • 7
  • 25
  • Just to be clear ... I believe you are trying to create an XSL that would convert an XSL designed to produce XSL FO into an XSL that will produce HTML, correct? Meaning you want to map all the constructs like fo:block to p and fo:table to table and so on? – Kevin Brown Mar 31 '15 at 03:53
  • You don't have access to the XML that was used as the input for the FO transformation? If you do, that would be an easier starting point. – Hobbes Apr 02 '15 at 09:53

2 Answers2

1

If you want to use XSLT to output XSLT elements (i.e. elements in the XSLT namespace) then you need to use a namespace alias as shown in 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>
Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
0

i put xsl: code between < ! CDATA [... ] ] >

anyway using another namespace

robyp7
  • 481
  • 2
  • 7
  • 25