--> If your command needs to refer to a file contained in my_ext.jar,
simply use Class.getResource(). Example:
MyCommand.class.getResource("/atts.txt")



--> If your command needs to refer to a file contained in the directory
where your add-on has been installed:

Solution A
----------

If your add-on contains a configuration (.xxe) file, add this property
element to it:

---
<property name="my-atts" url="true">atts.txt</property>
---

Your command may then use the value of system property "my-atts" (i.e.
System.getProperty("my-atts")), a fully resolved, absolute file:// URL,
to locate "atts.txt".

See http://www.xmlmind.com/xmleditor/_distrib/doc/configure/property.html

Solution B (you suggested it)
-----------------------------

[1] Add an XML catalog to your add-on. This XML catalog should contain
the following rule:

---
<rewriteURI uriStartString="my-addon:" rewritePrefix="." />
---

All files having a name ending with "atalog.xml" are automatically
loaded by XXE during its startup and added to the single, big, XML
catalog used everywhere.

[2] Use this API, com.xmlmind.xml.resolve.XMLCatalogs.resolveURI, to
resolve URIs such as this one: "my-addon:atts.txt".

See
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xml/resolve/XMLCatalogs.html#resolveURI(java.lang.String,%20java.net.URL)

This is how "xxe-config:" URLs work. There is no magic here.



Fabi?n Mandelbaum wrote:
> 
> I'm implementing an XXE customization as an addon (my_ext.jar) and
> need to open a file the customized command needs to perform its
> duties.
> Reading XXE docs (and sources, thanks again Hussein!), I've found
> things like xxe-config: URLs, and also the possibility to refer to
> resources inside JARs using jar:jar_name.jar!/resource URLs.
> 
> I'm wondering if there's an URL scheme that resolves to the addons dir
> (ex: ~/.xxe4/addon on Linux), or any other method to resolve this dir,
> in a OS-independent way (that is, that will work in all OSes supported by 
> XXE).
> 
> I can get to the file (inside the addon jar) if I use something like:
> 
> jar:file:///home/fabman/.xxe4/addon/myaddon/my_ext.jar!/atts.txt
> 
> but this only works on my Linux system (of course!) and I'd like to
> know if there's a more "general" way to change to something like:
> 
> jar:file:/ADD_ONS_DIR/myaddon/my_ext.jar!/atts.txt
> 
> where ADD_ONS_DIR is this special URL scheme or another XXE variable I
> can count on.
> 
> A solution that resembles this:
> 
> file:/ADD_ONS_DIR/myaddon/atts.txt
> 
> would be satisfactory also (that is, reference resources that are
> outside the addon jar, but inside the myaddon/ dir).
> 
> I was considering adding a catalog file to the addon and use an URI
> instead, but find this a not so elegant solution.
> 
> Hope to have been explicit enough, thank you in advance for your
> accurate and prompt (as usual) answer, and have a nice 2009!
> 



Reply via email to