I agree it would be nice to have a SQL-DDL standard but that isn't what I was interested in. I actually wanted a W3C XML Schema that mirrored a particular datbase. The JCA-RDBMS adapter I am using takes XML and maps the data in the XML to a DML query. When setting this up, it asks you to describe the input XML using XML Schema. Often that XML Schema maps fairly well to a particular table so I thought of using Middlegen to generate those for me.
Thanks fo your feedback. I will let you know if I find a way to use Middlgen to help me out. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Rod > Macpherson > Sent: Tuesday, February 04, 2003 8:34 PM > To: [EMAIL PROTECTED] > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > Hal, > > What we are missing is an industry standard SQL-DDL schema > specification. What XML Spy is doing does not even attempt to > address that problem. In this example they have defined a > FLIGHTS element and the constituent elements that comprise a > FLIGHTS record and so on. Where is the schema that defines > the database structure in general? What we need is a schema > that says a TABLE has FIELD elements and CONSTRAINT elements > and the FIELD element has a SQLTYPE element and it has > such-and-such attributes. Once you have a standard XML schema > that describes a SQL-99 compliant database, for example, you > can create instance of that schema. Let's call it the > SQL-99-XML-SCHEMA (in general you would use a guaranteed > unique name such as a registered URL but you get the > picture). Now what we can do is create an XML document that > uses the SQL-99-XML-SCHEMA. The TABLE element would have a > NAME attribute and in your case a TABLE element named FLIGHTS > would exist. HUGE difference here. There is no "FLIGHTS" > schema type, there is a "TABLE" schema type with a name attribute. > > Anyway, the main point is that the schema being generated by > XML Spy is entirely useless for the purpose you initially > suggested. It's a specific schema that describes instances of > XML documents tied to a fixed database schema. Unless > everybody has a FLIGHTS database it's not really useful. It's > extremely useful for a java application using, say, castor to > map objects to XML and vice versa. > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] On Behalf > Of Hal Deadman > Sent: Tuesday, February 04, 2003 4:44 PM > To: [EMAIL PROTECTED] > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > I just tried XML Spy 5 (release 3) and it generated a W3C XML > Schema from a the database schema I picked. It doesn't appear > to be very flexible or configurable and it doesn't infer xml > schema constraints from the database constraints (although > you can add them manually). I don't think you can configure > datatype mappings or influence the structure of the schema > (Russian doll vs. flat dtd style with named types) > > It also appears that the XML schema it generates captures the > structure of the database tables but XML instance documents > based on that schema would not be able to store multiple rows > of data for the elements defined in the schema. This is what > it came up with for the middlegen airline schema. > > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> > <xs:element name="FLIGHTS"> > <xs:complexType> > <xs:sequence> > <xs:element name="FLIGHT_ID" > type="xs:decimal"/> > <xs:element name="NAME"> > <xs:simpleType> > <xs:restriction > base="xs:string"> > > <xs:maxLength value="32"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > <xs:element > name="DEPARTURE_UTC" type="xs:dateTime"/> > <xs:element name="ARRIVAL_UTC" > type="xs:dateTime"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element name="PERSONS"> > <xs:complexType> > <xs:sequence> > <xs:element name="PERSON_ID" > type="xs:decimal"/> > <xs:element name="FIRST_NAME"> > <xs:simpleType> > <xs:restriction > base="xs:string"> > > <xs:maxLength value="32"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > <xs:element name="LAST_NAME"> > <xs:simpleType> > <xs:restriction > base="xs:string"> > > <xs:maxLength value="32"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element name="RESERVATIONS"> > <xs:complexType> > <xs:sequence> > <xs:element > name="RESERVATION_ID" type="xs:decimal"/> > <xs:element name="PERSON_ID" > type="xs:decimal"/> > <xs:element name="FLIGHT_ID" > type="xs:decimal"/> > <xs:element > name="REGISTRATION_UTC" type="xs:dateTime"/> > <xs:element name="COMMENTARY"> > <xs:simpleType> > <xs:restriction > base="xs:string"> > > <xs:maxLength value="200"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:schema> > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED]]On Behalf Of Rod > > Macpherson > > Sent: Tuesday, February 04, 2003 4:44 PM > > To: [EMAIL PROTECTED] > > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > > > > It does and I have used it and it works fine on a small > > schema. Here's the question: what XML schema is it > > generating? Answer: XML Spy's proprietary database schema. We > > really do need a standard for this. > > > > -----Original Message----- > > From: Hal Deadman [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, February 04, 2003 1:34 PM > > To: [EMAIL PROTECTED] > > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > > > > It looks like XML Spy 5 has support for "Generation of > > DTD/Schema from database". Haven't tried it and don't own > > that version of the product yet, but at least someone must > > have a use for it. > > > > http://www.altova.com/matrix.html > > Search for "Generation of DTD/Schema from database". > > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED]]On > Behalf Of Hal > > > Deadman > > > Sent: Tuesday, February 04, 2003 2:45 PM > > > To: [EMAIL PROTECTED] > > > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > > > > > > > 1) This page > > > (http://www.xml.com/pub/a/2000/11/29/schemas/part1.html?page=6) > > > describes how to model relations, although I am not an expert. It > > > appears that you would use the <xsd:key/> and <xsd:keyref/> > > to define > > > a pk type > > > constraint and an then refer to that constraint (fk-type > > > constraint). They refer to elements via xpath and keyref > refers to a > > > key via the key's name. > > > > > > 2) http://www.w3.org/XML/Schema is the standard. This is > > the standard > > > that is replacing DTDs. It's not necessarily meant to > replace data > > > models but there are many similarities between XML schemas and a > > > database schema. You > > > can enforce things in XML schema such as uniqueness, > > > relationships, data > > > types, constrained datatypes, etc that you couldn't do in > > > DTDs. I believe > > > J2EE 1.4 describes all of it's XML files (ejb-jar deployment > > > descriptors) > > > using XML schema instead of DTDs. > > > > > > 3) The reasons I was interested were because I need to provide XML > > > schemas that map closely to a database table for use with a JCA > > > adapter to a database in an XML based workflow tool. > > > > > > I also saw a proposal from BEA for XMLBeans that takes an > > XML schema > > > and generates XML schema aware and constrained java > objects. Wasn't > > > planning to use that but I thought it might be another reason to > > > want to quickly generate an XML schema. > > > http://www.javaskyline.com/20030127_bea.html > > > http://workshop.bea.com/xmlbeans/XsdUpload.jsp > > > > > > On the XML schema home page, there is a big list of tools > that work > > > with XML schemas, but I didn't notice any that help generate them > > > (from anything > > > other than DTDs). One example is Castor, which is described > > > as: "Castor > > > provides the only open-source Schema Object Model that loads > > > your XML Schema > > > in a Java representation. It also generates Java classes > > > given an XML Schema > > > and performs validation." Not being a Castor user, I don't > > > know if they > > > would benefit from having an XML schema generated for them or not. > > > > > > I looked into Torque which is a sub-project of Turbine on Jakarta. > > > They generate an "XML schema" from a database but it's not the > > > standard XML schema, rather it is a representation of a > database the > > > schema in their own > > > XML format. > > > > > > XML Schema is supposed to be a big part of Microsoft Office > > 11, maybe > > > being able to create schemas from existing data models would be > > > useful there, although maybe Microsoft supports that. I > don't know. > > > http://www.microsoft.com/presspass/features/2002/nov02/11-12XM > > > LOffice.asp > > > > > > I don't really know how useful this would be for people and > > it may not > > > make sense. I am about to start a project where I will get some > > > exposure to XML schema. As I learn more about XML schema, I will > > > keep Middlegen in mind and > > > see if I think it would be useful. > > > > > > Hal > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > > [mailto:[EMAIL PROTECTED]]On > > > Behalf Of Aslak > > > > Helles�y > > > > Sent: Tuesday, February 04, 2003 1:47 PM > > > > To: [EMAIL PROTECTED] > > > > Subject: RE: [Middlegen-user] xml schema from middlegen? > > > > > > > > > > > > 3 questions: > > > > > > > > 1) How would you model relations? Using ids? > > > > 2) Is there any kind of standard for this kind of schemas? > > > > 3) Who else than you would need this? > > > > > > > > Aslak > > > > > > > > > -----Original Message----- > > > > > From: [EMAIL PROTECTED] > > > > > [mailto:[EMAIL PROTECTED]]On > > > Behalf Of Hal > > > > > Deadman > > > > > Sent: 4. februar 2003 19:40 > > > > > To: [EMAIL PROTECTED] > > > > > Subject: [Middlegen-user] xml schema from middlegen? > > > > > > > > > > > > > > > I have run across a couple cases where it would be nice to > > > > have a W3C XML > > > > > Schema that mirrors an existing database schema. Are there > > > > any tools out > > > > > there that do that? Would that make sense as a > > middlegen plug-in > > > > > or at all? It wouldn't make use of Xdoclet but the information > > > > > that > > > > Middlegen has > > > > > regarding the tables, columns, and relationships > would be used. > > > > > > > > > > One thing that wouldn't be typical of a Middlgen > > plug-in is that > > > > > there would be one velocity template to generate the > entire XML > > > > > schema for the set of DB > > > > > tables rather than one template that gets executed for > > each table. > > > > > > > > > > I suppose there would have to be some mappings established > > > > between XML > > > > > datatypes and JDBC datatypes and this information would > > need to be > > > > > available in the template. > > > > > > > > > > I haven't worked much with XML Schema so most of what I > > > > know is based on > > > > > this article: > > > > > > > > > http://www.xml.com/pub/a/2000/11/29/schemas/part1.html?page=1 > > > > The article > > > > > talks about unique indexes and pk/fk type xml schema > > equivalents > > > > > on page 6. > > > > > > > > > > Below is an example of what a schema might look like for a > > > > single table. > > > > > > > > > > If you had a table like this: > > > > > CREATE TABLE COMPANY ( > > > > > COMPANY_ID NUMBER, > > > > > COMPANY_NAME VARCHAR2 (100), > > > > > TICKER VARCHAR2 (20), > > > > > MODIFIED_DATE DATE, > > > > > CREATED_DATE DATE) > > > > > > > > > > You could create a velocity template that generated a > > > > schema like this: > > > > > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > > > > elementFormDefault="qualified"> > > > > > <xsd:simpleType name="companyNameType"> > > > > > <xsd:restriction base="xsd:string"> > > > > > <xsd:maxLength value="100"/> > > > > > </xsd:restriction> > > > > > </xsd:simpleType> > > > > > <xsd:simpleType name="tickerType"> > > > > > <xsd:restriction base="xsd:string"> > > > > > <xsd:maxLength value="20"/> > > > > > </xsd:restriction> > > > > > </xsd:simpleType> > > > > > <xsd:complexType name="companyType"> > > > > > <xsd:sequence> > > > > > <xsd:element name="company_id" type="xsd:integer"/> > > > > > <xsd:element name="company_name" > type="companyNameType"/> > > > > > <xsd:element name="ticker" type="tickerType"/> > > > > > <xsd:element name="modified_date" type="xsd:date"/> > > > > > <xsd:element name="created_date" type="xsd:date"/> > > > > > </xsd:sequence> > > > > > </xsd:complexType> > > > > > <xsd:complexType name="companyListType"> > > > > > <xsd:sequence> > > > > > <xsd:element name="company" type="companyType" > > minOccurs="0" > > > > > maxOccurs="unbounded"/> > > > > > </xsd:sequence> > > > > > </xsd:complexType> > > > > > <xsd:element name="companies" type="companyListType"/> > > > > > </xsd:schema> > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > This SF.NET email is sponsored by: > > > > > SourceForge Enterprise Edition + IBM + LinuxWorld = > > > Something 2 See! > > > > > http://www.vasoftware.com > > > > > _______________________________________________ > > > > > middlegen-user mailing list > [EMAIL PROTECTED] > > > > > https://lists.sourceforge.net/lists/listinfo/middlegen-user > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.NET email is sponsored by: > > > > SourceForge Enterprise Edition + IBM + LinuxWorld = > > Something 2 See! > > > > http://www.vasoftware.com > > > > _______________________________________________ > > > > middlegen-user mailing list [EMAIL PROTECTED] > > > > https://lists.sourceforge.net/lists/listinfo/middlegen-user > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.NET email is sponsored by: > > > SourceForge Enterprise Edition + IBM + LinuxWorld > =omething 2 See! > > > http://www.vasoftware.com > > > _______________________________________________ > > > middlegen-user mailing list [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/middlegen-user > > > > > > > > ------------------------------------------------------- > > This SF.NET email is sponsored by: > > SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 See! > > http://www.vasoftware.com > > _______________________________________________ > > middlegen-user mailing list [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/middlegen-user > > > > > > ------------------------------------------------------- > > This SF.NET email is sponsored by: > > SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 See! > > http://www.vasoftware.com > > _______________________________________________ > > middlegen-user mailing list [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/middlegen-user > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 See! > http://www.vasoftware.com > _______________________________________________ > middlegen-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/middlegen-user
<<attachment: winmail.dat>>
