Under Community Review

Publish topics as JSON for Dynamic Delivery publishing output

With the OOB "Dynamic Delivery" Output Format the underlying Topic Content(DITA XML) is published and stored as "XHTML" in the Broker Database. While retrieving the topic content via PCA service, It returns a JSON having a TopicBody field value, which is an XHTML conversion of the DITA XML of the Topic.

So basically we are getting a JSON containing an XHTML field. With this mix of JSON and XHTML types, it is really hard to serialize it to a model object.

It would be great to publish Topic Content as JSON in place of XHTML. It would simplify the serialization of the topic objects in the frontend applications like DXA.

Reference Discussion: https://community.sdl.com/product-groups/sdl-tridion/tridion-docs/f/forum/29488/headless-implementation-of-tridion-docs

  • Tridion Docs 14 supports conversion from DITA XML to JSON during topic publishing. though It is not integrated with Dynamic Delivery yet.

    Here is my understanding of how the conversion from XML to JSON happens:

    It is using DITA-OT tool resides under '~\InfoShare\App\Utilities\DITA-OT\dita-ot-3.6.1\plugins\org.number9.json\'.
    Role of each file:
    • plugin.xml: referenced to all the files used in the conversion.
    • org.number9.json\xsl\dita-to-json.xsl: The XSLT stylesheet that helps to generate tree structure with its key and value. I believe that is happening in the below code,
     <xsl:variable name="json-tree">
          <json:object>
            <xsl:copy-of select="if (not($use-rayfish)) then json:create-node($input, false()) else json:create-simple-node($input)"/>
          </json:object>
        </xsl:variable>
    • build_dita2json.xml: targets blocks are setting the value that will be useful to set up the necessary environment to generate JSON output in build_dita2json_template.xml
    • build_dita2json_template.xml: flow is decided for conversion from DITA XML to HTML and HTML to JSON. The relatable code I found that might decide the flow is as below.
        <target name="dita2json"
                unless="noMap"
            depends="build-init, dita.json.init, preprocess, copy-css, xhtml.topics">
          <antcall target="dita.map.json"></antcall>
          <antcall target="rename-html-to-json"></antcall>
        </target>
     
    Overall, these Ant build files are being used to first transformed DITA XML to HTML and then HTML to JSON using the XSLT stylesheet. Probably HTML conversion is required to handle DITA XML's complex structure, and structured JSON is easier to get from HTML.
  • It's a great idea. I think one of the main ideas here is moving toward a more headless delivery for Tridion Docs. I understand that the DITA community has always pushed back against a JSON representation of DITA, which means on the Content Manager side we are kind of stuck with XML. But there is no reason why we couldn't convert to 100% JSON and headless on the Content Delivery side. This could potentially persuade an entirely new subset of the content management community to adopt Tridion Docs - in particular those who are determined to go headless. Wouldn't it be great if we have a solution that combined the best of both worlds: DITA + Headless together in one product.

    I would also suggest the ability to edit individual topics (i.e. in Draft Space) and also to be able to publish individual topics.