• Subject: Re: XML Attributes
  • From: Pete Hall <pbhall@xxxxxxxxxx>
  • Date: Fri, 17 Nov 2000 20:02:02 -0600

At 18:09 11/16/2000, Mike Pantzopoulos wrote:

>I know this is not an XML forum, but since this thread seems to be 
>acceptable, I'll continue. I've written some software to convert  our DDS 
>to an XML construct for communicating what used to be a display buffer to 
>an NT. Due to a bug it generated a very large value between two tags. It 
>then dawned on me that XML does not seem to allow a developer to describe 
>the attributes of data. Whatever is between the tags seems to be it. So if 
>a bug appears in a program and it generates a value between the tags of 
>9999999999999999 when in fact it should only be 99, then as far as XML is 
>concerned, it's correct. At least with a 5250 data stream there seems to 
>be some basic data type/structure checking done for you .
>Is there some mysterious way that XML allows the developer to define some 
>more sophisticated attributes than just a string of indeterminate length? 
>(as long as it's between two "well-formed" tags?
>Another example might be of an invoice amount. 
>Does  <amount>50000</amount> mean $500.00 or $50000?
>The idea of XML is great. It's just that its implementation seems too 

There are actually several ways that you can limit the damage from this 
kind of thing, as well as ensure that the required elements are present and 
valid. You can define a dtd (data type definition), in which you can 
specify the hierarchy of tags and what they can contain. The syntax of the 
dtd is, at least to me, a little counterintuitive though, and I haven't 
found an authoritive document that was written in a human readable language 
that really describes how to use it. Even according to W3C, dtds are a 
little lacking in robustness. The language has been handed down, virtually 
unchanged, or so I understand, from SGML. Data type support is limited to 
XML primitives (reeaally primitive). You specify a dtd schema in the xml 
document like this:

   <!DOCTYPE site SYSTEM "schemas/myschema.dtd">

A second, albeit currently unsanctioned alternative is the XML schema. This 
is a work in process, and it's championed chiefly by Microsoft, but I think 
the syntax is much easier to grasp, it's somewhat more robust, and it is 
going through the standard approval process, but it hasn't been blessed 
yet. It allows you to specify most normal data types (string, byte (i1), 
short integer (i2), long integer (i4), float, number (number can have any 
length), and currency (currency is curiously enough called "fixed.14.4", it 
doesn't seem to suffer rounding errors, and you can (for we yankees) format 
it perfectly well with 2 decimal positions. You specify an xml schema like 
this (this part is a secret - it took me a week to find):

   <schemaname xmlns="x-schema:schemas/myschema.xml">

In both examples, the document is in a subdirectory named "schemas" below 
the document root.

A third way, I think supported only by MS, is defining the data type in the 
xsl. I've not messed with this, but I know it's possible to do it. The real 
power is in the xml schema or dtd though, because you can specify which 
elements are valid, which are required (this can be conditional), what 
order they need to appear in (or any order), how many instances are allowed 
(minOccurs="0" maxOccurs="*" means any number or none - xml schema only). 
You can also specify the type of element, whether it can only have child 
elements, if it can have attributes and what they are, if it allows a data 
value, default values if it's not present, valid values if it's one of a 
finite number of discrete values, etc. If you get desperate, I could send 
you an example of both (you'd be stuck with my personal simpleminded style 

Both types of schemas are processed by the Microsoft products, although 
they are not currently validated at run time. Data values however, must be 
within range based on data type, or the document won't display, and default 
values do come through OK. Microsoft does have a validating parser but it's 
an add-in that you can install in IE5. They also have a freeware app called 
XMLNotepad that will validate document and schema (either xml or dtd). XML 
tools are kind of basic right now though, so don't expect too much.

Since you say you're sending XML to an NT box, it would probably be worth 
your while to do a little digging in MSDN: 
http://msdn.microsoft.com/xml/default.asp. There are also a number of sites 
besides MS that have coding examples too. Try searching for "XML example" 
on Yahoo or Google. Also read up on the DOM (Document Object Model) and SAX 
(haven't the faintest) standards, and XPath, which is a syntax for 
navigating through the XML document. It's all fun stuff, but a little 
frustrating at first.

Whatever happened to matching records and lookahead fields?


Pete Hall

| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].