How to use JAXB @XmlSchema annotation in Scala package object?

This question follows from Blaise's excellent answer here .

My question is: how can I use JAXB @XmlSchema annotation from Scala?

This is what I came 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 causes 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 the case of a workaround that @XmlSchema does not require, I will explain what I am trying to do - basically I am trying to decouple an XML representation that 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 href links ...

+6
source share

Source: https://habr.com/ru/post/904101/


All Articles