xml – 有没有办法阻止Eclipse(3.7)搞乱标签内容?

如果我使用属性视图在 XML模式中编写多行文档,则会创建< xsd:documentation>包含它的标签.

每当我格式化文件(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文件 – >编辑对缩进没有帮助.在相同的首选项页面增加“行宽”修复了换行,但我真的希望编辑器不要格式化我的文档元素的内容.

您可以向xsd:documentation添加xml atribute xml:space =“preserve”以告知必须保留空格.例如:
<xsd:documentation xml:space="preserve" >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>

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念