简体   繁体   中英

How to tell JAXB to add noNameSpaceSchemaLocation attribute

i have a certain class hierarchic which is transformed to XML using JAXB. i want the created XML to have the xsi:noNamespaceSchemaLocation and xmls:xsi attributes in the head element ( xsi:noNamespaceSchemaLocation="Something.xsd" xmls:xsi="http://www.w3.org/2001/XMLSchema-instance"). i dont want JAXB do use the schema in any way - just store these attributes and the values.

is there a specific annotation for this? i could create just a constant XmlAttribute but it seems wrong...

thanks

您可以像下面这样在Marshaller上设置JAXB_NO_NAMESPACE_SCHEMA_LOCATION

marshaller.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "address.xsd");

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