| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:01 AM | XQuery & XSLT Built-In & Modules Function Reference
Module: XHTML Conversion
The XHTML module is part of the conversion processing pipeline. These functions are used to manipulate XHTML, as part of conversion processing. To use the XHTML module as part of your own XQuery module, include the following line in your XQuery prolog: `import module namespace xhtml = "http://marklogic.com/cpf/xhtml" at "/MarkLogic/conversion/xhtml.xqy";` You will need to ensure that the XHTML module is loaded into the same modules database as the importing module. The library namespace prefix `xhtml` is not predefined in the server.
Function Summary
xhtml:add-lists | Infer numbered or bulleted lists and insert appropriate markup.
xhtml:clean | Clean up the XHTML: pruning empty spans, consolidating adjacent spans, etc.
xhtml:restructure | Turn an XHTML with flat structure into one with div structure based on the header elements.
Function Detail
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>
xhtml:clean(
| $doc as node()?
) as node()?
Summary: Clean up the XHTML: pruning empty spans, consolidating adjacent spans, etc.
Parameters:
$doc : The source XHTML.
Example:
      xquery version "1.0-ml";
      import module namespace xhtml = "http://marklogic.com/cpf/xhtml"
    		  at "/MarkLogic/conversion/xhtml.xqy";

      xhtml:clean(fn:doc("my.xhtml"))
xhtml:restructure(
| $doc as node()?
) as node()?
Summary: Turn an XHTML with flat structure into one with div structure based on the header elements.
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 $unstructured :=
         <html>
           <head><title>Example</title></head>
           <body>
              <h1>First section</h1>
              <p>First paragraph.</p>
              <p>Second paragraph.</p>
              <h2>Subheader</h2>
              <p>Sub paragraph.</p>
              <h1>Second section</h1>
              <p>Last paragraph.</p>
           </body>
         </html>
      return xhtml:restructure( $unstructured )

      Returns:
        <html>
          <head><title>Example</title></head>
          <body>
             <div class="mlsection1">
               <h1>First section</h1>
               <p>First paragraph.</p>
               <p>Second paragraph.</p>
               <div class="mlsection2">
                 <h2>Subheader</h2>
                 <p>Sub paragraph.</p>
               </div>
             </div>
             <div class="mlsection1">
               <h1>Second section</h1>
               <p>Last paragraph.</p>
             </div>
          </body>
        </html>

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.