Click to See Complete Forum and Search --> : Newbie: XML ordered lists and more


dcmiltown
01-11-2010, 09:23 PM
I'm very new to XML and I'm looking for a good single source format to export to both PDF and HTML. My boss suggests Word. I'd like to not do that.

Essentially I have a product catalog that I need to be able to sort the data by category / product / etc. My first task, and what I'd like help on, is figuring out how to put in a topic / description into the XML format.

The end result needs to look something like this:

Course Name: Course Title goes here
Length of Course: # of days in course
Overview: This is an overview of the course.
Prerequisites: These are the prerequisites.
Topics:

Topic 1
SubTopic
SubTopic
Sub Sub Topic
Topic 2
Sub Topic
Sub Sub Topic
Sub Sub Topic

etc...

Essentially, I am confused on what the proper markup should be for an ordered list. I need topic 1 to be the first element, with two subtopics below, and any sub sub topics within that.

Would the topic piece of the XML look like this?

<TOPIC>Topic 1</TOPIC
<SUBTOPIC>Topic 1 Sub Topic 1</SUBTOPIC>
<SUBSUBTOPIC>Topic 1 Sub Topic 1 Sub Sub Topic</SUBTOPIC>
...
...

and so on...

Or is there a better way to organize this within the XML document? Is XML the appropriate tool to use?

My goal is to build an HTML file using this XML content, and to use InDesign to build out a prinatable and PDF version of the content. I have everything else figured out in InDesign except how to properly sort the topic elements and sub topics. Each course can have numerous topics and sub topics.

Thanks for any help!

DC

Powersurge360
01-16-2010, 09:00 PM
For speed issues, you should look into a MySQL/PHP solution for building XML files on the fly. This resolves the issue of the user needing to load the XML file in its entirety (which can be a pain) and instead loads the relevant files only.

As far as structure, XML you sort of make up as you go along. Make sure it's well formed and that's all there really is to it. Whatever you feel to be the easiest to remember and is the best structured is what you should do.

Conversion to both XHTML and PDF (and a number of other things) is possible through XSLT, a simple language that is mostly HTML stuff with a bit of simple logic thrown in.

In summary, yes, XML is the right language to use, render XML on the fly where possible, and look into XSLT for conversions. Structure is a choice thing.

flowertwig
01-28-2010, 05:53 AM
Thsi is probably history by now, but my reply would be:
google on "xsl:sort", and I think you'll find examples of use. Take a look at w3schools xml course, too.