PEDRAZA4 Posted July 20, 2011 Share Posted July 20, 2011 I have a txt file that was exported from a system, this file is following a structure form. I would like to convert this file into xml format in order to do a report. An example of the file is described below. STEP NAME="LAST_STEP" { RECTANGLE= { X=945 Y=372 H=40 W=100 } ACTION NAME="A1" { DESCRIPTION="Step msg" ACTION_TYPE=ASSIGN QUALIFIER=P EXPRESSION="'^/MSG.CV' := ""Calc Complete. Press Start to Transfer.""" DELAY_TIME=0 } ACTION NAME="A3" { DESCRIPTION="Enable Subordinate Failures" ACTION_TYPE=ASSIGN QUALIFIER=P EXPRESSION="'^/MONITOR/SUB1_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB2_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB3_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB4_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB5_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB6_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB7_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB8_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB9_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB10_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB11_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB12_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB13_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB14_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB15_FAIL/DISABLE.CV' := 0;'^/MONITOR/SUB16_FAIL/DISABLE.CV' := 0;" DELAY_TIME=0 } Link to comment Share on other sites More sharing options...
Ingolme Posted July 20, 2011 Share Posted July 20, 2011 Is this meant to be done manually or automtically? If it's automatic, what programming languages do you have available? Link to comment Share on other sites More sharing options...
PEDRAZA4 Posted July 20, 2011 Author Share Posted July 20, 2011 The process should be performed automatically, since I'm only showing part of the txt file ( the complete file has a lot of code similar to what I present.I don't know what is used to convert the file to the format that I present due that this is a proprietary software. In terms of the software available that I could use, I'm open to suggestion. I have experienced with C++ and visual basic, but if there is a more easy way I will use it Link to comment Share on other sites More sharing options...
Ingolme Posted July 20, 2011 Share Posted July 20, 2011 This might not be absolutely necessary for you at the moment, as it's an entire field of study in computer science, but knowing grammar (computer science term) would give you a good idea how to make the program: http://en.wikipedia.org/wiki/Formal_grammarBut to break this down to a simple algorithm you could build, you must define a set of rules for the source and target languages, and then read and write following those rules.Your language seems a bit complicated, because you have two cases where different syntaxes are used for the same purpose: STEP NAME="LAST_STEP"{ and RECTANGLE={ You must define a list of all the rules that your syntax follows. Here's a couple of them: The first few characters from A-Z (and maybe 0-9?) define the type of object. After a type identifier can go three things:* An opening curly bracket indicating a set of objects that are children to this one.* An equals sign, indicating that this object has one value. The value of this object follows the equals sign and has its own set of rules which need to be defined.* A syntax with its own set of rules (A-Z0-9 followed by an = and then a values which may be quoted) indicating a property of the object. Following this syntax must go the curly brace mentioned before. And so on, I could keep defining all the rules your document follows, but only you know for certain what characters are and aren't allowed in each part. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.