I want to automatically format an XML schema definition file. All the normal pretty-print stuff: linebreaks after end-element, indentiing. I have seen this answer, and this elisp, which gives me the basics. Beyond what is there, though, I would like line-breaks between attributes within angle-brackets.
我想自动格式化XML架构定义文件。所有正常的漂亮印刷品:end-element之后的换行符,indentiing。我已经看到了这个答案,这个elisp,它给了我基础知识。但是,除了那里,我想在尖括号内的属性之间换行。
Like so. Before:
像这样。之前:
<s:schema elementFormDefault="qualified" targetNamespace="urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/" xmlns:tns="urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/" xmlns:detail="urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/" xmlns:to="urn:Cheeso.2009.05.Finance/TransferObject/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:address="urn:Cheeso.2009.05.Finance/TransferObject/Address/" xmlns:caller="urn:Cheeso.2009.05.Finance/TransferObject/Caller/" xmlns:gwy="urn:Cheeso.2009.05.Finance/TransferObject/Gateway/" xmlns:tender="urn:Cheeso.2009.05.Finance/TransferObject/Tender/" >
...
</s:schema>
After:
<s:schema
elementFormDefault = "qualified"
targetNamespace = "urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/"
xmlns:tns = "urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/"
xmlns:detail = "urn:Cheeso.2009.05.Finance/TransferObject/TransactionDetail/"
xmlns:to = "urn:Cheeso.2009.05.Finance/TransferObject/"
xmlns:s = "http://www.w3.org/2001/XMLSchema"
xmlns:address = "urn:Cheeso.2009.05.Finance/TransferObject/Address/"
xmlns:caller = "urn:Cheeso.2009.05.Finance/TransferObject/Caller/"
xmlns:gwy = "urn:Cheeso.2009.05.Finance/TransferObject/Gateway/"
xmlns:tender = "urn:Cheeso.2009.05.Finance/TransferObject/Tender/" >
...
</s:schema>
Can anyone suggest some elisp that can line up the = ?
任何人都可以建议一些可以排队的elisp =?
1 个解决方案
#1
Try something like the following:
尝试以下内容:
(defun prettyprint-xml ()
(interactive)
(goto-char (point-min))
(while (search-forward "=" (point-max) t)
(search-forward "\"")
(search-forward "\"")
(forward-char)
(newline-and-indent))
(align-regexp (point-min) (point-max) "\#"))
It may not do exactly what you want ( I justcoded it up), but it looks like it should work for the case you showed.
它可能不完全符合您的要求(我刚刚编写了它),但看起来它应该适用于您展示的情况。
#1
Try something like the following:
尝试以下内容:
(defun prettyprint-xml ()
(interactive)
(goto-char (point-min))
(while (search-forward "=" (point-max) t)
(search-forward "\"")
(search-forward "\"")
(forward-char)
(newline-and-indent))
(align-regexp (point-min) (point-max) "\#"))
It may not do exactly what you want ( I justcoded it up), but it looks like it should work for the case you showed.
它可能不完全符合您的要求(我刚刚编写了它),但看起来它应该适用于您展示的情况。