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

Parents
  • 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.
Comment
  • 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.
Children
No Data