The problem is I want to distinguish same elements name with different situation. For example:
<element>Hello StackOverFlow</element>
<element>
<group>
<ge>hello g1</ge>
<ge>hello g2</ge>
</group>
<group>
<ge>hello g3</ge>
<ge>hello g4</ge>
</group>
</element>
I want to have elements with text convert into
<div class="text_element">Hello StackOverFlow</div>
and for those elements with child nodes:
<div class="element">
<ul class="group">
<li>hello g1</li>
<li>hello g2</li>
</ul>
<ul class="group">
<li>hello g3</li>
<li>hello g4</li>
</ul>
</div>
So, the problem is how can I distinguish these two kind of elements in writing the template?
You can use count the descendant elements to see whether or not it has children, e.g.
count(descendant::group)=0The XSLT (assuming a root node
xmlon your input):Gives the output