简体   繁体   中英

generate class from xsd with xjc

i try to generate class from xsd 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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