Reputation: 29
How to externalize the namespace value in package-info.java
@javax.xml.bind.annotation.XmlSchema(namespace = "http://loclahost:9093/Request", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
in the above code how should externalize the "http://loclahost:9093/Request".
Any help is greatly appreciated
Upvotes: 2
Views: 1332
Reputation: 149037
The namespace specified on the the @XmlSchema
annotation isn't meant to correlate to the physical location of the XML schema. It is used to qualify the element, so that your address
element is different from another organizations use of an address
element. This is similar to package names in Java. As with package names, people generally use domain names for this purpose. I can't think of a good reason to have the namespace look like: http://loclahost:9093/Request
.
Upvotes: 2
Reputation: 122394
Annotation attribute values have to be compile time constants so the best you can do is to declare a public static final String NAMESPACE = "http://example.com"
in another class and then say namespace = MyClass.NAMESPACE
in the annotation. But you'd still have to re-compile package-info.java
when MyClass
changes.
Upvotes: 2