Solved

Basic Question

Posted on 2002-07-20
5
196 Views
Last Modified: 2008-01-09
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
.
0
Comment
Question by:shahbax
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7166847
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
0
 

Author Comment

by:shahbax
ID: 7167523
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
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 50 total points
ID: 7168149
>>that i hv to the source XML file is generated from SQL server<<
Try posting this code and perhaps we can coerce it into the 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>
Without transforming it after SQL Server returns the XML document.

Anthony
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question