简体   繁体   English

jEdit XML Sidekick无法处理XHTML5

[英]jEdit XML Sidekick cannot handle XHTML5

I have a document in XHTML5. 我在XHTML5中有一个文档。 That just means that I'm creating an HTML5 document, but I want all the ending tags to be present and I want appropriate encoding, etc. So the file extension is xhtml and the file starts with: 那只是意味着我正在创建一个HTML5文档,但是我希望所有的结束标签都存在并且我想要适当的编码,等等。因此文件扩展名是xhtml ,文件开头是:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">

All this is completely standard stuff. 所有这些都是完全标准的东西。 Just simple HTML5 encoded in XML. 只是用XML编码的简单HTML5。

I installed jEdit 5.3.0 with the XML Sidekick plugin. 我使用XML Sidekick插件安装了jEdit 5.3.0。 Immediately I get an error list, saying: 我立即得到一个错误列表,说:

Element type "html" must be declared.
Element type "html" must be declared.
Element type "body" must be declared.
Element type "h1" must be declared.
Element type "p" must be declared.
...

The Sidekick outline looks cool, and the popup suggesting the element and attribute names is nice. Sidekick轮廓看起来很酷,并且弹出提示元素和属性名称的窗口很好。

But how do I get rid of all those errors? 但是,如何摆脱所有这些错误? I don't need or want a DTD. 我不需要或不需要DTD。

If I change the parser to html then I don't get any errors --- but I don't get any DOM tree representation or auto-suggest either. 如果我将解析器更改为html那么我不会收到任何错误---但我也不会获得任何DOM树表示或自动建议。

Why doesn't jEdit+Sidekick like my simple, standards-compliant XHTML5 file? 为什么jEdit + Sidekick不喜欢我的简单且符合标准的XHTML5文件?

Re: 回覆:

But how do I get rid of all those errors? 但是,如何摆脱所有这些错误?

This answer describes one way. 该答案描述了一种方法。 There are others. 还有其他

Re: 回覆:

Why doesn't jEdit+Sidekick like my simple, standards-compliant XHTML5 file? 为什么jEdit + Sidekick不喜欢我的简单且符合标准的XHTML5文件?

<!DOCTYPE html> triggers jEdit's DTD-based parsing, but doesn't provide enough information to locate a corresponding DTD. <!DOCTYPE html>触发jEdit基于DTD的解析,但是没有提供足够的信息来定位相应的DTD。 For details, see the description of "permitted-public-ID-system-ID-combination" on the W3C web page " HTML syntax ". 有关详细信息,请参见W3C网页“ HTML语法 ”中对“ permitted-public-ID-system-ID-combination”的描述。

Re: 回覆:

I don't need or want a DTD. 我不需要或不需要DTD。

If you want to validate XHTML5 in jEdit using the XML plugin, then you need either a DTD or a schema. 如果要使用XML插件在jEdit中验证XHTML5,则需要DTD或架构。 This answer uses a W3C XML schema. 此答案使用W3C XML模式。

If you only want to check that your XHTML5 is well-formed, but not necessarily valid, then, yes, as you say, you don't need either a DTD or a schema, and you can ignore most of this answer: just insert the string :xml.validate.ignore-dtd=true: in a comment in one of the top 10 lines of your XHTML5 document. 如果您只想检查您的XHTML5格式是否正确,但不一定有效,那么是的,正如您所说,您不需要DTD或架构,可以忽略大多数答案:只需插入在XHTML5文档的前10行之一的注释中,字符串:xml.validate.ignore-dtd=true:

Validating XHTML5 in jEdit 在jEdit中验证XHTML5

Summary 摘要

  1. Insert :xml.validate.ignore-dtd=true: in a comment in the first 10 lines of your XHTML5 to prevent jEdit DTD parsing. 在XHTML5的前10行的注释中插入:xml.validate.ignore-dtd=true:以防止jEdit DTD解析。
  2. Download an XHTML5 schema. 下载XHTML5模式。
  3. In jEdit, associate the XHTML5 schema with your XHTML5 document. 在jEdit中,将XHTML5模式与您的XHTML5文档相关联。

Detailed procedure 详细程序

The following procedure assumes that you have already installed jEdit with the XML plugin. 以下过程假定您已经使用XML插件安装了jEdit。

  1. Insert the string :xml.validate.ignore-dtd=true: in a comment in the first 10 lines of your XHTML5 file. 在XHTML5文件的前10行的注释中插入字符串:xml.validate.ignore-dtd=true: For example: 例如:

     <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- jEdit XML plugin property: :xml.validate.ignore-dtd=true: --> <meta charset="UTF-8"/> <title>XHTML5 document</title> </head> <body> <p>Hello, World!</p> </body> </html> 

    This stops jEdit looking for that nonexistent DTD. 这将使jEdit停止寻找不存在的DTD。

  2. Download the XHTML5 schema from the GitHub repository arasix/XHTML5-XML-Schema . 从GitHub存储库arasix / XHTML5-XML-Schema下载XHTML5模式。

    Note the caveat in the repository readme about data-* attributes. 请注意存储库自述文件中有关data-*属性的警告。

    Other schemas for XHTML5 are also available. XHTML5的其他架构也可用。 There is no "official" XHTML5 schema. 没有“正式的” XHTML5模式。

  3. Extract the repository .zip file to the location of your choice. 将存储库.zip文件解压缩到您选择的位置。
  4. In jEdit, set the schema for your XHTML5 document: 在jEdit中,设置XHTML5文档的架构:
    1. Select Plugins > XML > Set Schema... 选择插件> XML>设置架构...
    2. Choose the xhtml5_with_microdata.xsd file from the downloaded repository. 从下载的存储库中选择xhtml5_with_microdata.xsd文件。
    3. I also chose to click "make this location relative (preview bellow)" (sic). 我还选择单击“使该位置相对(预览如下)”(原文如此)。

jEdit creates a schemas.xml file in the same directory as your XHTML5 document. jEdit在与XHTML5文档相同的目录中创建schemas.xml文件。 For details on schemas.xml, including editing it so that you do not need to set the schema for each of your XHTML5 documents, see the jEdit XML plugin help. 有关schemas.xml的详细信息(包括对其进行编辑,以便您无需为每个XHTML5文档设置模式),请参阅jEdit XML插件帮助。

Known issues 已知的问题

Unique particle attribution violations in the schema 模式中唯一的粒子归因冲突

When jEdit loads the schema (it does this once, and then caches it), it reports the following errors in xhtml5.xsd: 当jEdit加载架构时(先执行一次,然后将其缓存),它将在xhtml5.xsd中报告以下错误:

159:cos-nonambig: " http://www.w3.org/1999/xhtml ":link and " http://www.w3.org/1999/xhtml ":link (or elements from their substitution group) violate "Unique Particle Attribution". 159:cos-nonambig:“ http://www.w3.org/1999/xhtml”:link和“ http://www.w3.org/1999/xhtml ”:link(或来自其替代组的元素)受到侵犯“唯一粒子归因”。 During validation against this schema, ambiguity would be created for those two particles. 在针对此架构进行验证的过程中,将为这两个粒子创建歧义。

550:cos-nonambig: " http://www.w3.org/1999/xhtml ":figcaption and " http://www.w3.org/1999/xhtml ":figcaption (or elements from their substitution group) violate "Unique Particle Attribution". 550:cos-nonambig:“ http://www.w3.org/1999/xhtml”:figcaption和“ http://www.w3.org/1999/xhtml ”:figcaption(或来自其替代组的元素)违反了“唯一粒子归因”。 During validation against this schema, ambiguity would be created for those two particles. 在针对此架构进行验证的过程中,将为这两个粒子创建歧义。

I have reported these errors to the schema author. 我已将这些错误报告给架构作者。

In practice, you can ignore these errors: in the Error List pane, click the broom ("Clear Error List") button. 实际上,您可以忽略以下错误:在“错误列表”窗格中,单击扫帚(“清除错误列表”)按钮。

After clearing those errors, I found that I needed to "wake up" the XML parsing for my XHTML5 document: select Plugins > Sidekick > Parse Buffer. 清除这些错误之后,我发现需要“唤醒”我的XHTML5文档的XML解析:选择“插件”>“ Sidekick”>“解析缓冲区”。 Then the parse on keystroke starts working again. 然后,对按键的解析再次开始工作。

No support for HTML named character references 不支持HTML命名字符引用

HTML defines various named character references, such as &nbsp; HTML定义了各种命名字符引用,例如&nbsp; (non-breaking space). (不间断空间)。

The XML schema-based validation described in this answer does not support such named references, except for those predefined in XML . 除了XML中预定义的引用之外,此答案中描述的基于XML模式的验证不支持此类命名引用。

For example, entering &nsbp; 例如,输入&nsbp; in your XHTML5 document will generate the following error in jEdit: 在XHTML5文档中,jEdit中将生成以下错误:

The entity "nbsp" was referenced, but not declared. 实体“ nbsp”已被引用,但未声明。

As a workaround, specify the corresponding XML decimal or hexadecmal numeric character reference: &#160; 解决方法是,指定相应的XML十进制或十六进制数字字符引用: &#160; ;。 or &#xA0; &#xA0; .

Troubleshooting 故障排除

If jEdit does not appear to be parsing your document as XML: 如果jEdit似乎没有将您的文档解析为XML:

  1. Check that the edit mode of your XHTML5 is xml (that it has not reverted to, say, html ): select Utilities > Buffer Options > Edit mode: xml . 检查XHTML5的编辑模式是否为xml (尚未还原为html ):选择实用程序>缓冲区选项>编辑模式: xml
  2. "Wake up" XML parsing: select Plugins > Sidekick > Parse Buffer “唤醒” XML解析:选择“插件”>“ Sidekick”>“解析缓冲区”

Questions 问题

Why not just remove the DOCTYPE? 为什么不删除DOCTYPE?

Rather than inserting a jEdit-specific string into my XHTML5 source to prevent DTD-based parsing, why not just remove the DOCTYPE? 与其将jEdit特定的字符串插入到我的XHTML5源中以防止基于DTD的解析,不如仅删除DOCTYPE?

There are several reasons: for instance, triggering standards mode in web browsers. 原因有很多:例如,在Web浏览器中触发标准模式。 For more information, see the WHATWG FAQ; 有关更多信息,请参见WHATWG常见问题解答。 specifically, the answer to the question " What is the DOCTYPE for modern HTML documents? " 具体来说,是“ 现代HTML文档的DOCTYPE是什么? ”这一问题的答案

You just have to update your XML plugin. 您只需要更新XML插件即可。 The current version recognizes the HTML5 Doctype declaration and switches to DTD-less validation and completion automatically. 当前版本可识别HTML5 Doctype声明,并自动切换到无DTD的验证和完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM