Forum Discussion

dwhite's avatar
dwhite
Employee
8 years ago

Validate XML in Binary Form Without Parsing

If you’re having problems with XML validation going in or out of XML (formatter/parser) or if you wish to validate a binary XML without parsing it so save execution time you can use the XSLT snap to do this validation.

XSLT snap takes a binary input and has a binary output and has an xsd setting available to use for validation against the input data to the snap. You can utilize this function to do your validation without modifying the input XML data.

You can write a simple xslt file such as this to essentially pass through the XML data without modifying the structure. This is valid in our XSLT snap and when paired with an XSD essentially converts XSLT snap into a binary xml validator.

Sample XSLT that can be used to perform pass-through functions for any structure:

<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”>
<xsl:output method=“xml” version=“1.0” encoding=“UTF-8” indent=“yes”/>
<xsl:template match=“/”>
<xsl:copy-of select=“*”/>
</xsl:template>
</xsl:stylesheet>

  • Hi @aditya.gupta41

    you should use the function mapKeys in a mapper snap to get the key value and rename it.

    Inside the mapper snap you should use this expression:
    $[‘soapenv:Envelope’][‘soapenv:Body’][‘ns1:MT_SWE_FI_PEGA_ABAON’].mapKeys((value, key) => key == “CLIENT” ? “CLIENTID” : key)

    This expression will first check every key if it equals the value “CLIENT” and if true it will rename it to whatever you want to rename it to. If false the key name is not changed

    And give as target path the path of the original one until the object that contains CLIENT
    $[‘soapenv:Envelope’][‘soapenv:Body’][‘ns1:MT_SWE_FI_PEGA_ABAON’]

    The result:

    Regards

    Jens