From: MON KEY <monkey@sandpframing.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#4950: `xml-parse-file' returns incorrect results strings after `>' before `<' when CR\LF TAB+
Date: Tue, 17 Nov 2009 17:12:37 -0500 [thread overview]
Message-ID: <d2afcfda0911171412m394edccdw129ff7993c245384@mail.gmail.com> (raw)
`xml-parse-file' returns incorrect results strings after `>' before
`<' when CR\LF TAB+
`xml-parse-file' fails to retrun correct results when there are ^C-j
(e.g. CR\LF)
followed by \t+ e.g TAB+ after a tag's trailing `>' and before the next tag's
leading `<'. IOW the following:
,----
| <ELEMENT attr1="a1" attr2="a2" attr3="a3" attr4="a4" attr5="a5">CR\LF
| TAB TAB TAB <NEXT-NODE>
`----
Returns (:NOTE with my pp-ing to help clarify the problem):
,----
| (ELEMENT nil
| ((attr1 . "a1")
| (attr2 . "a2")
| (attr3 . "a3")
| (attr4 . "a4")
| (attr5 . "a5") "
| " ;; <-i.e. (mapconcat #'char-to-string '(32 10 9 9 9) "")
| (NEXT-NODE nil (...
`----
Is it if fair/safe to assume that where these types of sequences occur they are
not part of the XML and can be removed with a regexp? E.g. :
,----
| (while (search-forward-regexp "\"\)\n[\[:blank:]]+\"\)" nil t)
| (replace-match ""))
`----
or perhaps:
,----
| (defun cln-xml<-parsed (fname &optional insertp intrp)
| "Strip non-sensical strings created by xml-parse-file because of
| CR\LF TAB+ following tags/elements.
| FNAME is an XML filename path to parse and clean.
| When INSERTP is non-nil or called-interactively insert pretty printed lisp
| representation of XML file at point. Does not move point."
| (interactive "fXML file to parse: \ni\np")
| (let (get-xml)
| (setq get-xml
| (with-temp-buffer
| (prin1 (xml-parse-file fname) (current-buffer))
| (goto-char (point-min))
| (while (search-forward-regexp
| "\\( \"\n[\[:blank:]]+\\)\"\\(\\(\\()\\)\\|\\(
(\\)\\)\\)" nil t)
| ;;^^1^^^^^^^^^^^^^^^^^^^^^^^^^2^^3^^^^^^^^^^^^4^^^^^^^^^^^^
| (replace-match "\\2"))
| (pp-buffer)
| (buffer-substring-no-properties (point-min) (point-max))))
| (if (or insertp intrp)
| (save-excursion
| (newline)
| (princ get-xml (current-buffer)))
| get-xml)))
`----
:SEE-ALSO
(URL `http://lists.gnu.org/archive/html/bug-gnu-emacs/2001-11/msg00052.html')
s_P
next reply other threads:[~2009-11-17 22:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 22:12 MON KEY [this message]
2012-07-01 11:22 ` bug#4950: `xml-parse-file' returns incorrect results strings after `>' before `<' when CR\LF TAB+ Chong Yidong
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2afcfda0911171412m394edccdw129ff7993c245384@mail.gmail.com \
--to=monkey@sandpframing.com \
--cc=4950@emacsbugs.donarmstrong.com \
--cc=bug-gnu-emacs@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.