Xml 在WebLogic中使用相对路径调用xslt document()函数
在XSL样式表中,我尝试使用document()函数和XML文件的相对路径。我试图加载的XML文件与样式表位于同一文件夹中。后端中的代码正在使用transformer调用XSLT Java代码Xml 在WebLogic中使用相对路径调用xslt document()函数,xml,weblogic,xslt,Xml,Weblogic,Xslt,在XSL样式表中,我尝试使用document()函数和XML文件的相对路径。我试图加载的XML文件与样式表位于同一文件夹中。后端中的代码正在使用transformer调用XSLT Java代码 TransformerFactory tFactory = TransformerFactory.newInstance(); InputStream inXSL = getClass().getResourceAsStream("/input.xsl"); Transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
InputStream inXSL = getClass().getResourceAsStream("/input.xsl");
Transformer transformer = tFactory.newTransformer(new StreamSource(inXSL));
transformer.transform(new StreamSource(inXMLStream), new StreamResult(outStream));
XSL
但是由于某种原因,它似乎没有加载文件,它给出了以下错误:,
FODC0005:java.io.FileNotFoundException:D:\Applications\weblogic\u domain\config.xml
XSL似乎在寻找WebLogic域文件夹中的文件,而不是web应用程序路径 因为您提供了StreamSource并且没有设置systemId,所以XSLT处理器不知道样式表是从哪里加载的,所以它无法智能地解析相对URI。使用StreamSource上的setSystemId()方法为样式表设置基本URI
<xsl:variable name="configXml" select="document('config.xml')" />