我对我的 JAXB 的编组有疑问,不太明白为什么。当我整理数据并将其添加到 xml 文件中时,一切都是正确的,除了它在顶部导入 XML 编码。
之前的例子:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlightDetails xmlns="http://xml.netbeans.org/schema/Shows">
<FlightDetailsCollection>
<DestinationCity>France</DestinationCity>
<ExtraInfo>Free Wifi</ExtraInfo>
<Date>2009-03-09</Date>
<Fare>
<CurrencyName>GBP</CurrencyName>
<CurrencyFare>60.0</CurrencyFare>
</Fare>
</FlightDetailsCollection>
</FlightDetails>
然后,当我添加编组数据时,它显示如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlightDetails xmlns="http://xml.netbeans.org/schema/Shows">
<FlightDetailsCollection>
<OriginCity>London</OriginCity>
<DestinationCity>France</DestinationCity>
<AirlineBrand>Ryan Air</AirlineBrand>
<ExtraInfo>Free Wifi</ExtraInfo>
<Date>2009-03-09</Date>
<Fare>
<CurrencyName>GBP</CurrencyName>
<CurrencyFare>60.0</CurrencyFare>
</Fare>
</FlightDetailsCollection>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlightDetails xmlns="http://xml.netbeans.org/schema/Shows">
<FlightDetailsCollection>
<OriginCity>Germany</OriginCity>
<DestinationCity>France</DestinationCity>
<AirlineBrand>Virgin Air</AirlineBrand>
<Date>2009-03-09</Date>
<Fare>
<CurrencyName>GBP</CurrencyName>
<CurrencyFare>200.0</CurrencyFare>
</Fare>
</FlightDetailsCollection>
</FlightDetails>
如您所见,它在将其放入 XML 文件之前添加了以下内容。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlightDetails xmlns="http://xml.netbeans.org/schema/Shows">
我怎样才能阻止它包含编码和模式名称?在调试中,它似乎只包含所需的信息,所以我无法跟踪它。我认为是 JAXB 添加了它,但可能是错误的。
非常感谢,