Question

I'm new to XSLT and I can't figure out how to get an xsl:if that matches when there are no child tags.

I want this to match:

<context>
    howdy
</context>

And this not:

<context>
    <child>
        howdy
    </child>
</context>
Was it helpful?

Solution

the relevant xpath expression should look like:

//context[not(./*)]

OTHER TIPS

You could also specify count(child::*) = 0 .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top