Nor can I find it on my pallette or system.. Any Idea how I get this to
work in Delphi 5 ??
I basically need to itterate through a TQuery and produce an XML File from
it based on dtd's that
an external company have asked me to pass information to them in..
Perhaps I may even be looking at this from the wrong angle, I am completely
new to the world of XML so
any suggestions would be much appreciated..
Martin Dew
Fred
"Martin Dew" <mar...@owlsoftware.co.uk> a écrit dans le message de news:
OWLS26...@owlsoftware.co.uk...
> Any Idea how I get this to work in Delphi 5 ??
Unfortunately, you don't. The TXMLDocument is a D6 component that
encapsulates the DOM behavior in several third party engines. To use a DOM
in D5 you have other options :
1) use MSXML directly http://msdn.microsoft.com/xml
2) use OpenXML http://philo.de/xml
3) use TurboPower's XMLPartner http://www.turbopower.com
The methods for doing this are similar (with some syntax changes) to using
the TXMLDocument.
> I basically need to itterate through a TQuery and produce an XML File from
> it based on dtd's that
> an external company have asked me to pass information to them in..
You could also use SAX (which is event based). For example (this is a sample
I am actually using):
SAXWriter:= TSAXWriter.Create();
Stream:= TStringStream.Create('');
try
SAXWriter.setOutput(Stream);
SAXWriter.startDocument();
// Set start, range, next and prev
Count:= sDataset.RecordCount;
Next:= Start + Range;
Prev:= Start - Range;
if (Prev < 1) then Prev:= 1;
// Attributes
Atts:= TAttributesImpl.Create();
Atts.addAttribute('', 'start', 'start', 'CDATA', IntToStr(Start));
Atts.addAttribute('', 'range', 'range', 'CDATA', IntToStr(Range));
Atts.addAttribute('', 'next', 'next', 'CDATA', IntToStr(Next));
Atts.addAttribute('', 'previous', 'previous', 'CDATA', IntToStr(Prev));
Atts.addAttribute('', 'count', 'count', 'CDATA', IntToStr(Count));
// Start the Element
SAXWriter.startElement('', 'rows', 'rows', atts as IAttributes);
// Iterate results
sDataset.First;
sDataset.MoveBy(Start-1);
for I:= Start to (Start + Range)-1 do
begin
if (sDataset.EOF) then Break;
// Set the data
SAXWriter.startElement('', 'row', 'row', nil);
for J:= 0 to sDataset.FieldCount-1 do
begin
if (sDataset.Fields[J].IsBlob) then Continue;
if (sDataset.Fields[J].IsNull) then Continue;
SAXWriter.startElement('', sDataset.Fields[J].DisplayName,
sDataset.Fields[J].DisplayName, nil);
S:= sDataset.Fields[J].AsString;
SAXWriter.characters(PSAXChar(S), Length(S));
SAXWriter.endElement('', sDataset.Fields[J].DisplayName,
sDataset.Fields[J].DisplayName);
end;
SAXWriter.endElement('', 'row', 'row');
// Go to the next record!
sDataset.Next;
end;
SAXWriter.endElement('', 'rows', 'rows');
SAXWriter.endDocument();
// Set the result
Result:= Stream.DataString;
finally
SAXWriter.Free;
Stream.Free;
end;
The latest SAX package can be found at http://xml.defined.net/SAX There is
no documentation right now, so this will be tougher.
> Perhaps I may even be looking at this from the wrong angle, I am
completely
> new to the world of XML so any suggestions would be much appreciated..
This is a fine angle. As far as the DTD is concerned-- you program will
probably just encapsulate the rules for the DTD, right? In D6 there are also
some tools that can build interfaces based on DTDs and Schemas. But if the
DTD is simple, or if you only have D5 you don't need this.
HTH,
Jeff Rafter
Defined Systems
http://www.defined.net
XML Development and Developer Web Hosting
Hi Martin,
> I basically need to itterate through a TQuery and produce an XML File from
> it based on dtd's that
> an external company have asked me to pass information to them in..
>
> Perhaps I may even be looking at this from the wrong angle, I am
completely
> new to the world of XML so
> any suggestions would be much appreciated..
you can try XMLComponents: http://xmlcomponents.com
XMLComponents provide a simple and rapid way to develop Client/Server web
applications with XML/XSL.
They based on Microsoft XML parser 3.0 that is encapsulated into a
TXMLCursor class. This Class allows to
create easily XML Document.
>
> Martin Dew
Regards.
--
Luke Denning