Re: How do I style an embedded <strong> in the text from the XML input?

Andreas Reichel <[email protected]>
Newsgroups gmane.text.xml.fop.user
Organization manticore-projects Co. Ltd.
Message-ID <07f48021343021229165f410d4ceb1b4143e847e.camel@manticore-projects.com>
Hi Markus.

I have done something similar, under the following assumptions:

1) the node "text" contains HTML 3.2 formatted text with tags like
<strong>, <b>, <emp> <color>
2) inside the XSL I call a xhtml2fo.xsl like this:

<xsl:include href="com/manticore/profit/xsl/xhtml2fo.xsl"/>

<fo:block linefeed-treatment="preserve" white-space-collapse="false">
   <xsl:apply-templates select="description"/>
</fo:block>

("description" is my equivalent of your "text" node).

Attention: when you want to deploy xhtml2fo.xsl inside your JAR, you
will need to hand over an URL resolver to FOP:
        // Setup XSLT
        TransformerFactory factory = TransformerFactory.newInstance();
//        factory.setURIResolver(
//                new URIResolver() {
//                    @Override
//                    public Source resolve(String href, String base) throws TransformerException {
//                        return new StreamSource(ETLBox.class.getClassLoader().getResourceAsStream(href));
//                    }
//                });

I have the xhtml2fo.xsl, maybe it will help you.
Cheers
Andreas

On Mon, 2022-09-19 at 16:37 +0200, mailinglists wrote:
> I have the following XML (just a snippet, but should be enough).
>  There is exactly one <xsl-template> matching the root. Everything is
> taken from there. A document can contain many sections and a section
> can contain many textblocks.
> 
> Note: in the example given the section/textblocks/textblock/text
> contains <strong>...</strong>
> 
> <sections>
> <section>
> <sectionTitle>
> Contract Validity
> </sectionTitle>
> 
> <textBlocks>
> 
> <textblock>
> <text>This contract is valid for a
> period of <strong>18 months</strong> and the .... be 7,400.00.</text>
> </textblock>
> 
> </textBlocks>
> 
> <accepted>false</accepted>
> 
> <acceptanceText>
> I certify I have ... agree to the above.
> </acceptanceText>
> 
> </section>
> </sections>
> 
> and the respective fragment from the XSL
> 
> <xsl:for-each select="sections/section">
> <fo:block space-after="0.7em" text-
> decoration="underline">
>                 <xsl:value-of select="sectionTitle"/>
>                 </fo:block>
> 
>                 <xsl:for-each select="textBlocks/textblock">
>                 <fo:block space-after="0.7em">
> <xsl:value-of select="text"/>
> </fo:block>
> </xsl:for-each>
> </xsl:for-each>
> 
> How can I replace the <strong> by the proper <fo:font-weight=“bold”>
> tags during processing?
> 
> I have been reading up on xsl:apply-templates but have only been
> successful to *additionally* show the text “18 months” in bold either
> before or after the selected text, but never replacing the
> "<strong>18 months</strong>” inline by bolded text. However I was
> able to get rid of the strong-tags so that the text in the PDF just
> read “...period of 18 months and the...” without any visible
> boldness.
> 
> Thanks a lot
> ---markus---
> 
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
xhtml2fo.xsl (application/xslt+xml, 25.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.