Solved

Basic Question

Posted on 2002-07-20
5
193 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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now