I have a xml file like this
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="file:/dev/null" iosp="lasp.tss.iosp.ValueGeneratorIOSP" start="0" increment="1">
<attribute name="title" value="Vector time series"/>
<dimension name="time" length="100"/>
<variable name="time" shape="time" type="double">
<attribute name="units" type="String" value="seconds since 1970-01-01T00:00"/>
</variable>
<group name="Vector" tsdsType="Structure" shape="time">
<variable name="x" shape="time" type="double"/>
<variable name="y" shape="time" type="double"/>
<variable name="z" shape="time" type="double"/>
</group>
</netcdf>
And I want to the value of the nodes whose name is either variable or group, so what's the right syntax to do things like?
<xsl:value-of select="/netcdf/variable or /netcdf/group"/>
Thanks in advance
This transformation:
when applied on the provided XML document:
produces (what I guess is) the wanted result:
Do note:
<xsl:value-of>
outputs the string value, while<xsl:copy-of>
outputs the node(s). In your case the string value of either element is empty on white-space only, so you probably want the elements themselves.This is really an XPath question and there are different possible solutions:
(the above is used in the transformation above), or:
This one uses the XPath union operator
/