Being a newbie with XSLT transformation code please excuse my neivte.
In addition, I am not sure what I want to do can be done with xslt so
I apologize up front for asking anything stupid
I have a shell script that needs to get values from an XML file. What
I want to do is transform the XML into something more KSH friendly so
it can be easy to parsed in my KSH script.
I would like to go through an entire XML document and for every
"element" and "element/attribute" print the associated value in NVP
(name value pair).
Assume the following XML file:
<?xml version="1.0" encoding="UTF-8"?>
<abc>
<def>
<mno>2008-06-11-13:15:59</mno>
<pqr stu="World">Hello</pqr>
</def>
<ghi>
<jkl vwx="12345678" </jkl>
</ghi>
</abc>
Below is my desired out. As you can see for each element I print
"element=value" and for each attribute within an element I print
"element_attribute=value"
mno=2008-06-11-13:15:59
pqr=Hello
pqr_stu=World
jkl_vwx=12345678
Can somebody point me in the right direction or provide me with some
sample XSLT transformation code that can do this.
Keep in mind, I would like to keep this as generic as possible. That
is I don't want to reference element or attributes by names. I would
like something like this
for each element
do
if attribute
print element_attribute=value
else
print element=value
done
As oppose to say search element "pqr" and print value
Thanks to all who answer