For some projects or applications one may need XHTML-data instead of HTML. In some cases you may need XHTML to parse data to Adobe Forms for example.

The process roughly is the following:

html as String –> convert to UTF8 Xstring –> Convert with tidy –> transform with XSLT –> pass to Adobe forms Base64


I will describe this process step-by-step

One idea to convert the data is based on the Tidy library, which was originally developed by Dave Reggett (HTML Tidy Project Page)

It’s also possible to use this library within the ABAP stack by instrument the class CL_HTMLTIDY.

Here I describe roughly the way to do that:

1. First you have to convert the HTML to UTF8-XSTRING e.g. with help of the class cl_abap_conv_out_ce or  cl_gstext_tools

Example:

  lv_text_as_xstring = cl_gstext_tools=>convert_string_to_xstring( iv_string  =  lv_html ).

2. Create a global obkject  from CL_HTMLTIDY-object: cl_htmltidy=>create( ).

3. Set the options for the Tidy-object by using the method set-option from the class. The parameter input encoding has to be ‘utf8’

  gr_htmltidy->set_optionEXPORTING option  = ‘inputencoding’

                                      value   = ‘utf8’).


You can also set the values for output-encoding and char-encoding in the same way (also to utf8)

You can also have a look at this german blog: Rüdiger Plantiko: Testbare Oberflächen

4. Use the instance (object) of the CL_HTMLTIDY-class to trigger the method to convert. Have a look at the available methods in SE24.

   CALL METHOD gr_htmltidy->repair

     EXPORTING

       input       = xstring_input

       diagnostics = ‘X’

     IMPORTING

       output      = xstring_output

       retcode     = lv_retcode

       errors      = lv_errors.


5. Unfortunately some tags (e.g. <strong>) are not replaced (e.g. by XHTML-standard <b>). For that you have to use XSLT.

The use of XSLT is also depending on the current Adobe Forms version you use. Check which XFA-specification is supported and have a look at the offical specifications by Adobe and which TAGs are supported.

An XSLT-conversion to replace <strong>-tags by <b>-tags may look like that:

<xsl:transform version=“1.0”

   xmlns:xsl=http://www.w3.org/1999/XSL/Transform

   xmlns:x=http://www.w3.org/1999/xhtml

>

<xsl:output encoding=“UTF-8” method=“xhtml” indent=“yes” standalone=“0” version=“1.0”/>

<xsl:strip-space elements=“*”/>

  <xsl:template match=“@*|node()”>

    <xsl:copy>

     <xsl:apply-templates select=“@*|node()”/>

   </xsl:copy>

  </xsl:template>

  <xsl:template match=“/”>

    <xsl:apply-templates/>

  </xsl:template>

<xsl:template match=“x:strong”>

   <b>

      <xsl:apply-templates select=“@*|node()”/>

   </b>

</xsl:template>

</xsl:transform>

6. Use Base64 encoding to prepare the data for Adobe Forms output.

Use e.g. SSF_ABAP_SERVICE

If you have any further questions to this process, just write a comment or open a discussion thread and link me.

Regards,

Daniel

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Joby Thomas

    Hello,

    I am facing the problem to display the text in adobeform from webdynpro component ‘Formatted textedit’ element as the html tags are coming with the text

    i am able to show the bold i.e <b>sample</b> as a rich text in the adobform

    But in the above scenario text from webdynpro is coming with the tag <strong>sample text</strong>  so please suggest how to handle this

    currently we are using adobecycle designer 10

    i read in SCN that we need to set data format to XHTML but I am not finding that option 🙁

    From webgui the user is storing data as below

    /wp-content/uploads/2014/10/text_560552.jpg

    But in the table level the data is storing as below

    <ol><li><h1>sample text 1</h1></li><li><h1><p>sample text 2</p></h1></li></ol>

    I want to display the as shown in above image in my adobeform, please suggest how to handle

    Thanks

    Joby

    (0) 
    1. KARTHIK S NAIR

      I am also facing the same problem.

      Please confirm it can be achieved or not ? i tried the way mentioned above and it shows now the hexadecimal code of the string.

      Please suggest

      (0) 
  2. Daniel Kehne Post author

    @Karthik, you have to convert the Hexdecimal String with a standard encoder class back to the coding you need. (e.g. cl_abap_conv_in_ce)

    @Joby: If you want to bring <strong> to <b> tag you can use this code snippet here within your XSL Transformation file

    <xsl:template match=“x:strong”>

       <b>

          <xsl:apply-templates select=“@*|node()”/>

       </b>

    </xsl:template>

    (0) 

Leave a Reply