LISTSERV mailing list manager LISTSERV 16.0

Help for XML-L Archives


XML-L Archives

XML-L Archives


XML-L@LISTSERV.HEANET.IE


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

XML-L Home

XML-L Home

XML-L  May 2002

XML-L May 2002

Subject:

Re: Question regarding DTDs

From:

Chris Proctor <[log in to unmask]>

Reply-To:

General discussion of Extensible Markup Language <[log in to unmask]>

Date:

Wed, 15 May 2002 09:00:47 -0600

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (155 lines)

Wow! Thanks for all the information, Ron. I'm still having a problem with
terminology, but I did mean that I use the DTD to validate my XML document.
This information is very useful in trying to understand the best way for us
to develop flexible applications.

Thank you very much!

Chris

-----Original Message-----
From: Ronald Bourret [mailto:[log in to unmask]]
Sent: Tuesday, May 14, 2002 5:29 PM
To: [log in to unmask]
Subject: Re: Question regarding DTDs


Chris Proctor wrote:

> I'm fairly new to XML, but I have written some applications to build XML
> documents. I've used DTDs to validate that my document is well-formed, but
I
> know that DTDs can do a lot for me.

Minor nitpick: DTDs are used to validate a document, they are not used
to check well-formedness. Validation is the process of checking that a
document conforms to the rules in a given DTD. Well-formedness has a
number of rules, but largely boils down to (a) every start tag has a
matching end tag, and (b) start and end tags are properly nested.

Well-formedness is required -- if a document isn't well-formed, it is,
by definition, not an XML document. Validity is optional -- a document
can be invalid with respect to a particular DTD and still be a legal XML
document. (The more common case is that there simply isn't a DTD that
applies -- a good example of this is XSLT stylesheets.)

> Can a DTD be used to actually build an
> XML document?  In other words, can I say "here's a database file or a
> tab-delimited file" and "here's the associated DTD" and use the DTD to
build
> the XML document? Forgive me if this is a stupid question, but we have so
> many vendors wanting data in a various number of formats. It would be
great
> if something like this is possible.  It would take a lot of the pressure
off
> of us.  I'd appreciate any input.

It's definitely not a stupid question.

This is definitely possible, but generally not as automatic as one might
hope. For example, suppose you have a comma-delimited file and a DTD and
want to get the data out of the comma-delimited file and into a document
that matches the DTD. To do this, you will need to define how the data
maps from one to the other.

For example, suppose you have the following comma-delimited file:

Ronald,Bourret,Programmer,rpbourret.com
Chris,Proctor,Manager of Systems Integration,Gart Sports

And the following DTD:

   <!ELEMENT People (Person)>
   <!ELEMENT Person (Company, FirstName, Title, LastName)>
   <!ELEMENT Company (#PCDATA)>
   <!ELEMENT FirstName (#PCDATA)>
   <!ELEMENT Title (#PCDATA)>
   <!ELEMENT LastName (#PCDATA)>

There is no way a program can tell which fields in the DTD match which
fields in the file. Worse yet would be a DTD like:

   <!ELEMENT A (B)>
   <!ELEMENT B (#PCDATA)>

How would you map the above file to this?

The solution in both cases is some sort of user-specified mapping
information from the file to the XML document. Given this mapping
information, a program can automatically transfer data from a non-XML
format (comma-delimited file, database, Word document, LDAP, etc.) to an
XML document.

There are several things to note here:

1) You will note that the DTD doesn't really get involved here. Instead,
it serves as a guideline to you when you are writing your mapping. That
is, it tells you the structure of the XML document that you want to map
to.

2) If the non-XML format has metadata (a header line in a
comma-delimited file, database metadata, etc.), it is generally possible
to generate the mapping automatically. However (and this is important)
that mapping will follow a fixed structure that is hard-coded into the
generation program. For example, if the document above had a header
line:

   FirstName, LastName, Title, Company

you would get an XML document that used these names in the order shown,
such as:

   <Rows>
      <Row>
         <FirstName>Ronald</FirstName>
         <LastName>Bourret</LastName>
         <Title>Programmer</Title>
         <Company>rpbourret.com</Company>
      </Row>
      ...
   </Rows>

This might not be the structure you want. In this case, you will
generally use XSLT to transform the resulting document to the structure
you want.

3) Even if you hand-code the mapping, there is a good bet that the tool
you use can only use a fixed structure. For example, a tool for
comma-delimited documents will only generate documents of the form:

   <Rows>
      <Row>
         <Property_1>...</Property_1>
         ...
         <Property_n>...</Property_n>
      </Row>
      ...
   </Rows>

Again, you will need to use XSLT to transform this to match your DTD.

4) As a general rule, I have seen no tools that can take metadata for a
non-XML format, a DTD, and generate a mapping between the two -- it's
simply too difficult. Instead, you either do a hand mapping between the
two or you start with one (e.g. metadata for a non-XML format) and
generate the other (e.g. a DTD) and the mapping.

5) You will need a different tool for each type of non-XML source (text
file, Word document, database, etc.) that you have. Here are some Web
sites you can use to find tools:

   http://www.garshol.priv.no/download/xmltools/
   http://www.rpbourret.com/xml/XMLDatabaseProds.htm
   http://www.xmlsoftware.com/
   http://www.xml.com/pub/listrescat
   http://www.freshmeat.net/search.php3?query=xml
   http://www.xmlarena.com/binthing~MenuID,11;WebPageID,17.htm

6) The tool you want may not exist.

7) If you're interested in the mappings between databases and XML
documents, see:

   http://www.xml.com/pub/a/2001/05/09/dtdtodbs.html

-- Ron

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

February 2017
August 2016
June 2016
March 2016
January 2016
July 2014
April 2014
January 2014
July 2013
February 2013
September 2012
August 2012
October 2011
August 2011
June 2011
January 2011
November 2010
October 2010
July 2010
June 2010
March 2010
February 2010
January 2010
November 2009
September 2009
August 2009
July 2009
May 2009
March 2009
December 2008
October 2008
August 2008
May 2008
March 2008
February 2008
January 2008
December 2007
October 2007
August 2007
June 2007
March 2007
January 2007
December 2006
September 2006
July 2006
June 2006
April 2006
February 2006
January 2006
November 2005
September 2005
August 2005
July 2005
June 2005
May 2005
March 2005
January 2005
October 2004
August 2004
July 2004
June 2004
May 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000
January 2000
December 1999
November 1999
October 1999
September 1999
August 1999
July 1999
June 1999
May 1999
April 1999
March 1999
February 1999
January 1999
December 1998
November 1998
October 1998
September 1998
August 1998
July 1998
June 1998
May 1998
April 1998
March 1998
February 1998
December 1997
November 1997
October 1997

ATOM RSS1 RSS2



LISTSERV.HEANET.IE

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager