Background
Converting a document from OpenOffice to DocBook format.
Problem
Parts of the document include the following:
<ul><li><ul><li><ul><li><p>...</p></li></ul></li></ul></li></ul>
While other parts of the document include:
<ul><li><p>...</p></li></ul>
I tried to match just the inner-most ul tag using:
<xsl:template match="xhtml:ul[not(child::xhtml:li/child::xhtml:ul)]">
...
</xsl:template>
But this does not match. The following expression:
<xsl:template match="xhtml:ul">
Will create, as expected:
<itemizedlist>
<itemizedlist>
<itemizedlist>
...
</itemizedlist>
</itemizedlist>
</itemizedlist>
Desired Output
The desired output format, regardless of ul nesting, is:
<itemizedlist>
...
</itemizedlist>
Question
What’s the correct syntax for matching the innermost child ul node?
Ideas
There are a few ways to resolve this:
- Search/replace the original document (there are only ~20 instances).
- Use
xsl:testwithin thelinode to see if the child node isul.
What XPath expression would work? For example:
<xsl:template match="xhtml:ul[not(grandchild::xhtml:ul)]">
Thank you!
1 Answer