Problems with linefeed treatment
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Mon Mar 13, 2006 2:43 pm
Problems with linefeed treatment
Post by ehernandez »
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
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
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
Post by ehernandez »
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
Post by ehernandez »
Hi again :)
So the only thing that I can do is have an xml like this before call fop?
[b]<DOCUMENT TEXT="The first Line The second line" /> [/b]
Or use the other xml:
[b]<DOCUMENT>
<TEXT>The first line
The second line</TEXT>
</DOCUMENT> [/b]
Isn't it?
Best regards,
Kike
So the only thing that I can do is have an xml like this before call fop?
[b]<DOCUMENT TEXT="The first Line The second line" /> [/b]
Or use the other xml:
[b]<DOCUMENT>
<TEXT>The first line
The second line</TEXT>
</DOCUMENT> [/b]
Isn't it?
Best regards,
Kike
-
- Posts: 4
- Joined: Mon Mar 13, 2006 2:43 pm
Post by ehernandez »
Hi again George!
Thanks a lot for your help, you resolve my doubt very fast!
Best regards,
Kike
Thanks a lot for your help, you resolve my doubt very fast!
Best regards,
Kike
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service