Help with XSL to render XML "Cousins"

Questions about XML that are not covered by the other forums should go here.
Posts: 1

Help with XSL to render XML "Cousins"

Sun Sep 11, 2016 5:42 pm

Hi all,

I'm a newbie to XML/XSL and could use some need help displaying and sorting values that are stored within the child nodes of two different parents (i.e., the data are "cousins").

The XML file includes a schedule of events happening today in different rooms of our building. Each event is represented by the <event> tag, which contains <space> and <event_details> nodes, each of which has child nodes where the values I want to display and sort are stored. It basically has the following structure (using an example with two records below, with closing tags removed for readability):

  • <event>
    • <space>
      • <space_name>Room 210
    • <event_details>
      • <event_name>English Literature
      • <event_startandendtime>9:20am to 10:30am
  • <event>
    • <space>
      • <space_name>Room 103
    • <event_details>
      • <event_name>Advanced Calculus
      • <event_startandendtime>8:00am to 9:10am

Using XSL, I am trying to output the schedule with the events listed in order by date in the following format:

event_startandendtime, event_name, space_name
event_startandendtime, event_name, space_name

For example:

8:00am to 9:10am, Advanced Calculus, Room 103
9:20am to 10:30am, English Literature, Room 210

So far, I've been unsuccessful. In one attempt to code it, I can generate a sorted list but I can't get the space_name to appear. In other attempt, I can get the space_name, but can't sort the list, nor do I have much control over where to place the space_name.

Is this a straightforward coding task or a much more complicated one for a newbie? Thanks a lot for any directions you can point me in!

Posts: 77

Re: Help with XSL to render XML "Cousins"

Tue Sep 13, 2016 8:13 pm

I am reading this during my lunch break, and decided to post some thoughts here.

Usually posts such as yours usually will not get a response from my experience. Why? There's plenty of resources available all over to get you started. From looking at what you have posted, no one will really be able to help you with what you wish to accomplish. What would help here is providing a sample XML document of what you wish to sort. What you posted looks like an outline of information, but it is not XML. If you are new to XML, as you have stated, it would be a good idea to learn what makes an XML document well-formed and valid.

Last, there is an old expression in computer programming: garbage in = garbage out. I am posting this in regards to your event_startandendtime containing: 9:20am to 10:30am. You may have no control over what your XML content looks like. However, if you were responsible for the creation of it, I would suggest atomic values as opposed to combining all this data into a single event_startandendtime node. This will make your sorting life much simpler.

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 1 guest