Subject: Need XSLT help ASAP
Posted By: damocles82 Post Date: 4/5/2006 10:14:11 PM
Hello
I need to transform an xml file Inquiry.xml to another CustomerInquiry.xml using XSLT. Can someone please provide me with the xsl file to do so.

Inquiry.xml

<Inquiry xsi:schemaLocation="urn:Inquiry Inquiry.xsd">
<inquiryID>inquiry0123</inquiryID>
<customerID>169321</customerID>
<source>
<name>Eric Not </name>
<address>Avent ferry road, apt 5, raleigh, NC</address>
<phone>9145565678</phone>
<email>ericn@yahoo.com</email>
</source>

<destination>
<name>John Doe </name>
<address>42nd Street, New York,  NY, 10017</address>
<phone>2126758967</phone>
<email/>
</destination>

<accountFrom accountID="169321-001">
<bank bankID="WacUSA786">
<bankname>Wachovia</bankname>
<countryname>United States of America</countryname>
<countryCode>USA</countryCode>
<branchID>8989892</branchID>
<branchName>Raleigh-Hillsborough</branchName>
</bank>
<type>Card</type>

<balance>
<amount>1300.56</amount>
<currCode>USD</currCode>
</balance>

<transferTo>
<min>
<amount>10.00</amount>
<currCode>USD</currCode>
</min>
<max>
<amount>1300.56</amount>
<currCode>USD</currCode>
</max>
</transferTo>

<transferFrom>
<min>
<amount>1.00</amount>
<currCode>USD</currCode>
</min>
<max>
<amount>100000.00</amount>
<currCode>USD</currCode>
</max>
</transferFrom>
</accountFrom>

<accountTo accountID="874854-123">
<bank bankID="CitiUSA987">
<bankname>CitiBank</bankname>
<countryname>United States of America</countryname>
<countryCode>USA</countryCode>
<branchID>8789393</branchID>
<branchName>NewYork-Manhattan42</branchName>
</bank>
<type>Card</type>

<balance>
<amount>2500.00</amount>
<currCode>USD</currCode>
</balance>

<transferTo>
<min>
<amount>10.00</amount>
<currCode>USD</currCode>
</min>
<max>
<amount>1000000.00</amount>
<currCode>USD</currCode>
</max>
</transferTo>

<transferFrom>
<min>
<amount>0.00</amount>
<currCode>USD</currCode>
</min>
<max>
<amount>10000000</amount>
<currCode>USD</currCode>
</max>
</transferFrom>
</accountTo>

<dueDate>2006-04-06</dueDate>
<transferAmount>
<amount>500.00</amount>
<currCode>USD</currCode>
</transferAmount>
</Inquiry>


CustomerInquiry.xml

<Customer xsi:schemaLocation="urn:CustomerInquiry CustomerInquiry.xsd" customerID="169321">

<contactInfo>
<name>Eric Not</name>
<address>Avent ferry road, apt 5, raleigh, NC</address>
<phone>9145565678</phone>
<email>ericn@yahoo.com</email>
</contactInfo>

<customerBankInfo>
<bankID>WacUSA786</bankID>
<bankname>Wachovia</bankname>
<countryCode>USA</countryCode>

<AccountInfo accountID="169321-001">
<type>Card</type>
<balance>
<amount>1300.56</amount>
<currCode>USD</currCode>
</balance>
<branchID>8989892</branchID>
<branchName>Raleigh-Hillsborough</branchName>
</AccountInfo>
</customerBankInfo>

<customerInquiryInfo>
<transferInfo>
<destination>
<bankID>CitiUSA987</bankID>
<bankname>CitiBank</bankname>
<countryCode>USA</countryCode>

<AccountInfo accountID="874854-123">
<type>Card</type>
<balance>
<amount>2500.00</amount>
<currCode>USD</currCode>
</balance>
<branchID>8789393</branchID>
<branchName>NewYork-Manhattan42</branchName>
</AccountInfo>
</destination>

<transferAmount>
<amount>500.00</amount>
<currCode>USD</currCode>
</transferAmount>
</transferInfo>

<dueDate>2006-04-06</dueDate>
</customerInquiryInfo>
</Customer>

Would really appreciate the help. Just a simple xsl file to transform Inquiry to CustomerInquiry.

Reply By: joefawcett Reply Date: 4/6/2006 2:18:06 AM
What have you got so far, what aspect are you struggling with?

--

Joe (Microsoft MVP - XML)
Reply By: damocles82 Reply Date: 4/6/2006 2:42:39 AM
I haven got much, just starting out, trying to build elements in CustomerInquiry.xml manually (using xsl:element,xsl:attribute and value-of). But am trying this the first time and am very unsure if its going right.

Using a tutorial side by side, but am not getting to far. Need this done by the morning.

Reply By: mhkay Reply Date: 4/6/2006 3:44:08 AM
You may strike lucky and find someone prepared to write code for you. But it's not something I do. I'm here to help for readers of my books who have difficulty understanding some particular aspect of the technology. Before I can give you that help, I need to know where your difficulty lies: what have you read, what have you tried, what didn't work, which part of the book didn't you understand?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: mhkay Reply Date: 4/6/2006 3:48:26 AM
>Using a tutorial side by side, but am not getting to far. Need this done by the morning.

Can't help, I'm afraid. I've never learnt a new programming language in less than three weeks, and I wouldn't advise anyone else to try.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: damocles82 Reply Date: 4/6/2006 3:52:10 AM
Ok, I think I got some of it down.
I wrote the Inquiry.xsl and then used this
<?xml-stylesheet type="xsl" href="Inquiry.xsl"?> in Inquiry.xml to add the reference.
Then I opened Inquiry.xml using a browser, but the output I get is not like CustomerInquiry.xml, instead its a long sequence of text characters.

How do I make this text appear in the xml format?
I have already included
<xsl:output method="xml" indent="yes"/> in Inquiry.xsl


Go to topic 42511

Return to index page 322
Return to index page 321
Return to index page 320
Return to index page 319
Return to index page 318
Return to index page 317
Return to index page 316
Return to index page 315
Return to index page 314
Return to index page 313