You could write a subtype of XmlJavaTypeAdapter which did the
conversion, and then using binding customisations to associate it with
the URI type.
chrisrk wrote:
> Hi
>
> Seems this is a common question, but none of the methods I've tried seem to
> work.
>
> I have a schema containing some anyURI elements, I'd like JAXB to
> automatically read them into java.net.URI objects rather than Strings.
>
> I found
> https://metro.dev.java.net/guide/Customizing_XML_Schema_binding.html, and
> modified my Ant script to suit. Simple mode is being enabled;
> Unmarshaller.unmarshal(..) now returns a custom object rather than a
> JAXBElement - but anyURIs are still Strings.
>
> I tried using
>
> <jaxb:javaType name="java.net.URI" xmlType="xs:anyURI"/>
>
> also, but that gives me problems with uncaught URISyntaxExceptions - who is
> supposed to catch those? Is there a way of having them flag as validation
> errors?
>
> Thanks in advance,
>
> Chris
>
> --
> View this message in context: http://www.nabble.com/anyURI-to-java.net.URI-tp14949162p14949162.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>