Virginia Kirkendall <vk*********@ho tmail.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>DETECTIN G AND BLOCKING</Title>
<CrossCut>BAS E</CrossCut>
<PI>John Jones</PI>
<Institution>IN STITUTE</Institution>
<Project_Summar y>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>BAS E</CrossCut>
<PI>Mary QuiteContrary</PI>
<Institution>BO STON UNIVERSITY</Institution>
<Project_Summar y>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>BAS E</CrossCut>
<PI>Harry Pit</PI>
<Institution>Un iversity</Institution>
<Project_Summar y>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_S TACK[1]} == Programs ]]; then
unset Title Crosscut Pi Institution Project_Summary Start End
fi
}
data () {
case ${XML_ELEMENT_S TACK[1]} in
Title|CrossCut| PI|Institution| Project_Summary |Start|End)
strcat ${XML_ELEMENT_S TACK[1]} "$1" ;;
esac
}
end () {
if [[ ${XML_ELEMENT_S TACK[1]} == Programs ]]; then
cat <<+ EOF
Title={$Title}
CrossCut={$Cros sCut}
PI={$PI}
Institution={$I nstitution}
Project_Summary ={$Project_Summ ary}
Start={$Start}
End={$End}
EOF
fi
}
xml -s start -d data -e end "`< file.xml`"
You should get
Title={DETECTIN G AND BLOCKING}
CrossCut={BASE}
PI={John Jones}
Institution={IN STITUTE}
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**********@y ahoo.ca>
Open Geometry Consulting, Toronto, Canada