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_option( EXPORTING 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
56 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |