wanted xml tool

Freeform discussion about anything related to modding Transcendence.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Would someone be willing to make a tool that gets all of the given tag?
Like if I wanted all the <shiptypes> you would ask for all the <shiptypes> and it would put them all (from the start tag until the end like in the case of <shiptypes> go to </shiptypes>) into a text file.
Crying is not a proper retort!
Silentdances
Commonwealth Pilot
Commonwealth Pilot
Posts: 56
Joined: Fri Mar 21, 2008 6:06 am

couldn't you modify the 'Post a reply' script and just have it output to a text file?

though, come to think of it.. that would be a rather nifty thing to have here on the forums (right up there with faq, search, memberlist, etc).. hit submit and it drops your script/modding into a window like the topic review window (below)
"Darkness makes the sunlight so bright, that our eyes blur with tears. Misery sharpens the edges of our joy. Challenges remind us that we are capable of great things. Life is hard. It is supposed to be."
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

eer I think you misunderstand
I would like a tool that would get all the stuff between the given xml tags from the transcendence xml files.

An example of use is say I wanted to overwrite all ships instead of my copy pasting all of them I would just have the tool do all the work.
Crying is not a proper retort!
Silentdances
Commonwealth Pilot
Commonwealth Pilot
Posts: 56
Joined: Fri Mar 21, 2008 6:06 am

oops :oops:
"Darkness makes the sunlight so bright, that our eyes blur with tears. Misery sharpens the edges of our joy. Challenges remind us that we are capable of great things. Life is hard. It is supposed to be."
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

What exactly ? You say you would have the tool identify tags and overwrite a given parameter with a given value ? Or did I misunderstand ?
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

I want a tool that takes all the given tags (and there data) and dumps them into a text file.

Like the example said earlier lets say you wanted to overwrite the ships you would have the tool get all the shiptype tags and dump them with there data into a text file so you have them ready of modding.

Also remember that transcendence xml is case insensitive.
Crying is not a proper retort!
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

OK, you want to build your Mod file with the extracted data, then edit them by hand...
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Mutos wrote:OK, you want to build your Mod file with the extracted data, then edit them by hand...
yep now I think you got it.
Crying is not a proper retort!
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi Betelgeuse,


I didn't find a soft that does it. Would have to be built in any programming language you know.

Principle is : read lines in your source, maintain a boolean, an opening element turns it to True, a closing element to False, and depending on the boolean, you output or not the line to the target file.

Of course, it would need some refining around, but that's the base concept. As simple as VBS could do it.

Apparently in Java there is a parser named SAX for XML? that could ease that. But as I don't have any Java compiler...
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

well I wanted someone else to do it I know I can do it
I like having other people help on things.

edit: it would be trivial with java (that is what I work with, no need to treat it as an xml) but I was hoping someone could make something that more people could use
Crying is not a proper retort!
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi Betelgeuse,


Could try to do it in VBS, but it would be crude. First argument, source file, second argument, target file, third argument, XML tag...
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

sounds good (ideally I would like to be able to more than one source file at a time but still want people contributing whatever they can :D)
Crying is not a proper retort!
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

There is already a handy little utility that can do what you want. If you're running Transcendence in WINE or have a dual boot with linux just hop into your Transcendance directory and type

Code: Select all

sed -n "/^<ShipClass*/,/<\/ShipClass>/"p TranscendenceSource\*.xml extensions\*.xml > ships.txt
Substitute whatever tag you're looking for for "ShipClass" and name your output file whatever you want. This assumes TranscendanceSource and extensions are in their default location.

If you're using just windows it's a little harder. Go to http://gnuwin32.sourceforge.net/packages/sed.htm and download the setup program. You then need to get into the system properties dialog box ([windows key]-[break]). Go to the advanced tab and click the Environment Variables button. In the System variables list box select path and click the corresponding edit. Append ;"C:\Program Files\GnuWin32\bin\" to the end of the path variable assuming you installed sed in the default location. Navigate to your Transcendance directory with the command prompt and use the same sed command. Voila, you have everything found between ShipClass tags, tags included, in one text file. This will be a unix style text file so it won't have proper line breaks if opened in notepad, but wordpad will read it just fine and the first time you save it it will correct it to a windows style text file.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

very cool it works
thanks for that
for my understanding can you explain the arguments for me?
Crying is not a proper retort!
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Sed normally feeds a text file to the screen line by line making the changes in the first argument after the switches. -n makes it output nothing. The next argument is a command. The p says to print a line and overrides -n. It is preceded by a line to print or a range of lines. Lines can be by number, $ for the last line of the file, or by regular expression. It will print any range of lines that starts with a line that matches /^<ShipClass*/ and ends with one that matches /<\/ShipClass>/. Regular expressions are one of those arcane tools I can't write without a book in front of me. The first matches any line that starts with "<ShipClass" and the second matches any line that contains nothing but "</ShipClass>". Come to think of it that should also have a * on the end in case their are comments at the end of the line, but I didn't think of that when I first posted. All arguments after the command are filenames. The > is a directive to the operating system to redirect output that would normally go to the console to a file instead. I think it was introduced in Windows 2000 so the guy who's running Transcendence on windows 98 can't do this.

I just realized the linux instructions are wrong as well. I put microsoft style paths with '\' insteal of unix style paths with '/'.
Post Reply