JAXB Fragment Marshal w/o namespace

前端 未结 3 815
时光说笑
时光说笑 2021-02-05 21:18

I\'m using the JAXB_FRAGMENT property for my marshaller to marshal at the WorkSet level. The problem is that when I marshal it\'s giving the WorkSet element the xmlns attribute

3条回答
  •  悲哀的现实
    2021-02-05 21:46

    There are three workarounds for this.

    1) Create JAXB annotated objects for the container of your workersets. Add the workersets to that object and then marshal the whole thing.

    2) Follow the first example in 101 ways to marshal objects with JAXB and use DocumentBuilderFactory with namespace aware.

    3) Assuming that the jaxb object is in a package that should never have qualified namespaces you can add the following to the package annotation: (note: it's been a while since i've done this and I havn't tested this code)

    @XmlSchema(namespace = "", elementFormDefault = XmlNsForm.UNQUALIFIED) 
    package example;
    

提交回复
热议问题