Vazid
Vazid

Reputation: 803

How to use 'white-space' property in fop xsl-fo?

I am using FOP 2.2 in order to generate pdf file from xml documents. FOP documentation is here http://xmlgraphics.apache.org/fop/

The pdf document is generated fine. However, I keep on getting this ERROR message.

    ERROR: Invalid property value encountered in white-space="pre-wrap": org.apache.fop.fo.expr.PropertyException: null:118:-1: No conversion defined pre-wrap; property:'white-space' (See position 119:-1)
org.apache.fop.fo.expr.PropertyException: null:118:-1: No conversion defined pre-wrap; property:'white-space'
    at org.apache.fop.fo.properties.PropertyMaker.make(PropertyMaker.java:446)
    at org.apache.fop.fo.PropertyList.convertAttributeToProperty(PropertyList.java:499)
    at org.apache.fop.fo.PropertyList.addAttributesToList(PropertyList.java:386)
    at org.apache.fop.fo.FObj.processNode(FObj.java:124)
    at org.apache.fop.fo.flow.table.TableFObj.processNode(TableFObj.java:232)
    at org.apache.fop.fo.flow.table.TableRow.processNode(TableRow.java:82)
    at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:291)
    at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:179)
    at net.sf.saxon.event.ContentHandlerProxy.startContent(ContentHandlerProxy.java:252)
    at net.sf.saxon.event.ProxyReceiver.startContent(ProxyReceiver.java:169)
    at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:187)
    at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:195)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:262)
    at net.sf.saxon.event.Sender.send(Sender.java:128)
    at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:28)

xsl template has the below code:

<xsl:attribute name="style">
    <xsl:text>white-space: pre-wrap;</xsl:text>
</xsl:attribute>

Upvotes: 2

Views: 1461

Answers (1)

lfurini
lfurini

Reputation: 3778

(I guess you are converting HTML to XSL-FO using XSLT, as style is not a valid FO attribute)

The error message is telling you that pre-wrap is not a valid value for the property white-space; the only allowed values are normal, pre and nowrap.

However, in XSL-FO white-space is just a "shorthand property" to quickly control a set of whitespace-related properties, so you should be able to achieve the desired result directly setting those properties instead:

linefeed-treatment="preserve" 
white-space-collapse="false" 
white-space-treatment="preserve"

Upvotes: 1

Related Questions