xml - Is it possible to call a single XSLT Template for two or more nodes having different XPATH? -
i kind of not sure if possible or not hope is. want goes this:
i have xml structured follows:
<rootnode> <node1> <dataset1> <!--some xml tags here not necessary--> </dataset1> <dataset2> <!--some xml tags here not necessary--> </dataset2> <dataset3> <!--some xml tags here not necessary--> </dataset3> </node1> <node2> <dataset1> <!--some xml tags here not necessary--> </dataset1> <dataset2> <!--some xml tags here not necessary--> </dataset2> <dataset3> <!--some xml tags here not necessary--> </dataset3> </node2> <node3> <dataset1> <!--some xml tags here not necessary--> </dataset1> <dataset2> <!--some xml tags here not necessary--> </dataset2> <dataset3> <!--some xml tags here not necessary--> </dataset3> </node3> </rootnode>
what trying display datasets in html tables using xslt... want know if possible implement single template similar dataset elements. node1/dataset1
, node2/dataset1
, node3/dataset1
implemented via single template instead of triplicating code each possible xpath.
please note sample xml , names of parent nodes i.e. node1, node2, node3 etc unique , can't modified make them same.
if element names known in advance, can list them in match pattern, e.g:
<xsl:template match="dataset1 | dataset2 | dataset3">
if element names numbered shown in example, use:
<xsl:template match="*[starts-with(name(), 'dataset')]">
if element names unknown, use wild card, e.g:
<xsl:template match="*">
to restrict scope of such template, specify level, e.g.:
<xsl:template match="/rootnode/*/*">
or use mode.
Comments
Post a Comment