views:

254

answers:

1

I'm trying to use Quartz Composer to create a continuous integration build radiator.

I put together a simple XML file to describe the projects and the latest success of each of their workflows:

<projects>
  <project>
    <title>Project A</title>
    <workflows>
      <workflow>
        <title>Build 1.0</title>
        <status>success</status>
      </workflow>
      <workflow>
        <title>Build 2.0</title>
        <status>success</status>
      </workflow>
    </workflows>
  </project>
  <project>
    <title>Project B</title>
    <workflows>
      <workflow>
        <title>Build 1.0</title>
        <status>success</status>
      </workflow>
    </workflows>
  </project>
</projects>

This will obviously have more information but I'm just trying to get the basics working for now. I set up a composition and am using XML Downloader to load the above XML file from the filesystem.

The problem I'm having is thus: when I use the Structure Key Member patch on an element with multiple children, I get back multiple children BUT when I use Structure Key Member on an element with just one child I get back the single child instead of a collection of 1 item.

I've illustrated the problem below in an example composition:

Quartz Composition

Am I doing something wrong? Is this expected behavior? Why isn't the lower chain not also returning a QCStructure?

+1  A: 

Unfortunately, the XML Downloader patch doesn't properly handle multiple adjacent empty elements.

One possible workaround might be to restructure your XML to remove the "projects" group, and just make "project" a property of each "workflow":

<workflows>
  <workflow project="Project A">
    <title>Build 1.0</title>
    <status>success</status>
  </workflow>
  <workflow project="Project A">
    <title>Build 2.0</title>
    <status>success</status>
  </workflow>
  <workflow project="Project B">
    <title>Build 1.0</title>
    <status>success</status>
  </workflow>
</workflows>

This produces a structure with usable results.

(When XML Downloader builds a structure from XML, attributes are equivalent to child tags, so "project" could be either and you'd get the same result.)

smokris
Well that stinks (the XML Downloader issue).I tried not wrapping my workflows and using Structure Key Member to pull "workflow" instead of "workflows". That results in the upper patch returning nothing and the bottom chain returning the single workflow in Project B.I'm more apt to just throw an extra blank <workflow/> in my file and reducing the count by one when iterating through them.
spilth
I realized I could take your suggestion a little bit further for a good solution. I decided to remove projects altogether and just store the project title with each workflow. Now I just have a big list of workflows and don't have to worry about single item collections.
spilth
If you could alter your answer to reflect my changes (based on your suggestion) that would be great.
spilth
Answer altered.
smokris
Thanks, smokris. Also good to know about the attribute/element equivalence.
spilth