Hi -

Problem statement: I have a XML file which is converted to JSON. This JSON
is sent to ConvertJSONToAvro where it fails. This same JSON output when run
against same .asvc file in avro-tools works fine and generates the output.
Can someone please look at the attached artifacts and help.

command tried:

*java -jar avro-tools-1.8.1.jar fromjson --schema-file
TMSDataModelFlat.avsc 90573445988483.json > validated.avro*
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text"/>

<xsl:template match="/">{
    <xsl:apply-templates select="*"/>}
</xsl:template>

<!-- Object or Element Property-->
<xsl:template match="*">
    "<xsl:value-of select="local-name()"/>" :<xsl:call-template name="Properties">
        <xsl:with-param name="parent" select="'Yes'"> </xsl:with-param>
    </xsl:call-template>
</xsl:template>

<!-- Array Element -->
<xsl:template match="*" mode="ArrayElement">
    <xsl:call-template name="Properties"/>
</xsl:template>

<!-- Object Properties -->
<xsl:template name="Properties">
    <xsl:param name="parent"></xsl:param>
    <xsl:variable name="childName" select="local-name(*[1])"/>
    <xsl:choose>            
        <xsl:when test="not(*|@*)"><xsl:choose><xsl:when test="$parent='Yes'"> <xsl:text>&quot;</xsl:text><xsl:value-of select="."/><xsl:text>&quot;</xsl:text></xsl:when>
                <xsl:otherwise>"<xsl:value-of select="name()"/>":"<xsl:value-of  select="."/>"</xsl:otherwise>
            </xsl:choose>           
        </xsl:when>                
        <xsl:when test="count(*[local-name()=$childName]) > 1">{ "<xsl:value-of  select="$childName"/>" :[<xsl:apply-templates select="*" mode="ArrayElement"/>] }</xsl:when>
        <xsl:otherwise>{
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates select="*"/>
            }</xsl:otherwise>
    </xsl:choose>
    <xsl:if test="following-sibling::*">,</xsl:if>
</xsl:template>

<!-- Attribute Property -->
<xsl:template match="@*">"<xsl:value-of select="local-name()"/>" : "<xsl:value-of select="."/>",
</xsl:template>
</xsl:stylesheet>
<tns:DataModel xmlns:tns="http://www.apachecorp.com/IntegrationRouter/TMS_DataModel";><tns:Header><tns21:TMS_ID xmlns:tns21="http://www.apachecorp.com/Header";>1093984501</tns21:TMS_ID><tns21:PROCESS_CD xmlns:tns21="http://www.apachecorp.com/Header";>WvWellHeader</tns21:PROCESS_CD><tns21:BATCH_ID xmlns:tns21="http://www.apachecorp.com/Header";>25664</tns21:BATCH_ID><tns21:RECORD_COUNT xmlns:tns21="http://www.apachecorp.com/Header";>1</tns21:RECORD_COUNT><tns21:SOURCE_SYSTEM xmlns:tns21="http://www.apachecorp.com/Header";>WELLVIEW</tns21:SOURCE_SYSTEM><tns21:SOURCE_RECORD_ID xmlns:tns21="http://www.apachecorp.com/Header";>1093984501</tns21:SOURCE_RECORD_ID><tns21:TARGET_SYSTEM xmlns:tns21="http://www.apachecorp.com/Header";>EDW</tns21:TARGET_SYSTEM><tns21:TRANSACTION_TYPE xmlns:tns21="http://www.apachecorp.com/Header";>NEW</tns21:TRANSACTION_TYPE><tns21:SOURCE_CREATE_DATE xmlns:tns21="http://www.apachecorp.com/Header";>2017-03-29T10:18:00-05:00</tns21:SOURCE_CREATE_DATE><tns2:KEY xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:tns3="http://www.apachecorp.com/TMS/Batch"; xmlns:tns2="http://www.apachecorp.com/Header"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><tns1:ELEMENT_NAME xmlns:tns1="http://www.apachecorp.com/Key";>KEY_PAIRS</tns1:ELEMENT_NAME><tns1:ELEMENT_VALUE xmlns:tns1="http://www.apachecorp.com/Key";>WvWellHeader?Idrec=BA6300E67D2A4F63898DDC50290A03F2</tns1:ELEMENT_VALUE></tns2:KEY><tns21:DELETE_FL xmlns:tns21="http://www.apachecorp.com/Header";>N</tns21:DELETE_FL></tns:Header><tns:Data xmlns:tns1="http://www.apachecorp.com/Key"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:tns3="http://www.apachecorp.com/TMS/Batch"; xmlns:tns2="http://www.apachecorp.com/Header"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>H4sIAAAAAAAAA42TTY/bIBCGz+2v4NgeHAP+aCwhJAIki2pDBDhuellF3Uh7Slbb/f/qGCd2emoPljXvPO8wjMfMu4F//sSM8lryjagLjHX9TVFRbuti3ayVkhWmDRa42FKWT1wyDLpt/8uRQLCMb6MEJzijTYbrJiN4qFh+12+IFZ3mQrZIRyRaFAZh0ZNp24Ca0ZdskymR4OqD9vFHJP92zSS43F57EZ3n4u306/WM5OlyejmhNiqWz7kHTjqluXs7v58+zi8LkmTAQhRR7707cLFh+RJBSrreRn/k0wksv8eQUuZggnF2zs0CJLdGtypd8slB56gbfcJY1FsTEWH5AgDdimhiD81U1QrjqqxZPktj2tndFGSEVKtyXRYAzCIQuj3sPByhOC2L1bpk+aKMBbQIUBxTgimGw6d4vEOMXdj3ipOmrjJMsgImPYtTYefN7vsGCkNvVUNT6ZuWepPQqbPxuOfu8vv1+n4ee1vEcb7HELTsvYnHUemt1yF6I6NWz1JYocSz0noPo/8bnKzSa/ggCh4OzdcZphkuEvuQmYY4zgTCvuNQdF2kKS7awgTXe6n5z+vljAix6AuhGA3o4wpRiYavs/EGzqukYVL3/dHqvsC27wq+quqaUlJU06om7WFL0q6JZUmm3WP5+BP/AaZyjR3KAwAA</tns:Data></tns:DataModel>

Attachment: 111992238023017.json
Description: application/json

Attachment: TMSDataModelFlat.avsc
Description: Binary data

Reply via email to