Does dicetools support ActiveXObject or another way to access local files [fload()] (of course, with dicetools running off of the computer itself)?
ActiveXObject would make handling xml character sheets a breeze. fload would take a bit of testing and work, but could also do it.
If there is no equivalent, may I request for these to be added?
-
This is, of course, for functions.js
ActiveXObject or fload support
Moderators: dorpond, Azhrei, giliath
No, DiceTool does not currently support accessing ActiveX objects. It does however support everything that is possible in Java. The engine we are currently using is called "Rhino" and information about it is available here: http://www.mozilla.org/rhino/.
Tell me a little more about what you are trying to do with it and lets see if we can figure out an alternate way.
Tell me a little more about what you are trying to do with it and lets see if we can figure out an alternate way.
~Giliath
I wish to load an xml document using a javascript function. More specifically, if possible, pull child information from nodes or just get based on xml node names.
Here's the xml document (an rpgwebprofiler 3E profile document) (Purr.xml)
(replace | with <, cause the code on phpbb want to remove a lot of information from tags...)
My end goal is for the ability to do the following in DiceTools:
GetXml('Purr.xml','Str') to produce 14
Here's the xml document (an rpgwebprofiler 3E profile document) (Purr.xml)
Code: Select all
|?xml version="1.0" encoding="iso-8859-1"?>
|!DOCTYPE character PUBLIC "-//rpgprofiler.net//DTD 3EProfiler 1.0//EN"
"http://www.rpgprofiler.net/2003/3EProfiler.dtd">
|character xmlns="http://www.rpgprofiler.net/2003/3EProfiler">
<source>...edited out...</source>
<cname>Purr</cname>
<template>d20 v3.5 DnD</template>
<public>y</public>
<data>
|node name="firstload">false</node>
...(various other unimportant nodes)...
|node name="Str">14</node>
My end goal is for the ability to do the following in DiceTools:
GetXml('Purr.xml','Str') to produce 14
This should be possible using a combination of JAXP and XPath that is built into Java 1.5.
Here are some references that should lead you down the right path.
http://java.sun.com/developer/technical ... tionxpath/
http://www.mozilla.org/rhino/scriptjava.html
Here are some references that should lead you down the right path.
http://java.sun.com/developer/technical ... tionxpath/
http://www.mozilla.org/rhino/scriptjava.html
~Giliath
I threw together a quick example.
[/quote]
Code: Select all
function testJava(statName) {
var builder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
var doc = builder.parse(new java.io.File("test01.xml"));
var xpath = Packages.javax.xml.xpath.XPathFactory.newInstance().newXPath();
row.setLabel(xpath.evaluate("/character/name", doc, Packages.javax.xml.xpath.XPathConstants.STRING));
var value = xpath.evaluate("/character/stats/stat[@name='" + statName + "']", doc, Packages.javax.xml.xpath.XPathConstants.NUMBER);
java.lang.System.out.println(value);
return value;
}
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<character>
<name>Giliath</name>
<stats>
<stat name="Str">10</stat>
<stat name="Con">11</stat>
<stat name="Dex">12</stat>
<stat name="Int">13</stat>
<stat name="Wis">14</stat>
<stat name="Chr">15</stat>
</stats>
</character>
~Giliath
Great! Thank you!
This almost works as is, except I had to remove
and
the notes sections from the RPG Profiler files.
After that, worked well! I am using now:
so, I could use.. say..
getx("Int","Purr") to get Int from Purr.xml
This almost works as is, except I had to remove
Code: Select all
!DOCTYPE character PUBLIC "-//rpgprofiler.net//DTD 3EProfiler 1.0//EN"
"http://www.rpgprofiler.net/2003/3EProfiler.dtd"
the notes sections from the RPG Profiler files.
After that, worked well! I am using now:
Code: Select all
function getx(Cn,Cf) {
var builder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
var doc = builder.parse(new java.io.File(Cf + ".xml"));
var xpath = Packages.javax.xml.xpath.XPathFactory.newInstance().newXPath();
return xpath.evaluate("/character/data/node[@name='" + Cn + "']", doc, Packages.javax.xml.xpath.XPathConstants.NUMBER);;
}
getx("Int","Purr") to get Int from Purr.xml