Converting Xml to Json in Teamsite

Hi ,

 

My requirment is to convert my dcrs(xml ) files into json file. Is this possible with the help of tpl?

 

My approach is to make DCRs of my webinars. Then I need this webinars on my home page with lot of other functionality on the same like filtering , sorting etc.

 

So I am asked to try if I can convert these XML into JSON file using tpl file. Is this is possible any how??

 

Thanks in Advance!

 

Comments

  • You can find sample code to convert xml to json online. Or use some Perl modules which does the same. Then use it in your tpl and generate the json!

     

    regards,

    Praveen

  • There's not any smarts to this, and I don't think solutions you find on the internet will really help you with your TPL work. You might be able to find an XSL sample though. However since you have full control of the transformation either way, it's just a matter of actually doing it.

     

    That said, if you don't need to use TPL/XSL, you could do this in workflow directly. The product includes (an old version of) a library from json.org which will basically do all the work for you. It'd be super easy to wrap an external task around this.

    http://www.json.org/java/index.html

     

  • Why not just create a second .tpl file that generates json? You just need to add it to the templating,cfg file.

     

       <presentation>
        <template name="example.tpl" extension="json">
         <locations>
          <branch vpath-regex=".*" preview-dir="/subs/home">
           <directory dir-regex=".*"/>
          </branch>
         </locations>
        </template>
       </presentation>

  • I am facing a similar issue.

    I have generated a json output from the XSL in presentation template.

    The extension is set as .json and the <xslSmiley Surprisedutput> tag is set to json. But I get the 

    <?xml version="1.0" encoding="UTF-8"?>

     on the start of each file. Also when I edit the file in teamsite, it opens the DCR rather than the json file.

     

    Can you let me know where do I have to change and what do i have to change?

     

    Thanks to you all in advance!

  • User921526, use omit-xml-declaration in your xsl.

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs