Link to home
Start Free TrialLog in
Avatar of shahbax
shahbax

asked on

Basic Question

Hello
How can i transform this XML document ?

"<INV INvID="1" INVNO="inv1" CustName="sdsd" CustNo="0909"><INVDT ItemCode="12" Pack="12" Descr="12"/></INV>"

to this format

<data>
<JF_JOB_CARD>PACKING -afpD:\JetForm\Central\Samples\Exprint\forms -alpD:\JetForm\Central\Samples\Exprint\logos </JF_JOB_CARD>
<INVID>1</INVID>
<InvNO>abc2</InvNO>
<CustName>abc3</CustName>
<CustNo>abc4</CustName>
<ITEMCODE>12</ItemCODE>
<PACK>12</Pack>
..

</data>
any help,sugesstion,clue is reuired
thanks in advance
.
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

This would be simpler if elements were spelled the same:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

     <xsl:template match="/INV">
          <data>
               <JF_JOB_CARD>PACKING -afpD:\JetForm\Central\Samples\Exprint\forms -alpD:\JetForm\Central\Samples\Exprint\logos </JF_JOB_CARD>
               <INVID>
                    <xsl:value-of select="@INvID"/>
               </INVID>
               <InvNO>
                    <xsl:value-of select="@INVNO"/>
               </InvNO>
               <CustName>
                    <xsl:value-of select="@CustName"/>
               </CustName>
               <CustNo>
                    <xsl:value-of select="@CustNo"/>
               </CustNo>
               <ITEMCODE>
                    <xsl:value-of select="INVDT/@ItemCode"/>
               </ITEMCODE>
               <PACK>
                    <xsl:value-of select="INVDT/@Pack"/>
               </PACK>
          </data>
     </xsl:template>
</xsl:stylesheet>

Anthony
Avatar of shahbax
shahbax

ASKER

Hi,

Thanks for the help..but my problem is that i hv to the source XML file is generated from SQL server andi hv to put this XML file for another location for some processing ,how can automatically convert the source XML file format to target format..i can embed my own tag in the source XML file for examlple <JF_JOB_CARD>..and i can give the path of XML in ..but there is no browser involement so how can i transfrom it to target XML format
Thanks in advance

Ragrads,
Shahbaz
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial