2

We have a custom Journal Article web content structure and currently using the hard-coded XML content to populate the structure with the values. Is there any API in Liferay that we can make use in order to create the XML content for Journal Article.

Vishnu S Kumar
  • 666
  • 7
  • 24
  • There is a general purpose version of this api here: https://www.e-systems.tech/web/guest/truenth-knowledge-base/-/knowledge_base/truenth-cms/api-quick-reference But I guess it is just for subscribers. Do you have any special case? – Victor Oct 04 '17 at 00:29
  • Sorry, @Victor . This is not what we are looking for. – Vishnu S Kumar Oct 04 '17 at 14:47
  • hum, I have just noticed, you were looking for a structure and populating it from XML. This sounds like a native functionality, as web content is stored as XML with in the database. just to get your case straight: XML is holding your content and you wanna access this content? or you want to get your XML and use its values to generate a second piece of content which is based on the first XML, but with a structure as base? – Victor Oct 04 '17 at 18:23
  • I am just asking for your steps, as I know there are native functions for either way. if your XML is already on your database and you have the journalarticle, you can simple do Document document = SAXReaderUtil.read( article.getContent() ); – Victor Oct 04 '17 at 18:24
  • 1
    We are creating the journals programmatically. Right now we are hard-coding the XML template based on the DDM structure and dynamically populating it with the values each time with the help of SAXReaderUtil So far so good. Now we want to get rid of the hard-coded XML template with some API's that helps to generate the XML content for the respective DDM structure. – Vishnu S Kumar Oct 04 '17 at 18:28
  • To make it more clear.for ex: Just imagine if we want to parse a Java Object to XML, we can either hard code the XML for that respective java class or we can use any Java XML parsing library right. We are looking for the second situation in order to create an XML content using it's DDM Structure and values – Vishnu S Kumar Oct 04 '17 at 18:34
  • so, I guess you are looking for this guy: com.liferay.dynamic.data.mapping.util.FieldsToDDMFormValuesConverter – Victor Oct 04 '17 at 19:51

1 Answers1

2

I guess you are looking for this guy: com.liferay.dynamic.data.mapping.util.FieldsToDDMFormValuesC‌​onverter

DDMFormValues ddmFormValues = DDMUtil.getDDMFormValues(ddmStructure.getStructureId(), ...);
Fields fields = DDMUtil.getFields(ddmStructure.getStructureId(), ddmFormValues); 
String content = _journalConverter.getContent(ddmStructure, fields) 
Victor
  • 3,520
  • 3
  • 38
  • 58