If I write multi-line documentation in an XML schema using the properties view it creates <xsd:documentation>
tags to contain it.
如果我使用properties视图在XML模式中编写多行文档,它会创建
Whenever I format the file (CTRL+SHIFT+F) all lines but the first are indented and sometimes wrapped due to this indentation.
每当我格式化文件(CTRL+SHIFT+F)时,除了第一行之外的所有行都会被缩进,有时由于缩进而被包装。
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.
“格式注释”选项在首选项中—> XML—> XML文件—>编辑器对缩进没有帮助。在相同的首选项页面上增加“行宽度”可以修复包装,但是我真的希望编辑器不要格式化我的文档元素的内容。
4 个解决方案
#1
4
You could add an xml atribute xml:space="preserve"
to xsd:documentation
to tell that spaces must be preserved. For example:
您可以向xsd:文档中添加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>
#2
1
"Format comments" option is for XML comments:
“格式注释”选项用于XML注释:
<!-- comment -->
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).
我不明白你在设置“线宽”选项时遇到了什么问题(在3.7版本是999)。
If your XML is:
如果您的XML:
<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>
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).
然后将“线宽”设置为999,格式不会改变内容。不幸的是,没有选择关闭宽度检查(例如将“线宽”设置为0)。
edit: it seems that when you use <![CDATA[, Eclipse is not formating the content (at least indentation and line wrapping), example:
编辑:当你使用, Eclipse没有格式化内容(至少是缩进和换行),例如:</p>
<root>
<documentation><![CDATA[
1st line of comment
2nd line is indented and also wrapped as it exceeds the max line length setting.
3rd line is just indented.
]]></documentation>
</root>
#3
1
Try using it like this:
试着这样使用:
<xsd:documentation><![CDATA[ 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>
But ALSO , try to set
同时,试着设置
<?xml version="1.0" encoding="UTF-16"?>
in your file, if you are not already using it. New lines in xml can be problematic between ASCII and UTF-16
在您的文件中,如果您还没有使用它。在ASCII和UTF-16之间,xml中的新行可能存在问题
#4
0
Set the option "Preserve whitespace in tags with PCDATA content".
设置选项“保留带有PCDATA内容的标签中的空格”。
#1
4
You could add an xml atribute xml:space="preserve"
to xsd:documentation
to tell that spaces must be preserved. For example:
您可以向xsd:文档中添加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>
#2
1
"Format comments" option is for XML comments:
“格式注释”选项用于XML注释:
<!-- comment -->
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).
我不明白你在设置“线宽”选项时遇到了什么问题(在3.7版本是999)。
If your XML is:
如果您的XML:
<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>
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).
然后将“线宽”设置为999,格式不会改变内容。不幸的是,没有选择关闭宽度检查(例如将“线宽”设置为0)。
edit: it seems that when you use <![CDATA[, Eclipse is not formating the content (at least indentation and line wrapping), example:
编辑:当你使用, Eclipse没有格式化内容(至少是缩进和换行),例如:</p>
<root>
<documentation><![CDATA[
1st line of comment
2nd line is indented and also wrapped as it exceeds the max line length setting.
3rd line is just indented.
]]></documentation>
</root>
#3
1
Try using it like this:
试着这样使用:
<xsd:documentation><![CDATA[ 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>
But ALSO , try to set
同时,试着设置
<?xml version="1.0" encoding="UTF-16"?>
in your file, if you are not already using it. New lines in xml can be problematic between ASCII and UTF-16
在您的文件中,如果您还没有使用它。在ASCII和UTF-16之间,xml中的新行可能存在问题
#4
0
Set the option "Preserve whitespace in tags with PCDATA content".
设置选项“保留带有PCDATA内容的标签中的空格”。