From: "Daniel Meißner" <daniel.meissner-i4k@ruhr-uni-bochum.de>
To: guile-user@gnu.org
Subject: Preserving EOL styles during SXML (de)serializing with xml->sxml/sxml->xml
Date: Tue, 01 Feb 2022 11:19:09 +0100 [thread overview]
Message-ID: <87y22u99eq.fsf@ruhr-uni-bochum.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 197 bytes --]
Hi Guile community!
First of all, thank you for the wonderful language you created. It's
super fun for me to try to get stuff done using Guile.
Now to my problem: I have an XML file like this:
[-- Attachment #2: eol-guile.xml --]
[-- Type: application/octet-stream, Size: 139 bytes --]
<root>
<node>Text with Windows
line endings, that is, CRLF.</node>
<node>Text with UNIX
line endings, that is, LF.</node>
</root>
[-- Attachment #3: Type: text/plain, Size: 259 bytes --]
In this file there are elements that contain text nodes with CRLF
(Windows style EOL) and ones containing LF (UNIX style EOL). I wish to
preserve the CRLF line endings. However, the following little script
shows that they get lost during reading/parsing:
[-- Attachment #4: eol-guile.scm --]
[-- Type: text/plain, Size: 214 bytes --]
(use-modules (sxml simple)
(srfi srfi-26))
(let ((sxml (call-with-input-file "eol-guile.xml" xml->sxml)))
(write sxml)
(call-with-output-file "eol-guile-written.xml"
(cut sxml->xml sxml <>)))
[-- Attachment #5: Type: text/plain, Size: 170 bytes --]
After reading in the file and parsing it to SXML the CRLF is gone. This
seems to happen during the SXML parsing. How do I prevent this from
happening?
Thanks,
Daniel
reply other threads:[~2022-02-01 10:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y22u99eq.fsf@ruhr-uni-bochum.de \
--to=daniel.meissner-i4k@ruhr-uni-bochum.de \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).