XML Transformation using XSLT

Avatar

Avatar

tarekahf

Avatar

tarekahf

tarekahf

27-07-2019

We have a complex XDP for Appraiser Application Form with XML Data Model (default one, nothing fancy). There is another XDP of the same Application Form, same layout, but with different model and XML Structure. The XML Structure of the 2nd form is based on format which I am not familiar with, but I can understand what is in there.

The 1st XML is plain vanilla XML, straight forward.

The 2nd XML has multiple nested sections, and the field names are specified in the attribute of the tag element. The images are specified in the attachment section, and the are references from the relevant tag element.

Following is a sample of the 1st XML:

<app_rep1>

  <NEW_primaryform>Some-primary-form</NEW_primaryform>

  <NEW_TITLE_PHOTO>SamplePhotoLabel1</NEW_TITLE_PHOTO>

  <NEW_CITY>Toronto</NEW_CITY>

  <NEW_Stage>Stage Value</NEW_Stage>

  <NEW_GS_AGE>23</NEW_GS_AGE>

  <NEW_POOL_X>Nice Pool</NEW_POOL_X>

  <NEW_PHOTO1>/9j/4AAQSkZJRgABAAEASABIAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCE

bla...bla...bla

  </NEW_PHOTO1>

</app_rep1>

Following is a sample of the 2nd XML:

<app_rep2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">

  <appraisal>

    <configuration>

      <primaryform>Some-primary-form</primaryform>

      <versioninfo>

        <acifileversion>123</acifileversion>

        <collectionversion>1.2.3.4</collectionversion>

        <collection>Report Pro</collection>

        <platform>Desktop Platform</platform>

      </versioninfo>

    </configuration>

    <data>

      <form name="photo1" primary="false">

        <section type="other" number="0" name="section_name1">

          <tag name="TITLE_PHOTO">SamplePhotoLabel1</tag>

          <tag name="LINE_PHOTO">SamplePhotoDescription1</tag>

        </section>

        <tag name="PHOTO1">../../../attachments/attachment[@key='267463fa-0073-4c10-83d6-fd8141641b72']</tag>

      </form>

      <form name="Some-primary-form" primary="true">

        <section type="other" number="0" name="OPTIONS">

          <tag name="OPT_TYPE_OF_APPRAISAL">Appraisal Type Value</tag>

        </section>

        <section type="subject" number="0" name="SUBJECT">

          <tag name="CITY">Toronto</tag>

          <tag name="STATE">Stage Value</tag>

          <tag name="GS_AGE">23</tag>

          <tag name="POOL_X">Nice Pool</tag>

        </section>

     </form>

    </data>

    <attachments>

      <attachment type="photo" label="" key="267463fa-0073-4c10-83d6-fd8141641b72">

        <image>

          <binary format="jpeg">/9j/4AAQSkZJRgABAAEASABIAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCE

bla...bla...bla

          </binary>

        </image>

      </attachment>

    </attachments>

  </appraisal>

</app_rep2>

As you can see, I want to transform the 2nd XML to look like the 1st XML.

I think I need to first write the XSLT. Then, I need to import the 2nd XML into the 1st XDP, and apply the XSLT while importing.

Am I thinking in the right direction?

Can you please help achieve my goal? I am not exactly sure how to do that.

Questions:

1. How to develop the XSLT?

2. How to apply the XSLT while merging the 2nd XML with the 1st XDP? How I can do than using Acrobat? How I can do that using Adobe LiveCycle Process Management?

Any help would be appreciated.

Regards,

Tarek

View Entire Topic

Avatar

Avatar

tarekahf

Avatar

tarekahf

tarekahf

06-08-2019

Thanks Bruce! There are more than 1000 fields, it'll be very hard to do such mapping. I am looking for a solution to automate this or at least introduce a step to minimize the manual work.

Steps I am thinking of:

1. Write XSL to map the structure and leave field names as is. Looks like this is doable.

2. Prepare a table in Excel Sheet to map the field names from 1st XML to the 2nd XML. It'll be simple two columns table.

3. Apply find/replace using the table rows in 2 above as input. I can write a program to perform this find/replace, but I am looking for a desktop tool to perform this find/replace. I couldn't find a way to do this using Notepad++ for example.

If you can help with the above, that would be great.

Tarek