I want to combine the results of three zip-filter queries on an xml tree. The XML I am parsing looks like this:
<someroot>
<publication>
<contributors>
<person_name>
<surname>Surname A</surname>
</person_name>
<person_name>
<given_name>Given B</given_name>
<surname>Surname B</surname>
<suffix>Suffix B</suffix>
</person_name>
</contributors>
</publication>
</someroot>
From this example you can see that <given_name>
and <suffix>
are optional - only <surname>
is required. Here in lies my problem - if I run three separate queries the responses I get will be out of kilter with each other:
(xml-> xml :publication :contributors :person_name :given_name text)
(xml-> xml :publication :contributors :person_name :surname text)
(xml-> xml :publication :contributors :person_name :suffix text)
After running these three queries I will be left with three sequences whose cardinalities do not match; given_name
and suffix
will be length 1 while surname
will be length 2. This makes it impossible for me to combine the components of each name. I need to write a single query that will perform this name concatenation during sequence construction.
I'm looking at the very sparse documentation for clojure.contrib.zip-filter.xml
and can't figure out how I could do this (or if it is even possible). Unfortunately I am a Clojure (and Lisp) newbie! Can anyone point out how I can write a query that will concatenate three other embedded queries?