MarkLogic 10 Product Documentation
xhtml:add-lists

xhtml:add-lists(
   $doc as node()?
) as node()?

Summary

Infer numbered or bulleted lists and insert appropriate markup. Restructuring first is highly recommended to improve both accuracy and performance. This function also assumes that indentation styling is already present on the paragraphs in the original input.

Parameters
doc The source XHTML.

Example

  xquery version "1.0-ml";
  declare default element namespace "http://www.w3.org/1999/xhtml";

  import module namespace xhtml = "http://marklogic.com/cpf/xhtml" 
		  at "/MarkLogic/conversion/xhtml.xqy";

  let $raw :=
     <html>
       <head><title>Example</title></head>
       <body>
          <div class="mlsection1">
            <h1>Section header</h1>
            <p>1. First paragraph.</p>
            <p>2. Second paragraph.</p>
            <p>a. Sub-topic 1.</p>
            <p>b. Sub-topic 1.</p>
            <p>3. Third paragraph</p>
            <div class="mlsection2">
              <h2>Subheader</h2>
              <p>1. Sub paragraph.</p>
            </div>
          </div>
       </body>
     </html>
  return xhtml:add-lists( $raw )

  Returns:
     <html>
       <head><title>Example</title></head>
       <body>
          <div class="mlsection1">
            <h1>Section header</h1>
            <ol style="list-style-type: none; margin-left: 0pt">
              <li>1. First paragraph.</li>
              <li>2. Second paragraph.</li>
              <ol style="list-style-type: none; margin-left: 0pt">
                <li>a. Sub-topic 1.</li>
                <li>b. Sub-topic 1.</li>
              </ol>
              <li>3. Third paragraph</li>
            </ol>
            <div class="mlsection2">
              <h2>Subheader</h2>
              <p>1. Sub paragraph.</p>
            </div>
          </div>
       </body>
     </html>
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy