You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by hdave <da...@gmail.com> on 2012/01/12 20:33:08 UTC

XML Schema and REST

I have the beginnings of a REST API that has resources that can be returned
as either the application/xml or application/json media types.  I've used
the JAX-B annotation "@XMLSchema" in my package-info.java files to ensure
that the appropriate namespace is referenced when responding with an XML
payload.

I also understand that I can generate and XML Schema document based my JAX-B
annotations.  However, is it common practice to also have the payload
reference the XML Schema (e.g. via "xsi:schemaLocation")?  I ask because as
my system evolves and the JAX-B annotations change, I'll need to version the
schema, yes?

--
View this message in context: http://cxf.547215.n5.nabble.com/XML-Schema-and-REST-tp5140807p5140807.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: XML Schema and REST

Posted by hdave <da...@gmail.com>.
That makes perfect sense...thank you.

--
View this message in context: http://cxf.547215.n5.nabble.com/XML-Schema-and-REST-tp5140807p5149210.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: XML Schema and REST

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 13/01/12 21:42, hdave wrote:
> Thanks for the reply.
>
> Would you agree that XML payloads, if they have anything, contain only a
> reference to a namespace?
>
Yes
> I guess, from this namespace, one could infer the XML schema, provided there
> are not 2 or more schemas that constrain the namespace.  It just seems like
> greater precision would be called for...like it is in SOAP.
>

What I was saying that a specific client that expects say '<bar 
xmlns:="http://bar"/>' needs to have an idea (in the configuration, etc) 
of the schema referenced by "http://bar", for example if it needs to 
validate or say for JAXB to read the payload properly.
I'm not sure non-generic clients should rely on xsi:schemaLocation being 
available in order to validate etc.
The other reason why xsi:schemaLocation is not recommended in the actual 
payloads is that it makes it more difficult to use the alternative 
schema languages, such as RelaxNG, it's not that big of deal for many 
cases where use just go with XMLSchema, but either way, this attribute 
makes the payloads schema-'unportable' :-)

Cheers, Sergey

> --
> View this message in context: http://cxf.547215.n5.nabble.com/XML-Schema-and-REST-tp5140807p5143824.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: XML Schema and REST

Posted by hdave <da...@gmail.com>.
Thanks for the reply.   

Would you agree that XML payloads, if they have anything, contain only a
reference to a namespace?

I guess, from this namespace, one could infer the XML schema, provided there
are not 2 or more schemas that constrain the namespace.  It just seems like
greater precision would be called for...like it is in SOAP.

--
View this message in context: http://cxf.547215.n5.nabble.com/XML-Schema-and-REST-tp5140807p5143824.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: XML Schema and REST

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 12/01/12 19:33, hdave wrote:
> I have the beginnings of a REST API that has resources that can be returned
> as either the application/xml or application/json media types.  I've used
> the JAX-B annotation "@XMLSchema" in my package-info.java files to ensure
> that the appropriate namespace is referenced when responding with an XML
> payload.
>
> I also understand that I can generate and XML Schema document based my JAX-B
> annotations.  However, is it common practice to also have the payload
> reference the XML Schema (e.g. via "xsi:schemaLocation")?  I ask because as
> my system evolves and the JAX-B annotations change, I'll need to version the
> schema, yes?
>

I think including an xsi:schemaLocation in the actual representations is 
very rare and is mainly needed for the generic consumers (such as an 
Excel Web query plugin or similar) who may need to know how to properly 
render a given XML payload. The specific clients need to have an a 
priori knowledge of the data

Cheers, Sergey

> --
> View this message in context: http://cxf.547215.n5.nabble.com/XML-Schema-and-REST-tp5140807p5140807.html
> Sent from the cxf-user mailing list archive at Nabble.com.