xslt - Match node except for grandchild node -


background

Convert document from openoffice to docbook format.

Problem <
  
  • ; Li & gt; & Lt; Ul & gt; And
  • & lt; Ul & gt;
  • p & gt; ... & lt; / P & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt;

    While other parts of the document are included:

      & lt; Ul & gt; & Lt; Li & gt; & Lt; P & gt; ... & lt; / P & gt; & Lt; / Li & gt; & Lt; / Ul & gt;   

    I also tried to match them with the most ul tag:

      & lt; Xsl: template match = "xhtml: ul [no (child :: xhtml: li / child :: xhtml: ul)]" & gt; ... & lt; / Xsl: Templates & gt;   

    But it does not match. The following expression:

      & lt; Xsl: template match = "xhtml: ul" & gt;   

    will be expected as expected:

      & lt; Itemized list & gt; & Lt; Itemizedlist & gt; & Lt; Itemizedlist & gt; ... & lt; / Itemized list & gt; & Lt; / Itemizedlist & gt; & Lt; / Itemizedlist & gt; Regardless of the nesting, the desired output format is:  
       

    desired output

      Lt; Itemizedlist & gt; ... & lt; / Itemized list & gt;   

    question

    Inside children ul node? What is the correct syntax for matching

    ideas ?

    There are a few ways to resolve this:

    • Find / replace the original document (only ~ 20 examples).
    • Use xsl: to see if child node is ul

      will the XPath expression work? Li> test inside the node . For example:

        & lt; Xsl: template match = "xhtml: ul [no (grandchild :: xhtml: ul)]" & gt;   

      Thanks!

        & lt; Xsl: template match = "xhtml: ul [no (descendant: xhtml: ul)]" & gt; & Lt; Itemized list & gt; & Lt; Xsl: applied-template / & gt; & Lt; / Itemized list & gt; & Lt; / XSL: Templates & gt;    

  • Comments