Hi everyone!
I'm trying to get a pdf file from my xml file using xsl-fo, but I have problems with linefeed treatment.
I put in my xsl file the next atributtes:
<fo:root linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
Well, now if I have an xml like this:
<DOCUMENT>
<TEXT>The first line
The second line</TEXT>
</DOCUMENT>
The linefeed are preserved correctly, but If my xml is like this other:
<DOCUMENT TEXT="The first Line
The second line" />
The linefeed are not preserved.
How can I preserve the linefeed using xsl-fo if my xml is like the second one???
Best regards! Thanks in advance
Problems with linefeed treatment
Hi,
Any XML parser that reads your document must normalize the attribute values, and will convert your new line character to space before that reaches the FOP. What you can do is to write the new line as a character entiry for instance:
<DOCUMENT TEXT="The first Line The second line" />
(not tested)
Best Regards,
George
Any XML parser that reads your document must normalize the attribute values, and will convert your new line character to space before that reaches the FOP. What you can do is to write the new line as a character entiry for instance:
<DOCUMENT TEXT="The first Line The second line" />
(not tested)
Best Regards,
George
Last edited by george on Mon Mar 13, 2006 5:01 pm, edited 1 time in total.
-
- Posts: 4
- Joined: Mon Mar 13, 2006 2:43 pm
Hi!
The problem is that the data of the xml comes from a text area of an applet and I don't want to change it before call fop.
I try to replace the carriage return into
but when I put this code (an example from internet):
[b]contains(@TEXT,'
')[/b]
It doesn't works. Before call fop I print the value of each of the characters in the xml and I can see that it contains 0x010 (
) but the replace doesn't works.
I don't know what more can I do.
Best Regards,
Kike
The problem is that the data of the xml comes from a text area of an applet and I don't want to change it before call fop.
I try to replace the carriage return into
but when I put this code (an example from internet):
[b]contains(@TEXT,'
')[/b]
It doesn't works. Before call fop I print the value of each of the characters in the xml and I can see that it contains 0x010 (
) but the replace doesn't works.
I don't know what more can I do.
Best Regards,
Kike
Hi,
As I said if you parse the XML that has a new line in an attribute value the parser is required to normalize that, see:
http://www.w3.org/TR/2004/REC-xml-20040204/#AVNormalize
***
Before the value of an attribute is passed to the application or checked for validity, the XML processor MUST normalize the attribute value by applying the algorithm below, or by using some other method such that the value passed to the application is the same as that produced by the algorithm.
[...]
Note that if the unnormalized attribute value contains a character reference to a white space character other than space (#x20), the normalized value contains the referenced character itself (#xD, #xA or #x9). This contrasts with the case where the unnormalized value contains a white space character (not a reference), which is replaced with a space character (#x20) in the normalized value and also contrasts with the case where the unnormalized value contains an entity reference whose replacement text contains a white space character; being recursively processed, the white space character is replaced with a space character (#x20) in the normalized value.
***
So your only chance to see the new line is to encode it as a character reference.
Best Regards,
George
As I said if you parse the XML that has a new line in an attribute value the parser is required to normalize that, see:
http://www.w3.org/TR/2004/REC-xml-20040204/#AVNormalize
***
Before the value of an attribute is passed to the application or checked for validity, the XML processor MUST normalize the attribute value by applying the algorithm below, or by using some other method such that the value passed to the application is the same as that produced by the algorithm.
[...]
Note that if the unnormalized attribute value contains a character reference to a white space character other than space (#x20), the normalized value contains the referenced character itself (#xD, #xA or #x9). This contrasts with the case where the unnormalized value contains a white space character (not a reference), which is replaced with a space character (#x20) in the normalized value and also contrasts with the case where the unnormalized value contains an entity reference whose replacement text contains a white space character; being recursively processed, the white space character is replaced with a space character (#x20) in the normalized value.
***
So your only chance to see the new line is to encode it as a character reference.
Best Regards,
George
-
- Posts: 4
- Joined: Mon Mar 13, 2006 2:43 pm
-
- Posts: 4
- Joined: Mon Mar 13, 2006 2:43 pm