Results 1 to 13 of 13

Thread: XML: Worth Using?

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Question XML: Worth Using?

    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

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    If it ain't broke etc.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    This being tabular data and not tree-like data, CSV makes more sense than XML.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    Thanks for your replies.

    Can someone post an example of tree-like data?

  5. #5
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    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?.....

  6. #6

  7. #7
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    You got vb.net?

  8. #8

  9. #9
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    ok. give me a day or two to work a COM eg. send a reminder in a day though

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11
    Member
    Join Date
    Sep 2000
    Location
    Kentucky
    Posts
    56
    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?

  12. #12
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    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

  13. #13
    Member
    Join Date
    Sep 2000
    Location
    Kentucky
    Posts
    56
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width