1

so I am using a binding.xjb file to generate classes from XML files. My main problems is that every XML file begins like this:

 <xs:schema xmlns="http://www.kfk.de/bokes" xmlns:xs="http://www.w3.org
/2001/XMLSchema" targetNamespace="http://www.kfk.de/bokes"
elementFormDefault="qualified" attributeFormDefault="unqualified">

And the generated package-info.java - <xs:schema xmlns="http://www.kfk.de/bokes" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.kfk.de/bokes" elementFormDefault="qualified" attributeFormDefault="unqualified">

However I don't want to have the targetNamespace to be http://www.kfk.de/bokes, I want to change it to "bokes" only but I still can't understand how to change it in the bindings.xjb I tried using:

       <jxb:bindings>
          <namespace:prefix name="bokes"/>
       </jxb:bindings>

but it didn't work

nxn
  • 89
  • 1
  • 10
  • Are you sure you want to changed the `targetNamespace`? Not `preifx`? Why do you need this? – lexicore Jan 20 '17 at 11:00
  • I need to change the whole part actually, the xmlns="bokes" as well as the targetNamespace, because the XML files I am using to generate the classes are with the namespace with http://www.kfk.de/bokes and it has to be only bokes, and I can't change it in the XML files because we download them from a provider, so only way to edit the namespace is through the bindings.xjb, I also tried setting the namespace to the JAXB2 marshaller, but it doesn't work in java8. – nxn Jan 20 '17 at 11:05
  • So your XML does not comply to your schema, is that right? While you can change the generated annotations via `jaxb2-annotate-plugin`, I'd actually recommend patching the downloaded schemas prior to compilation. – lexicore Jan 20 '17 at 11:19
  • The provider does not comply to the general standard that's why I have to adjust it manually just for this provider, thats why I am looking for an option. I will try looking into the annotate plugin – nxn Jan 20 '17 at 11:28
  • Provider - the one that sends you XML files? If so, I'd preprocess XML by changing the namespaces using an XMLFilter or similar. – lexicore Jan 20 '17 at 11:36

0 Answers0