xslt newbie question

T

TexasAggie96

I am writing xslt to convert a xml response from a software package I
work with to a more managable result. An example of this response can
be seen below. If you look there are two sections, one for quantity
and one for price. I want to be able to pull data from both of these
sections and put them in a single record much like the second record.
Any help would be greatly appreciated.

-JW

***FIRST RECORD***
- <PowerDeal>
<ID>25686</ID>
<Name>UNIT 1</Name>
<State>VALID</State>
<Kind>Purchase</Kind>
<Comments>UNIT 1</Comments>
<ContractName>UNIT1</ContractName>
<CounterpartyAcronym>TUB</CounterpartyAcronym>
<ContactName>Billy Bob</ContactName>
<ProductName>Generation</ProductName>
<PriceUnitName>$/MWh</PriceUnitName>
<Broker />
<BrokerFeeInfo>0</BrokerFeeInfo>
<BrokerContactName />
<TradingBook>TUB</TradingBook>
<TraderID />
<LiquidatedDamages>false</LiquidatedDamages>
<Priority>500</Priority>
- <Profile>
- <Entry>
<Start>04/18/2007 00:00</Start>
<Stop>04/18/2007 01:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 01:00</Start>
<Stop>04/18/2007 02:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 02:00</Start>
<Stop>04/18/2007 03:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 03:00</Start>
<Stop>04/18/2007 04:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 04:00</Start>
<Stop>04/18/2007 05:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 05:00</Start>
<Stop>04/18/2007 06:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 06:00</Start>
<Stop>04/18/2007 07:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 07:00</Start>
<Stop>04/18/2007 08:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 08:00</Start>
<Stop>04/18/2007 09:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 09:00</Start>
<Stop>04/18/2007 10:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 10:00</Start>
<Stop>04/18/2007 11:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 11:00</Start>
<Stop>04/18/2007 12:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 12:00</Start>
<Stop>04/18/2007 13:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 13:00</Start>
<Stop>04/18/2007 14:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 14:00</Start>
<Stop>04/18/2007 15:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 15:00</Start>
<Stop>04/18/2007 16:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 16:00</Start>
<Stop>04/18/2007 17:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 17:00</Start>
<Stop>04/18/2007 18:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 18:00</Start>
<Stop>04/18/2007 19:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 19:00</Start>
<Stop>04/18/2007 20:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 20:00</Start>
<Stop>04/18/2007 21:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 21:00</Start>
<Stop>04/18/2007 22:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 22:00</Start>
<Stop>04/18/2007 23:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/18/2007 23:00</Start>
<Stop>04/19/2007 00:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 00:00</Start>
<Stop>04/19/2007 01:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 01:00</Start>
<Stop>04/19/2007 02:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 02:00</Start>
<Stop>04/19/2007 03:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 03:00</Start>
<Stop>04/19/2007 04:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 04:00</Start>
<Stop>04/19/2007 05:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 05:00</Start>
<Stop>04/19/2007 06:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 06:00</Start>
<Stop>04/19/2007 07:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 07:00</Start>
<Stop>04/19/2007 08:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 08:00</Start>
<Stop>04/19/2007 09:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 09:00</Start>
<Stop>04/19/2007 10:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 10:00</Start>
<Stop>04/19/2007 11:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 11:00</Start>
<Stop>04/19/2007 12:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 12:00</Start>
<Stop>04/19/2007 13:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 13:00</Start>
<Stop>04/19/2007 14:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 14:00</Start>
<Stop>04/19/2007 15:00</Stop>
<Value>0.00</Value>
</Entry>
- <Entry>
<Start>04/19/2007 15:00</Start>
<Stop>04/19/2007 16:00</Stop>
<Value>0.00</Value>
</Entry>
</Profile>
- <PriceStructure>
<PriceType>Fixed</PriceType>
</PriceStructure>
- <PriceProfile>
- <PriceEntry>
<Start>04/18/2007 00:00</Start>
<Stop>04/18/2007 01:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 01:00</Start>
<Stop>04/18/2007 02:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 02:00</Start>
<Stop>04/18/2007 03:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 03:00</Start>
<Stop>04/18/2007 04:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 04:00</Start>
<Stop>04/18/2007 05:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 05:00</Start>
<Stop>04/18/2007 06:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 06:00</Start>
<Stop>04/18/2007 07:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 07:00</Start>
<Stop>04/18/2007 08:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 08:00</Start>
<Stop>04/18/2007 09:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 09:00</Start>
<Stop>04/18/2007 10:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 10:00</Start>
<Stop>04/18/2007 11:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 11:00</Start>
<Stop>04/18/2007 12:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 12:00</Start>
<Stop>04/18/2007 13:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 13:00</Start>
<Stop>04/18/2007 14:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 14:00</Start>
<Stop>04/18/2007 15:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 15:00</Start>
<Stop>04/18/2007 16:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 16:00</Start>
<Stop>04/18/2007 17:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 17:00</Start>
<Stop>04/18/2007 18:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 18:00</Start>
<Stop>04/18/2007 19:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 19:00</Start>
<Stop>04/18/2007 20:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 20:00</Start>
<Stop>04/18/2007 21:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 21:00</Start>
<Stop>04/18/2007 22:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 22:00</Start>
<Stop>04/18/2007 23:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/18/2007 23:00</Start>
<Stop>04/19/2007 00:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 00:00</Start>
<Stop>04/19/2007 01:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 01:00</Start>
<Stop>04/19/2007 02:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 02:00</Start>
<Stop>04/19/2007 03:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 03:00</Start>
<Stop>04/19/2007 04:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 04:00</Start>
<Stop>04/19/2007 05:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 05:00</Start>
<Stop>04/19/2007 06:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 06:00</Start>
<Stop>04/19/2007 07:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 07:00</Start>
<Stop>04/19/2007 08:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 08:00</Start>
<Stop>04/19/2007 09:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 09:00</Start>
<Stop>04/19/2007 10:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 10:00</Start>
<Stop>04/19/2007 11:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 11:00</Start>
<Stop>04/19/2007 12:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 12:00</Start>
<Stop>04/19/2007 13:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 13:00</Start>
<Stop>04/19/2007 14:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 14:00</Start>
<Stop>04/19/2007 15:00</Stop>
<Price>0.00</Price>
</PriceEntry>
- <PriceEntry>
<Start>04/19/2007 15:00</Start>
<Stop>04/19/2007 16:00</Stop>
<Price>0.00</Price>
</PriceEntry>
</PriceProfile>
<Start>2006-01-01T06:00:00Z</Start>
<Stop>2021-01-01T06:00:00Z</Stop>
<LastModified>2007-04-11T22:24:50Z</LastModified>
<EntryTime>2006-09-22T21:42:20Z</EntryTime>
<DoneDealTime>2006-07-06T21:46:58Z</DoneDealTime>
- <Ramp>
<UpOffset>300</UpOffset>
<UpDuration>600</UpDuration>
<DownOffset>300</DownOffset>
<DownDuration>600</DownDuration>
</Ramp>
- <LocationList>
<Location>a) North</Location>
</LocationList>
<HistoryList />
<LocalRefList />
<ExtraCostList />
<CheckoutList />
</PowerDeal>


*** Second Record***

- <PowerDealList>
- <PowerDealSegment>
- <PowerDeal>
<Count />
<Name>UNIT 1</Name>
<TransactionID>25686</TransactionID>
<Type>Purchase</Type>
<Contract>UNIT 1</Contract>
<Book>TUB</Book>
<Status>VALID</Status>
<Counterparty>TUB</Counterparty>
<Product>Generation</Product>
<StartTime>04/18/2007 00:00</StartTime>
<EndTime>04/18/2007 01:00</EndTime>
<Qty>0.00</Qty>
<Price>0.00</Price>
</PowerDeal>
</PowerDealSegment>
...
...
 
J

Joe Kesselman

TexasAggie96 said:
Any help would be greatly appreciated.

If you want to use an off-the-shelf tool, I would suggest XSLT or
XQuery. (XSLT 1.0 is most widely available; XSLT 2.0 and XQuery are
relatively recent and still establishing themselves.)

If you want to code it yourself, you'll want to use an off-the-shelf XML
parser, which will produce either SAX events or a DOM tree; you'll write
code which operates on that information to generate a new document and
pass it to a serializer (usually part of the parser package) to be
written back out as XML. This approach obviously leaves you free to use
the full power of your programming language rather than the XSLT/XQuery
languages, but "with power comes responsibility".

Which approach is best depends on the specifics of what you want to do,
how large the input data is, how it's organized, and how you personally
prefer to think about the problem.

The place to start is probably to read some tutorials on XML application
development, and on XSLT, so you understand what's involved in each
approach. Then pick one and start playing with it. From your
description, it sounds like any of these could do this job.
 
J

Joe Kesselman

Have you started by reading some XSLT tutorials? Herewith my standard
pointer to DeveloperWorks, which has a lot of good info:
http://www.ibm.com/xml

The next step, as in any programming language, is to describe the
problem in detail: Exactly what information are you going to extract
(and how will it be recognized), how will it be recombined and what new
structures are you going to build around it.

Once you've got that spelled out, translating that into XSLT is "a
simple matter of programming".

If you have specific questions, ask 'em; if you're looking for someone
to solve it all for you, I'm gonna leave that as an exercise for the reader.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top