有没有办法阻止 Eclipse (3.7) 弄乱的内容?标签?
如果我使用属性视图在 XML 模式中编写多行文档,它会创建
标记来包含它。
每当我格式化文件(CTRL + SHIFT + F)时,除第一行之外的所有行都会缩进,有时由于这种缩进而被换行。
这种缩进和换行实际上破坏了从文件生成漂亮文档的所有努力。特别是如果我想记录允许值的表。
格式之前:
<xsd:documentation>1st line of comment
2nd line is indented and also wrapped as it exceeds the max line length setting.
3rd line is just indented.
</xsd:documentation>
格式之后:
<xsd:documentation>1st line of comment
2nd line is indented and also wrapped as it exceeds the max line
length setting.
3rd line is just indented.
</xsd:documentation>
首选项 -> 中的“格式评论”选项XML-> XML 文件 ->编辑器不帮助缩进。在同一首选项页面上增加“线宽”可以修复换行,但我真的希望编辑器不要格式化我的文档元素的内容。
If I write multi-line documentation in an XML schema using the properties view it creates <xsd:documentation>
tags to contain it.
Whenever I format the file (CTRL+SHIFT+F) all lines but the first are indented and sometimes wrapped due to this indentation.
This indentation and wrapping effectively ruins every effort of generating a nice looking documentation from the file. Especially if I want to document a table of allowed values.
Before format:
<xsd:documentation>1st line of comment
2nd line is indented and also wrapped as it exceeds the max line length setting.
3rd line is just indented.
</xsd:documentation>
After format:
<xsd:documentation>1st line of comment
2nd line is indented and also wrapped as it exceeds the max line
length setting.
3rd line is just indented.
</xsd:documentation>
The "Format comments" option in Preferences -> XML -> XML files -> Editor does not help with the indentation. Increasing "Line width" on the same preferences page fixes wrapping but I really want the editor to NOT format my the contents of my documentation elements.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将 xml 属性
xml:space="preserve"
添加到xsd:documentation
来告知必须保留空格。例如:You could add an xml atribute
xml:space="preserve"
toxsd:documentation
to tell that spaces must be preserved. For example:“格式注释”选项适用于 XML 注释:
这就是它不能按您希望的方式工作的原因。
我不明白将“线宽”选项设置为 max(在版本 3.7 中为 999)时遇到什么问题。
如果您的 XML 是:
那么将“线宽”设置为 999 并且格式设置不会更改您的内容。不幸的是,没有没有选项可以关闭宽度检查(例如将“线宽”设置为 0)。
编辑:
似乎当您使用
"Format comments" option is for XML comments:
That's why it's not working as you wish.
I do not understand what problem are you facing with setting "line width" option to max (in version 3.7 it is 999).
If your XML is:
Then setting "line width" to 999 and formatting does not change your content. Unfortunately there is no option to turn width checking off (for example to set "line width" to 0).
edit:
it seems that when you use <![CDATA[, Eclipse is not formating the content (at least indentation and line wrapping), example:
尝试像这样使用它:
但是,
如果您还没有使用它,请尝试在您的文件中进行设置。 xml 中的新行在 ASCII 和 UTF-16 之间可能会出现问题
Try using it like this:
But ALSO , try to set
in your file, if you are not already using it. New lines in xml can be problematic between ASCII and UTF-16
设置选项“在具有 PCDATA 内容的标签中保留空格”。
Set the option "Preserve whitespace in tags with PCDATA content".