Returning to an old thread.
This is a great tool, but a Piotr mentioned, there is a problem with
foreign keys in Djano.
Sample xsd from
http://icm.eionet.europa.eu/schemas/dir200760ec/CA_UoM_1p0.xsd
generateDS generates the main model CA_UoM_model with all the elements
directly under the root element, however some of these are at the wrong end
of the relationship. I have marked up the model with what I think are the
correct field types below.
I have tried to analyse how we could detect a requirement for Foreign or
ManyToMany links. It is fairly difficult to generalise. I see your point
regarding the fundamental differences between xml and relational models.
A Foreign key at this end seems to be only detectable by inspection.
In general, maxOccurs > 1 indicates that either a ForeignKey (at the other
end) or a ManyToManyField is required. A ManyToMany field is symmetric,
while a Foreign key is asymmetric, with a one end and a many end, so a
Foreign key is a more restrictive subset of a ManyToMany key. So it might
be best to put in a ManyToManyField and insert a comment beside it to say
that the model should be inspected to determine whether a foreign key is
required, and a comment should be placed in the other model to say that a
relationship has been defined to the other model.
So:
model Parent_model(models.Model):
Child = models.ManyToManyField(Child) # Inspect to determine if a
ForeignKey is required, and at which end of the relationship.
model Child_model(models.Model):
# Parent = Models.ForeignKey(Parent_model) # Inspect to determine if
this is required. Remove Child from Parent_model if this is used.
Marked up model:
class CA_UoM_model(models.Model):
Description = models.CharField(max_length=1000, null=True,blank=True)
CreationDate = models.CharField(max_length=200, null=True,blank=True)
Email = models.CharField(max_length=200, null=True,blank=True)
GeneratedBy = models.CharField(max_length=200, null=True,blank=True)
Creator = models.CharField(max_length=200, null=True,blank=True)
#C_CD = models.CharField(max_length=1000, null=True,blank=True)
C_CD = models.ForeignKey(CountryCode, null=True,blank=True)
#WFDCompetentAuthorities = models.CharField(max_length=1000,
null=True,blank=True)
WFDCompetentAuthorities = models.BooleanField()
#CompetentAuthority = models.ForeignKey("CompetentAuthorityType_model")
# Foreign key from CompetentAuthorityType_model refers here
#WFDRiverBasinDistricts = models.CharField(max_length=1000,
null=True,blank=True)
WFDRiverBasinDistricts = models.BooleanField()
#UnitOfManagement = models.ForeignKey("UnitOfManagementType_model")
# Foreign key from UnitOfManagementType_mode refers here
METADATA = models.CharField(max_length=2000, null=True,blank=True)
URL = models.CharField(max_length=250, null=True,blank=True) # may be
many to many or foreign key
Like I say, this tool has helped me enormously.
Many Thanks.
Vincent
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users