The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

XML -- How to get started?

Hey everyone -

I'm trying to map data from CLI commands into a database and eventually into an XML format that I can build XSLT transforms to generate webpages and reports.

This is also an exercise in learning how to work with XML.

The app I'm pulling stuff from is a software distribution application on Unix.

I'm trying to design the XML template that I'm going to be using, but I'm not really sure about what I should be doing... here is an example of what I have so far:

<distribution distid=12345, type=Software_Distribution>
  < ... other data about the distribution >
    <target type=endpoint>

Does this look ok, or am I missing something? Pointers to articles would be appreciated!
Duff Send private email
Thursday, April 28, 2005
You can learn about XML in general at . The formal way define an XML template is called XML Schema. You can learn about it at . One advantage of using a schema instead of an informal template is that then you can validate your XML files against your schema.
KevinJ Send private email
Thursday, April 28, 2005
Simpler than a schema (though also somewhat less expressive) is a Document Type Declaration (or DTD). If I were you, I'd learn how DTDs work before learning anything about XML Schemas.
Benji Smith Send private email
Friday, April 29, 2005
Looks all right. Don't forget the <?xml version="1.0"?> at the top. If it's an experiment I wouldn't worry about writing a DTD or Schema yet. As for transforming the XML, XSLT has a lot of benefits but it's not the only way. Depending on your desired output you could try walking the DOM in Javascript or a server-side language (like PHP). If you're not doing something that's seen in a web browser, then Saxon or Instant Saxon can do XSLT transforms from the command line. To do useful things in XSLT you'll also want to read up on XPath. XPath is the language for querying XML documents. The best (but hardest to read) source for any of this is

I've tried all three of the methods I've mentioned to access or transform XML. Leveraging skills you already have can be very helpful. If you know a language that can parse XML (and access it as a tree, not just dumb text) then try it with that first. Then get into XSLT if you think it better suits your needs.
Rob Send private email
Friday, April 29, 2005
Rob, going without a DTD or Schema might be a bad idea. I don't think the poster understands the difference between XML and HTML very well, and a good tutorial on Schema could clear that up. Our poster's sample is missing quotation marks on the attributes.

Duff, This line:

<distribution distid=12345, type=Software_Distribution>

should be like this:

<distribution distid="12345", type="Software_Distribution">

This is something a validator could clear up. Most people use validators integrated into their editors, or just set up their code to validate and run the files through their code. A search for "xml editor" on google turns up most popular validating XML editors. Java provides hooks in various APIs for validating. JAXB is my favorite API.

If you want a totally free validating editor, download NetBeans.
Ben Atkin Send private email
Saturday, April 30, 2005
I suppose it depends on your approach to learning. I find that a lot of people (myself included) need to see some results as feedback to keep learning. The XML standards can be a very dry read. My approach has been to start out with some experiments, get some feedback and learn from my mistakes. After getting a feel for things, I have no problem diving into the mountain of standards because I can relate the explanations beck to my own mistakes.

I have a friend who has taken the exact reverse approach. He started by reading the standards meticulously, then built a Schema and started doing things with it. I have a hard time relating because my advice is always to "just try something."

So yes, my advice isn't the best for everybody. And I don't mean to imply that having no DTD or Schema is right for a production environment. I just think it's a common shortcut for someone who wants to see what XML can do.
Rob Send private email
Monday, May 02, 2005
Ben Atkin said that this line:

<distribution distid=12345, type=Software_Distribution>

should be like this:

<distribution distid="12345", type="Software_Distribution">

but he's wrong. There shouldn't be a comma between the attributes. It should actually look like this:

<distribution distid="12345" type="Software_Distribution">
Benji Smith Send private email
Monday, May 02, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz