Skip to Content
avatar image
Former Member

Adding comment line in XML message

Hi,

Does anyone know how to add a comment line in outgoing XML message from XI? Using graphical mapping or java or adapter module?

Something like .....

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

<! this is a comment>

<record>

Thanks

Pushpinder

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 19, 2008 at 08:45 AM

    You can write below statement in simple java mapping

    As you want to insert comment before <record>

    read entire source structure in string strXMLSource

    finalString = strXMLSource.replaceAll("<record>", "<!-- this is a comment--><record>");

    in out.write statement pass finalString....

    No need to write any parser, just write simple code in execute method

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 19, 2008 at 09:34 AM

    Comment for xml should be inserted

    <!-- Your Comment -->

    Thanks

    Sunil Singh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 19, 2008 at 09:55 AM

    Hi Pushpinder,

    depends on the kind of mapping you process:

    1) graphical mapping: not possible

    2) xsl-mapping: use <xsl:comment>

    3) JAVA-Mapping: Insert a comment-node to the target structure

    3) ABAP-Mapping: Insert a comment-node to the target structure

    Regards Mario

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Amit,

      But it will make a difference as the messages will be split after the message mapping. So how java mapping going to handle it?

      I have tried deploying the java code but it is not inserting the comment line in the final message.

      Thanks

      Pushpinder

  • avatar image
    Former Member
    Aug 19, 2008 at 03:27 PM

    Some more complications in the requirement

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 19, 2008 at 03:28 PM

    You can transform your XML with an XSLT transformation:

    http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output encoding="utf-8" indent="no" method="xml" version="1.0"/>

    <xsl:param name="COMMENT"/>

    <xsl:preserve-space elements="*"/>

    <xsl:template match="/">

    <xsl:comment>

    <xsl:value-of select="$COMMENT"/>

    </xsl:comment>

    <xsl:copy>

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

    </xsl:copy>

    </xsl:template>

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

    <xsl:copy>

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

    </xsl:copy>

    </xsl:template>

    </xsl:transform>

    Best wishes,

    Jan

    Add comment
    10|10000 characters needed characters exceeded