This question is following on from Blaise's excellent answer here.
My question is, how do I use the JAXB @XmlSchema
annotation from within Scala?
This is what I've come up with so far:
// File src/main/scala/co/orderly/prestasac/representations/wrappers.scala
package co.orderly.prestasac.representations
// JAXB
import javax.xml.bind.annotation._
@XmlSchema(xmlns = Array(@XmlNs(prefix = "xlink", namespaceURI = "http://www.w3.org/1999/xlink")))
package object wrappers {
}
Unfortunately this throws an error:
/home/alex/Development/Orderly/prestashop-scala-client/src/main/scala/co/orderly/prestasac/representations/wrappers/wrappers.scala:18: illegal start of simple expression
[error] @XmlSchema(xmlns=Array(@XmlNs(prefix = "xlink", namespaceURI = "http://www.w3.org/1999/xlink")))
[error] ^
In case there's a workaround which doesn't require @XmlSchema
, I'll explain what I'm trying to do - basically I'm trying to unmarshall an XML representation which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<products>
<product id="11" xlink:href="http://www.myshop.com/api/products/11"/>
<product id="12" xlink:href="http://www.myshop.com/api/products/12"/>
...
</products>
</prestashop>
I believe I need to use @XmlSchema
to define the "xlink"-prefixed namespace for the href
links...