Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Formatting texts with XSL FO

I have the following xml:

    <text>Lorem Ipsum is simply dummy <link>text of the printing</link> and typesetting
 industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </text>

I need to display the text in order and format the link. I also want to add a new line at the end of text.

Here is my xsl:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<xsl:template match="text">
        <xsl:value-of select="."/>
        <xsl:apply-templates select="link"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

    <xsl:template match="link">
        <fo:basic-link color="red" text-decoration="underline" external-destination="{whatever}">
            <xsl:value-of select="whatever"/>
        </fo:basic-link>
    </xsl:template>

With this code, i’m printing the links in place but not formated. Then at the end of the text all links are printed accordingly. Also the new line is not being printed.

>Solution :

Try

<xsl:template match="text">
  <fo:block>
        <xsl:apply-templates/>
        <xsl:text>&#10;</xsl:text>
  </fo:block>
</xsl:template>

<xsl:template match="link">
    <fo:basic-link color="red" text-decoration="underline" external-destination="{whatever}">
        <xsl:value-of select="whatever"/>
    </fo:basic-link>
</xsl:template>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading