× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2017-04-25 3:53 PM, Jon Paris wrote:
I _think_ my version is right - but not tested - if I have time I'll
do that because it needs a couple of count fields by the look of it
(for OptionalChannelData for example).

Jon, I think your version needs a few corrections
- The DIM should be on Channel, not Channels
- ChannelID, Readings, OptionalChannelDatas should be subfields of Channel, not of Channels
- the DIM should be on OptionalChannelData, not OptionalChannelDatas

I think this is closer, but it's also untested ... sorry ...

I added a few "count" subfields for the repeated elements. I also added a few names on the END-DS's. It seems useful when the end of the data structure is a long way from the beginning.

dcl-ds MeterReadingDocument Qualified;
dcl-ds ImportExportParameters;
CreateResubmitFile char(n);
dcl-ds DataFormat;
DSTTransitionType char(n);
ReadingTimestamp char(n);
end-ds;
end-ds;

dcl-ds Channels;
countChannel int(10);
dcl-ds Channel dim(nn);
ReadingsInPulse char(n);
IsRegister char(n);
IsReadingDecoded char(n);
MarketType char(n);
dcl-ds ChannelID;
EndPointChannelID char(n);
end-ds;
dcl-ds Readings;
countReading int(10);
dcl-ds Reading dim(nn);
Value char(n);
ReadingTime char(n);
end-ds;
end-ds;
dcl-ds OptionalChannelDatas;
countOptionalChannelData int(10);
dcl-ds OptionalChannelData dim(nn);
Name char(n);
Value char(n);
end-ds;
end-ds;
end-ds Channel;
end-ds Channels;
end-ds MeterReadingDocument;

To get the Channel data the XML-INTO would look like this:

XML-INTO MeterReadingDocument.Channels
%XML(XMLFile: 'doc=file +
datasubf=data +
countprefix=count +
path=MeterReadingDocument/Channels +
case=any');

Then use MeterReadingDocument.Channels.countChannel to find out how many Channel elements there were.

Mike, if you only want the Channel info, it might be better just to code the Channels DS at the top level, and not bother about the other stuff before the Channels info.

dcl-ds Channels qualified;
countChannel int(10);
dcl-ds Channel dim(nn);
ReadingsInPulse char(n);
IsRegister char(n);
IsReadingDecoded char(n);
MarketType char(n);
dcl-ds ChannelID;
EndPointChannelID char(n);
end-ds;
dcl-ds Readings;
countReading int(10);
dcl-ds Reading dim(nn);
Value char(n);
ReadingTime char(n);
end-ds;
end-ds;
dcl-ds OptionalChannelDatas;
countOptionalChannelData int(10);
dcl-ds OptionalChannelData dim(nn);
Name char(n);
Value char(n);
end-ds;
end-ds;
end-ds Channel;
end-ds Channels;

Then the XML-INTO would look like this:

XML-INTO Channels
%XML(XMLFile: 'doc=file +
datasubf=data +
countprefix=count +
path=MeterReadingDocument/Channels +
case=any');

Then use Channels.countChannel to find out how many Channel elements there were.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.