You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Aristedes Maniatis <ar...@ish.com.au> on 2008/12/04 11:44:33 UTC

schema for map XML

I've put together a preliminary schema. I am sure adjustment will be  
needed, but I think it is a good first cut. I'd appreciate some  
feedback about whether it validates your models, so please take your  
xxx.map.xml file and hand edit the top of it to change this:

<?xml version="1.0" encoding="utf-8"?>
<data-map project-version="3.0">

to this

<?xml version="1.0" encoding="utf-8"?>
<data-map project-version="3.0" xmlns="http://cayenne.apache.org/xml/ns/map 
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://apache.org/xml/ns/cayenne http://people.apache.org/~amaniatis/cayenneMap.xsd 
">



Then please use a tool to validate this schema. Personally I use  
Oxygen which is really nice, but anything will do. You can even write  
a little Java tool to do it [1]. Ultimately that's how Cayenne Modeler  
will validate the XML to see that it matches the schema.

We'll need to discuss how to name the namespace, and it might be nice  
to put lots of documentation into the schema file itself which will  
help people who want to dive in.



Ari




[1] http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html


-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: schema for map XML

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Dec 4, 2008, at 3:28 PM, Andrus Adamchik wrote:

>  So I can only think of cases that would help us internally, but  
> will not affect the end users:
>
> * Validation as a part of map-saving unit tests
> * Switching from manual XML parser to an auto-generated parser based  
> on schema (such as JAXB; although I decided against JAXB some time  
> ago, as it would add yet another hard dependency to Cayenne, and  
> will require a rewrite of a piece of Cayenne that already works  
> well. So I am just using it as an example).
>
> Other ideas?

Oh, here is one more:

* "Raw XML" view in the Modeler. Something I wanted us to have for  
some time.

Andrus


Re: schema for map XML

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 05/12/2008, at 12:28 AM, Andrus Adamchik wrote:

> Nice. I don't think it is complete to actually use it for the real  
> map validation, but this is a great start.

Well, it validates several maps I throw at it. I haven't compared it  
to the code, but I did try to generate various maps and couldn't break  
it. I'm interested if people could try to validate their maps against  
it and find any breakages.


> I guess the immediate value of it is documenting the format for  
> manual editing.

That's certainly helpful.


> Now I am wondering where in the model lifecycle during development  
> and runtime would it be appropriate/useful to do automated  
> validation of the mapping? In other words where the benefit of  
> validation would justify the overhead? The map semantical problems  
> are rare, as most people are using the Modeler (that presumably  
> generates a correct mapping).

That may be the case, but if we don't have the modeler check for  
validity on every save, the schema will not be maintained since there  
is no incentive to do so and it will fall into disrepair. I'd suggest  
a validation on every save/open which does not prevent the save/open  
but shows a dialog if validation is not successful.

I'd suggest this is useful since some people edit the XML by hand  
(long live 'emacs/vi'!) but still would like Cayenne modeler to  
validate their schema. It will also provide a second level check that  
Cayenne modeler isn't outputting rubbish XML under some circumstances  
(eg. XML which isn't properly encoded or nested incorrectly).


> So I can only think of cases that would help us internally, but will  
> not affect the end users:
>
> * Validation as a part of map-saving unit tests
> * Switching from manual XML parser to an auto-generated parser based  
> on schema (such as JAXB; although I decided against JAXB some time  
> ago, as it would add yet another hard dependency to Cayenne, and  
> will require a rewrite of a piece of Cayenne that already works  
> well. So I am just using it as an example).


I agree that there is little benefit in this.

Ari



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: schema for map XML

Posted by Andrus Adamchik <an...@objectstyle.org>.
Nice. I don't think it is complete to actually use it for the real map  
validation, but this is a great start. I guess the immediate value of  
it is documenting the format for manual editing.

Now I am wondering where in the model lifecycle during development and  
runtime would it be appropriate/useful to do automated validation of  
the mapping? In other words where the benefit of validation would  
justify the overhead? The map semantical problems are rare, as most  
people are using the Modeler (that presumably generates a correct  
mapping). So I can only think of cases that would help us internally,  
but will not affect the end users:

* Validation as a part of map-saving unit tests
* Switching from manual XML parser to an auto-generated parser based  
on schema (such as JAXB; although I decided against JAXB some time  
ago, as it would add yet another hard dependency to Cayenne, and will  
require a rewrite of a piece of Cayenne that already works well. So I  
am just using it as an example).

Other ideas?

Andrus


On Dec 4, 2008, at 12:44 PM, Aristedes Maniatis wrote:
> I've put together a preliminary schema. I am sure adjustment will be  
> needed, but I think it is a good first cut. I'd appreciate some  
> feedback about whether it validates your models, so please take your  
> xxx.map.xml file and hand edit the top of it to change this:
>
> <?xml version="1.0" encoding="utf-8"?>
> <data-map project-version="3.0">
>
> to this
>
> <?xml version="1.0" encoding="utf-8"?>
> <data-map project-version="3.0" xmlns="http://cayenne.apache.org/xml/ns/map 
> " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://apache.org/xml/ns/cayenne http://people.apache.org/~amaniatis/cayenneMap.xsd 
> ">
>
>
>
> Then please use a tool to validate this schema. Personally I use  
> Oxygen which is really nice, but anything will do. You can even  
> write a little Java tool to do it [1]. Ultimately that's how Cayenne  
> Modeler will validate the XML to see that it matches the schema.
>
> We'll need to discuss how to name the namespace, and it might be  
> nice to put lots of documentation into the schema file itself which  
> will help people who want to dive in.
>
>
>
> Ari
>
>
>
>
> [1] http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>
>


Re: schema for map XML

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 04/12/2008, at 9:44 PM, Aristedes Maniatis wrote:

> I've put together a preliminary schema.


I've just updated the schema to capture all the listeners possible. I  
think that is now everything that should go in.

http://people.apache.org/~amaniatis/cayenneMap.xsd


Ari Maniatis




-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A