Click to See Complete Forum and Search --> : XML: Worth Using?
agmorgan
Jul 3rd, 2003, 06:00 AM
I use VB to control lab equipment that outputs loads of numbers.
Currently, the program outputs the results in a CSV file.
#DUT 7 - VSWR 2.0 s/n 1838 CIS/C/029
Frequency: MHz,VRC (Real),VRC (Imag.),Uncertainty (Real),Uncertainty (Imag.),Correlation coefficient
0.0300,-0.1274, 0.0001, 0.0030, 0.0030,-0.0041
0.0400,-0.1274, 0.0001, 0.0030, 0.0030,-0.0048
...
...
Do you think changing to XML would be worthwhile or
just a case of using it for the sake of it?
/Andrew
DeadEyes
Jul 3rd, 2003, 02:18 PM
If it ain't broke etc.
CornedBee
Jul 7th, 2003, 05:38 AM
This being tabular data and not tree-like data, CSV makes more sense than XML.
agmorgan
Jul 8th, 2003, 09:13 AM
Thanks for your replies.
Can someone post an example of tree-like data?
shunt
Jul 8th, 2003, 01:56 PM
Like DeadEyes said....
But, using xml can make debuging and other such tasks a lot easier. For example, you could use an xsd to make sure your file is in the correct format. You would then be able to check everything from field size to data type to pattern match to ...
XML does not only have to be used in a tree like structure. Take ADO.NET as an example. The datasets (very similar to recordsets, tables of data) are persisted using xml. The nice thing is, you can choose what the xml looks like.
In projects that I have worked on, I always output the data as xml, but run it through an xslt transformation before writing the data to the file. Using this transformation, I have been able to write out a file of fixed length fields (no xml at all). After a year, the client informed me that they could now handle an xml file and asked me to update the program. So all I did was update my xslt file which did the transformation to the fixed length fields to output the file as it was. The result, xml output. Time required, 5 minutes (They still pay you the equivalent of updating the program. I felt bad so gave them a nice discount).
Want a sample?.....
agmorgan
Jul 8th, 2003, 01:59 PM
that would be much appreciated :)
shunt
Jul 8th, 2003, 02:08 PM
You got vb.net?
agmorgan
Jul 8th, 2003, 02:33 PM
no only VB6 professional :(
shunt
Jul 8th, 2003, 03:40 PM
ok. give me a day or two to work a COM eg. send a reminder in a day though
CornedBee
Jul 9th, 2003, 01:14 AM
Originally posted by shunt
XML does not only have to be used in a tree like structure. Take ADO.NET as an example. The datasets (very similar to recordsets, tables of data) are persisted using xml. The nice thing is, you can choose what the xml looks like.
No, of course it does not have to be. Just look at the XHTML <table> element ;)
But the fact is, trees are far closer to the tag structure.
Kevin Swanson
Aug 26th, 2003, 01:05 PM
shunt,
I am looking for a way to do exactly what you did. I am going to export data to XML because of future requirements, but the current requirements are very basic. I would like to transform the XML with XSLT and output a simple CSV or fixed-length text file. How would I do this?
Is it possible to make the transformation without VB? Maybe a command line program?
shunt
Sep 2nd, 2003, 05:57 AM
Hi Kevin,
To transform the xml you first need the xml and xslt documents. If you use MSXML4 you load the xml document into one freethreadeddomdocument object and the xslt into another freethreadeddomdocument object. U must use the free threaded objects for transformation! You then need an xslTemplate object to which you assign the xslt object as the template. You then create a processor object from the xsltemplate. You then use processor.transform using the xml object as the input. Once this method completes you query the output of the processor for the result of the transformation. If this description is not 100% pls forgive me. Its been a while since i have dealt with transformations.
Note: It is possible to use com objects and script within the xslt document.
It is possible to do the transformation without vb. I have never done it myself, but it seems you can using processing tags in the xml document. You know the <? tags .... You can use those to tell a parser to execute any logic when processing the document. This is sometimes used so that when u open the xml document in IE for example, the xml document is transformed and an html page outputed to the screen.
I dont have any examples of this either. I think there is an example in the MSXML4 SDK. I have seen an example, but I just cant remember where.
For better correspondance use: dayne.olivier@za.sappi.com
I think it works...
I am on this address weekdays 8-5
Kevin Swanson
Sep 2nd, 2003, 08:07 AM
I found the solution I was looking for. There is msxsl.exe (a download from Microsoft). It is a command line program that transforms an XML with an XSLT and the results can be output to a file. I just have to write the XSLT that will create the text file in the format that I want.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.