Trying to create a PDF file based on an XML and a file using XMLSpy.
I’m trying to split a field into two lines based on the field content.
For example, if my varialbe = “John Doe AKA Johnny D”, I want to view it like this :
John Doe
Johnny D
My problem is that I can’t make it work even with all the samples on the net.
Here’s my code :
<xsl:value-of disable-output-escaping="yes" select="concat(substring-before(//MyField,'AKA'),$newline,substring-after(//MyField,'AKA'))" />
</xsl:when>
So basically, eveytime I find the “AKA” string, I want to break the field into two lines.
So my code, finds the string, create the new variable but still shows in one line.
I’ve tried creating a variable with a blank line, using all kinds of techiniques but still shows in one line.
Any thoughts ?
See my answer here about using a hex entity reference and
linefeed-treatment.Edit
I took your code from the comments and put it in template in a sample XSLT stylesheet. The only thing I changed was:
newlinevariable to
.linefeed-treatment="preserve"to yourfo:block.Using a dummy XML file and the XSLT stylesheet, I produced an XSL-FO document that when rendered with FOP, produces “John Doe” and “Johnny D” on separate lines.
Here is the XML file:
Here is the XSLT stylesheet:
Here is the resulting XSL-FO:
The PDF is a single 8.5″ x 11″ page with this on it: