[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to create a tabular data format in XML schema?

  • From: Griffith Feeney <gfeeney@g...>
  • To: Benjamin Lim <benjamin_lim@d...>
  • Date: Fri, 10 Aug 2001 07:27:30 -1000

xml tabular data
At 06:07 PM 8/10/01 +0800, you wrote:
>   Hi,     wonder if any one has done the  above, i am new to XML and would
>like to know how to create a tabular data  format in XML schema so that i
>can capture a MS Word document with table into  XML format.   Rgds, Ben

I don't know about Word-XML conversion, but here's a simple DTD (not
schema) based XML document for tabular data.

<?xml version="1.0"?>
<!DOCTYPE datatable[
  <!ELEMENT datatable (title, dimension+, cell+ )>
  <!ELEMENT title     (#PCDATA)>
  <!ELEMENT dimension (name, value+)>
  <!ELEMENT cell      (#PCDATA)>
  <!ELEMENT name      (#PCDATA)>
  <!ELEMENT value     (#PCDATA)>
  <!ATTLIST dimension code      CDATA #IMPLIED>
  <!ATTLIST value     code      CDATA #IMPLIED>
  <!ATTLIST cell      Sex       CDATA #REQUIRED
                      Residence CDATA #REQUIRED>
]>

<datatable>
    <title>Table 1. Population by Sex and Residence</title>
    <dimension>
        <name>Sex</name>
        <value code="1">Male</value>
        <value code="2">Female</value>
    </dimension> 
    <dimension>
        <name>Residence</name>
        <value code="1">Urban</value>
        <value code="2">Rural</value>
    </dimension>
    <cell Sex="Male" Residence="Urban">4000</cell>
    <cell Sex="Female" Residence="Urban">4000</cell>
    <cell Sex="Male" Residence="Rural">1000</cell>
    <cell Sex="Female" Residence="Rural">1000</cell>
</datatable>

The general idea can be elaborated in several directions: allowing notes to
be attached to any table element; "vectorizing" the cell data into a single
element with an implicit order; moving the upper DTD code to a separate DTD
file, keeping only the ATTLIST lines for the table dimensions; putting
dimension specifications into the DTD as entities, so that they can be
referenced by multiple table documents.

Caveat. "Table" in SGML/HTML/XML seems to refer more to a typographical
construct than a data structure. Above is for a data structure that might
be called a "multidimensional associative array" (perl) or
"multidimensional dictionary" (python). Arrays in R/S/S+ implement this
structure: arrays with names associated with each value of each dimension
and the ability to index cell values using names rather than index numbers.



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.