当我用s1 EPSDK36 run xsd文件时,从一个已经做好的xsd文件copy template写自己的文件时,总是报出:Content is not allowed in prolog 错误。
尝试半天结果一样,用文件对比工具问题还是得不到解决;
查询得知是BOM的问题,把文件转存为UTF-8 no BOM 格式,一切ok。
现做简单总结;
*********************************************************************
参考文档:
Content is not allowed in prolog
疯了,可怜的Java 可怜的JSP,问题真多:Content is not allowed in prolog.
一个简单的JSP,转换一个XML输出HTML
<c:import url="Test.xsl" var="stylesheet"/>
<x:transform xslt="${stylesheet}" doc="Test.xml"/>
报错:Content is not allowed in prolog.
上网查,说可能是BOM问题,说很多编辑器保存UTF-8时会在前面加个0xFE之类的,
但是很多XML解析器又不认识。。。。
是这个原因吗?我更改了其他编码,也曾经用编辑器把0xFE去掉,没用啊。。。
其他回答:
对于UTF-8编码的文件来说, BOM头是可有可无的. 如果用dom4J加载含有BOM
头的UTF-8格式的xml文件, 却会抛出"Content is not allowed in prolog"异常.
原来无BOM头的UTF-8文件在经过UltraEdit编辑后, UltraEdit会擅自作主添加一个
BOM头(EditPlus无此问题, 记事本似乎有此问题), 即使去掉UltraEdit中与BOM相
关的所有设置选项也无济于事. 后来在UltraEdit论坛搜索答案, 有人提到11版以后
(含)的UltraEdit"另存为"对话框提供了另存为"UTF-8 - NO BOM"的一个选项.对理
想主义者来说, 这不能算是一个很完美的解决方法:(
进一步研究可以发现, IE/Windows记事本/XmlBuddy等等可正常显示含BOM头的
UTF-8格式文件.那么完美方案应该是让dom4j能正确读入含BOM头的UTF-8文件.
在dom4j的sourceforge论坛上已经有人就此提问, 但是答案中的链接已经失效. 再
次google, 在这里找到了一段代码.
/////////////////////////////
在 windows 上,檔案如果是存檔成 unicdoe 或是 utf-8 的時候,如果用 ultraedit 或是其他可以用二進元觀看檔案的軟體打開檔案,會看到檔案的開頭多了 FE FF 這 2 個位元組的東西,去年自己在玩 hibernate 時候,使用 xml 檔案做為 hibernate 初始化的設定檔,那時候曾出現一個怪問題,就是在讀取 xml 檔案的時候,xml parser 一直回報 Content is not allowed in prolog 的錯誤訊息,上網查了查資料後,才發現原來是因為檔案的前面有unicdoe 的 BOM 識別字元。
22222222222222222:
http://www.blogjava.net/bigseal/archive/2005/02/27/1535.aspx
"Content is not allowed in prolog" error
Posted on 2005-02-27 11:09 bigseal 阅读(6046) 评论(3) 编辑 收藏
看到一篇关于在eclipse中使用ant构建java项目的文章,就按照文章中的说明新建了一个项目,并新建了classes,dist,doc,lib几个文件夹和build.xml文件。其中build.xml文件的内容也是直接复制的,由于是从网页上直接复制的,里面“<”“>”都是中文格式的,我就把这些给替换了一下。
但当选中项目,然后选择“Project”,“Properties”,“Builders”,“New…”,选择“Ant Build”:载入“Bulidfile”时提示“Content is not allowed in prolog”错误。
我就去Google上转了一圈,还有点收获,看了一篇小文章,觉得可能是build.xml文件格式的错误。
In SGML and XML, a document is composed of two sequential parts,
the prolog and the instance. You can see this in an HTML example:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN "
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
3 <html xmlns= "http://www.w3.org/1999/xhtml " >
4 <head >
5 <title >The Symbol Grounding Problem </title >
6 </head >
7 <body >
8 </body >
9 </html >
In this example, the prolog is lines 1-2, the instance begins on
line 3. The prolog includes the DOCTYPE declaration, the external
subset (called the DTD), and the internal subset (which you seldom
see but it 's legal). The document instance includes the document
element (in this case <html > and all of its descendent content).
You generally don 't want to see the prolog, and you generally don 't
want to store it. The DOCTYPE declaration provides references to
DTD, which is instantiated as part of the process of validating the
document. You may want to store the reference(s), but you wouldn 't
want to store the DTD each time you store the document, as that
would be a real waste (the DTD is often bigger than the document).
It sounds like your well-formed and valid document isn 't being
considered as such by the XML processor. The error message indicates
that there is content (i.e., either elements or character data) in
the part of the document considered as the prolog. You may be missing
the last " > " on line 2 above, as that would normally be the beginning
of the internal subset. If it found " <html " (or something similar),
you might get that error.
果然,有两个“!”是中文状态,改过来就ok 了。
- 大小: 63.2 KB
分享到:
相关推荐
Download from your IP address is not allowed 百度网盘永久连接: QT下载: qt-opensource-linux-x64-5.8.0.run: 链接:https://pan.baidu.com/s/1sQ3tqPaWdDnmhBYAc_XR7g qt-opensource-linux-x64-5.13.1....
NULL 博文链接:https://rayoo.iteye.com/blog/1973032
**问题描述**:编译器报错“Error 318: can’t open file ‘beep.h’”,表示在编译过程中尝试打开文件`beep.h`但未能成功。 **解决方案**: - 创建一个名为`beep.h`的头文件,并将其放置在项目的工作目录下,通常...
设置隐试打开PPT报错 Hiding the application window is not allowed
Android WebView 报 Not allowed to load local resource错误的解决办法 博客地址:http://blog.csdn.net/yuzhiqiang_1993/article/details/76228541
错误信息`Error:(25, 5) Integer types not allowed (at 'android:textSize' with value '12')`表明在第25行的第5个字符处,系统发现了一个整数值 '12' 被用作`android:textSize`的值,这是不允许的。`android:...
directories that will not be allowed to be processed by Diskeeper. Event Logging ------------- Diskeeper records information about its activity in two ways. First, general information about ...
import cycle not allowed(解决方案).md
Host 主机名 is not allowed to connect the mysql server 原因:没有授权远程访问mysql 解决方法: cmd 中运行mysql -u root -p(如果报mysql 不是内部或外部命令,找到安装mysql对应的bin文件夹运行mysql.exe,...
### 启动报错:验证加密狗无效 error:1001-mysql参数导致 #### 问题现象 在启动过程中出现了“验证产品加密狗无效:error:1001”的错误提示,该问题通常出现在V5系统启动时,并且与MySQL数据库参数配置有关。 ##...
常见错误: Error encoding arguments: Error: invalid bytes32 value (arg=””, coderType=...SyntaxError: Functions are not allowed to have the same name as the contract. If you intend this to be a const
本文实例讲述了ThinkPHP提示错误Fatal error: Allowed memory size的解决方法。...错误提示:Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes) in /var/w
### Android XML Attribute详解 在Android开发中,XML文件扮演着非常重要的角色,特别是在定义界面布局、样式、动画等方面。为了帮助开发者更好地理解Android中的各种XML属性及其用途,本文将详细介绍部分核心XML...
nginx: [emerg] “proxy_cache_path” directive is not allowed here in /etc/nginx/conf.d/default.conf:29 提示意思“proxy_cache_path指令不被允许”,在官网上查找了相关说明,也没有发现问题,最后看应用范围...
document.write is not allowed in a script tag(解决方案).md
document.write is not allowed in a style tag(解决方案).md
document.write is not allowed in a link tag(解决方案).md
CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject '...