3
votes

I want to do the following with the XML being unindented:

xdmp:quote(fn:doc($uri)/*)

The documentation at https://docs.marklogic.com/xdmp:quote is not very clear. How should the options parameter be formatted?

2

2 Answers

4
votes

Try using the following options parameter:

let $options :=
  <options xmlns="xdmp:quote">
    <indent>no</indent>
  </options>

return xdmp:quote(fn:doc($uri)/*, $options)

The quote options are listed in the documentation for the xdmp:quote() function.

For a full listing of all the options you can find the quote.xsd file in your install area in the /MarkLogic/Config directory.

2
votes

It is relatively straight-forward, not different than how it is used in other commands, like xdmp:http-get and xdmp:eval:

  xdmp:quote(
    $xml,
    <options xmlns="xdmp:quote">
      <omit-xml-declaration>yes</omit-xml-declaration>
      <indent>no</indent>
      <indent-untyped>no</indent-untyped>
    </options>
  )

Note thought, this will not strip whitespace that is present in the XML. To get rid of that, you can use good old xsl:strip-space:

xdmp:quote(
  xdmp:xslt-eval(
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all">

      <xsl:output indent="no" omit-xml-declaration="yes"/>
      <xsl:strip-space elements="*"/>

      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>

   </xsl:stylesheet>,
   $xml
 )

)

HTH!