0

我尝试从 xsd 生成类,但第二行出现问题

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:saqcc="urn:saq:cct:cct-3.5.xsd" xmlns:flx="urn:saq:mtl:grey:flux:04489:rep-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:saq:mtl:grey:flux:04489:rep-1.0.xsd"  elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1">

...

我收到了这个错误:

[错误] prolog 中不允许有内容。所以 xjc 似乎有架构问题

这个xsd有一个导入,在这个导入中还有另一个导入......所以我不知道如果xjc能够管理那个错误什么时候会被删除......

4

2 回答 2

4

我遇到了这个问题,结果发现编码是问题:

<?xml version="1.0" encoding="utf-8"?>

有效,但

<?xml version="1.0" encoding="utf-16"?>

没有(至少在我的 Windows7/64 位操作系统上)。

于 2011-08-23T17:00:54.053 回答
2

When I get this error with any sort of XML document, it's usually because of some (invisible) content before <?xml. More specifically, this is due to the BOM (byte order mark) added by some editor. In my case, it was mostly due to this BOM: 

Check if you have such content in your file. If you do, remove it. XML files don't need a BOM, as they can formally specify the encoding in the prolog like this:

<?xml version="1.0" encoding="utf-8"?>

UPDATE: The prolog MUST be the first part of well-formed XML, as defined by w3c here:

http://www.w3.org/TR/2008/REC-xml-20081126/#sec-well-formed

于 2011-07-22T08:17:29.217 回答