You are here

How can I write this path in XML?

20 posts / 0 new
Last post
Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
How can I write this path in XML?

So I'm trying to deal with 3 XML settings files in JStock Portable that require a path. Here's the important stuff from all of them:

...\module\project.xml (the whole file)

<org.yccheok.jstock.gui.IndicatorProjectManager>
  <preferredOperatorIndicatorType>ModuleIndicator</preferredOperatorIndicatorType>
  <projects/>
  <directory>[%USERPROFILE%\.jstock\1.0.6\module should be written here]</directory>
</org.yccheok.jstock.gui.IndicatorProjectManager>

...\indicator\project.xml (the whole file)

<org.yccheok.jstock.gui.IndicatorProjectManager>
  <preferredOperatorIndicatorType>AlertIndicator</preferredOperatorIndicatorType>
  <projects/>
  <directory>[%USERPROFILE%\.jstock\1.0.6\indicator should be written here]</directory>
</org.yccheok.jstock.gui.IndicatorProjectManager>

...\config\options.xml

<org.yccheok.jstock.gui.JStockOptions>
  <!--...-->
  <lastFileIODirectory>[%PAL:DataDir%\saves should be written here]</lastFileIODirectory>
  <!--...-->
</org.yccheok.jstock.gui.JStockOptions>

(It took an incredible amount of time for that to show up correctly.)

I thought it'd be pretty easy, but the manual's examples don't apply to this particular case, nor am I familiar enough with XML to try to figure it out myself.

So is it possible or should I just write a virus that the launcher runs instead and infects the world wide web and destroys our lifestyles as we know it? I don't want to feel compelled to go with the latter, but if that's what it takes...

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 3 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
Answers

Yeah, Xpaths are tricky to get the hang of. Here's what they should look like (based on what you've given)

...\module\project.xml

[FileWriteN]
Type=XML text
File=...\module\project.xml
XPath=/org.yccheok.jstock.gui.IndicatorProjectManager/directory
Value=%USERPROFILE%\.jstock\1.0.6\module

...\indicator\project.xml

[FileWriteN]
Type=XML text
File=...\module\project.xml
XPath=/org.yccheok.jstock.gui.IndicatorProjectManager/directory
Value=%USERPROFILE%\.jstock\1.0.6\indicator

...\config\options.xml

[FileWriteN]
Type=XML text
File=...\config\options.xml
XPath=/org.yccheok.jstock.gui.JStockOptions/LastFileIODirectory
Value=%PAL:DataDir%\saves
Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Not working

None of them seem to be working. In the indicator/project.xml one, I think you forgot to replace "module" with "indicator" in the FileWrite for that part, and I fixed it but it was to no avail. While there's a slim chance the module/project.xml might be working the last two are definitely not.

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 3 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
<projects/>

I just noticed an empty tag in the first two files. Try inserting project between the Xpath sections.

[EDIT] options.XML: can you post the full file?

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Pastebin
Gord Caswell
Gord Caswell's picture
Offline
Last seen: 5 months 3 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
Try these

...\module\project.xml

[FileWriteN]
Type=XML text
File=...\module\project.xml
XPath=/org.yccheok.jstock.gui.IndicatorProjectManager/projects/directory
Value=%USERPROFILE%\.jstock\1.0.6\module

...\indicator\project.xml

[FileWriteN]
Type=XML text
File=...\indicator\project.xml
XPath=/org.yccheok.jstock.gui.IndicatorProjectManager/projects/directory
Value=%USERPROFILE%\.jstock\1.0.6\indicator

...\config\options.xml

[%PAL:DataDir%\saves should be written here]

Note that config\options hasn't changed from what i posted earlier.

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Nope

None of them worked.

Sad

Here's a zip of JStock Portable in case your curious about what I'm doing.

The Data folder is where the files are at (it's about 40 MB of data to load, so it's going to take a bit for the app to start.)

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
FYI

Seeing all the issues you are having I took the liberty to ask the developer of JStock a question in regards to what you are trying to do. Will let you know if I get an answer

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Thanks

I think you meant the .jstock folder, though (you said file :P)

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
hopefully he understands

He seems quite active, in fact I downloaded the zip file while we were talking, the second time I launched it I got a new version available because of security issues....time will though

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
Got a response

Apparently he saying you can not change the location of the folder. Sad

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
Can I ask

a probably stupid question? (BTW not waiting for answer to that going to ask anyway).

Why? Why are you trying to re-write the XML? I just grabbed your zip folder and put it on my drive. Then went to another computer with it and ran ran it. It appeared to work as expected. It saved the information as well as updated the xml on its own. Mind you I went from 7 to xp with it, it did it all correctly...appears in looking deeper it has to do with the automatic detection it uses from the gui part of java.

So unless I am missing something why re-create something already there?

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Well,

I honestly have no idea. It just looks important, so I wanted to play is safe.

I don't know what the deal with it was, but I couldn't use JStock to it's full potential because it doesn't work behind a proxy that requires authorization, so I couldn't ever tell whether JStock updates the files by itself or if it relied on them to do something, or what.

I mean, why write data that's completely useless?

I do suppose I could push a dev test out and see if people run into problems.

yccheok
Offline
Last seen: 11 years 5 months ago
Joined: 2012-03-06 00:32
Halo

Halo, I am the project admin of JStock. It's so great to see there is effort of making JStock workable under PortableApps.

If you need any information, let me know. I am glad to help. Biggrin

Good luck!

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
If you'd like to,

You can follow this thread:
https://portableapps.com/node/31437

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
Could you make a tiny modification?

Regarding this issue, I was wondering if you could create an option to select where the .jstock folder data could be located instead of %USERPROFILE% so that I could point the JStock data to the JStockPortable\Data folder instead (to avoid the issue I mentioned).

yccheok
Offline
Last seen: 11 years 5 months ago
Joined: 2012-03-06 00:32
I get the similar request

I get the similar request from here, just wondering whether *he* is *you*?

http://sourceforge.net/projects/jstock/forums/forum/723855/topic/3848818

What my proposed solution is, I will modify jstock, so that you can launch jstock in the way

will store data in c:\my_own_dir
================================
jstock.exe -userdir=c:\my_own_dir

will store data in default location
===================================
jstock.exe

Just wondering, will this solve your problem in making JStock into portableapp? If it is yes, I will go ahead and implement my proposed solution.

Thanks.

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
if you are referring to

vf2nsr

[Avatar]
2012-02-28 18:41:34 PST
Is it possible to get the .jstock file that is added to the USERPROFILE folder saved as well to usb stick? that would make it really portable?

as the he Pyromaniac is not him it is me I asked your forum as to maybe try to help Pyromaniac figure out a way to make it work without having to do major xml editing

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

Pyromaniac
Pyromaniac's picture
Offline
Last seen: 9 years 2 weeks ago
Developer
Joined: 2008-09-30 19:18
I've already solved the problem

All I had to do was set -Duser.home to the directory I specified and it worked as intended.

Thanks, though.

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
Just

trying to cya with my last statement Pyro, I think my original intentions to try to help may have messed things up, so want it clear to the developer that you and I are not one in the same

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

Log in or register to post comments