[
https://issues.apache.org/jira/browse/SOLR-1656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998505#comment-12998505
]
Uwe Schindler commented on SOLR-1656:
-------------------------------------
This path at least fixes the CWD problem in an non-intrusive way using a
interface hack. I think that's perfectly fine to preserve the SystemID along
with the InputStream.
Problem is that the XML handling is a little bit inconsistent, because it
currently only work for files and only if the files are in exact same
directory. Theoretically, it *should* be possible that a XML file that is in
the conf folder (which is part of the classpath) can load a file from the lib
folder (which is also part of the resource classpath and should work with a
relative filename only path) or even from inside a JAR file (if the java
package name == classpath directory is identical).
This could only be solved by e.g. supplying a method
RessourceLoader.asFooBarResolver that returns a class that implements both
org.xml.sax.EntityResolver, javax.xml.transform.URIResolver (to work with
either SAX and TRAX) and delegates all requests to the underlying classloader.
Example could be taken from
[http://www.ibm.com/developerworks/xml/library/x-tipentres.html] (warning: this
example is not correct, but goes into right direction).
Another solution might be to not pass streams around, but simply feed the xml
parser with the URL.toString() returned by ClassLoader.getResource(). This
would also work with JAR files (I use this quite often in my code to parse XSL
or other XML files in the JAR file of my programs):
{code}
final URL url=MyClass.class.getResource("myXSLTFile.xslt");
if (url == null) throw new FileNotFoundException();
final Templates templates = transformerFactory.newTemplates(new
StreamSource(t.toString()));
{code}
This would also successfully load relative resources, but not accross JAR files
or different dirs (so "./anyfile.xml" would only find the file if its in same
java package in same JAR files but not if the file is in a different JAR file
or other classpath entry in same package).
> XInclude's are resolved relative CWD, not instance dir
> ------------------------------------------------------
>
> Key: SOLR-1656
> URL: https://issues.apache.org/jira/browse/SOLR-1656
> Project: Solr
> Issue Type: Bug
> Affects Versions: 1.4
> Reporter: Hoss Man
> Attachments:
> SOLR-1656_Support_SAX_SystemId_via_wrapping_InputStream.patch,
> Support_SAX_SystemId_via_wrapping_InputStream.patch
>
>
> As noted on the mailing list, when an XInclude in a config files refrences a
> relative path, it's resolved relative the CWD of the servlet container, and
> not the instanceDir of the core...
>
> http://old.nabble.com/using-Xinclude-with-multi-core-to26548400.html#a26548400
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]