开发者

generate class from xsd with xjc

开发者 https://www.devze.com 2023-03-22 09:02 出处:网络
i try to generate class from xs开发者_JAVA技巧d but i got problem with the second line <?xml version=\"1.0\" encoding=\"UTF-8\"?>

i try to generate class from xs开发者_JAVA技巧d but i got problem with the second line

<?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">

...

i got this error:

[ERROR] Content is not allowed in prolog. so xjc seem to have problem with schema

this xsd have an import and in this import there is another import... so i don't know when the error will be removed if xjc will be able to manage that...


I had this issue and it turned out the encoding was the issue:

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

works but

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

doesn't (at least on my Windows7/64 bit OS).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消