Virginia Kirkendall <vk*********@hotmail.com> wrote:
Hi: I'm new with this & need help creating a XSL table that looks
like the following:
---------------------------------------------------------
| | | | | |
|Title |CrossCut |Institution |START |END |
| | | | | |
| | |PI | | |
| | | | | |
|Project| | | | |
|Summary| | | | |
---------------------------------------------------------
XML :
<Programs>
<Title>DETECTING AND BLOCKING</Title>
<CrossCut>BASE</CrossCut>
<PI>John Jones</PI>
<Institution>INSTITUTE</Institution>
<Project_Summary>build an effective</Project_Summary>
<Start>2004-09-15T00:00:00</Start>
<End>2006-09-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS</Title>
<CrossCut>BASE</CrossCut>
<PI>Mary QuiteContrary</PI>
<Institution>BOSTON UNIVERSITY</Institution>
<Project_Summary>This application describes an
important</Project_Summary>
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS</Title>
<CrossCut>BASE</CrossCut>
<PI>Harry Pit</PI>
<Institution>University</Institution>
<Project_Summary>This application describes an
important</Project_Summary>
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
The desired effect will be to sorta group by Title (see that two
titles are same) with subsequent details spanning the row.
Thanks very much for any help I could really use it-- Ginger
Get a patched Bash shell with Expat XML parser interface,
http://freshmeat.net/projects/bashdiff/
help xml
help basp
First, parsing of your XML text would go something like
start () {
if [[ ${XML_ELEMENT_STACK[1]} == Programs ]]; then
unset Title Crosscut Pi Institution Project_Summary Start End
fi
}
data () {
case ${XML_ELEMENT_STACK[1]} in
Title|CrossCut|PI|Institution|Project_Summary|Star t|End)
strcat ${XML_ELEMENT_STACK[1]} "$1" ;;
esac
}
end () {
if [[ ${XML_ELEMENT_STACK[1]} == Programs ]]; then
cat <<+ EOF
Title={$Title}
CrossCut={$CrossCut}
PI={$PI}
Institution={$Institution}
Project_Summary={$Project_Summary}
Start={$Start}
End={$End}
EOF
fi
}
xml -s start -d data -e end "`< file.xml`"
You should get
Title={DETECTING AND BLOCKING}
CrossCut={BASE}
PI={John Jones}
Institution={INSTITUTE}
Project_Summary={build an effective}
Start={2004-09-15T00:00:00}
End={2006-09-14T00:00:00}
for the first <Programs>...</Programs> section. Now, if you consider
cat <<+ EOF
...
EOF
as HTML template, with '...' replaced by your table template, then your
solution becomes self-evident. If you have HTML code in a file, then
you can use my BASP (Bash Server Pages) engine.
For that, your template would go something like
<table> ...
<td><% echo -n $Title %></td>
<td><% echo -n $CrossCut %></td>
...
</table>
and you would print it, like
basp "`< template.html`"
--
William Park <op**********@yahoo.ca>
Open Geometry Consulting, Toronto, Canada