[
https://issues.jboss.org/browse/JBESB-3340?page=com.atlassian.jira.plugin...
]
Henrique Viecili commented on JBESB-3340:
-----------------------------------------
Workaround:
setup uri-resolver property in the XSLAction and create a URIResolver implementation with
the following code:
{code:title=XSLURIResolver extends URIResolver|borderStyle=solid}
public Source resolve(String href, String base) throws TransformerException {
String resource = href;
try {
URI uri;
uri = new URI(href);
if (uri.isAbsolute()) {
String sysCP = System.getProperty("java.class.path");
if (LOG.isDebugEnabled()) {
LOG.debug("(System) java.class.path: "+sysCP);
}
if (!sysCP.endsWith("/")) {
StringBuilder sysClassPath = new StringBuilder(sysCP);
sysClassPath.delete(sysClassPath.lastIndexOf("/")+1,
sysClassPath.length());
sysCP = sysClassPath.toString();
}
String path = uri.getPath();
if (path.contains(sysCP)) {
resource = path.replaceAll(sysCP, "");
}
}
} catch (URISyntaxException e) {
if (LOG.isWarnEnabled()) {
LOG.warn("cannot create URI for "+href, e);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Resource to be loaded from application classpath:
"+resource);
}
Source source = new
StreamSource(getClass().getClassLoader().getResourceAsStream(resource));
return source;
}
{code}
XsltAction does not resolve relative uri properly
-------------------------------------------------
Key: JBESB-3340
URL:
https://issues.jboss.org/browse/JBESB-3340
Project: JBoss ESB
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Transformation Service
Affects Versions: 4.6
Environment: Windows XP Pro, CZ, JBossESB Server 4.6 with Sun JDK 1.6.0_17using
javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl
Reporter: Jan Vlcinsky
Attachments: jboss-esb.xml, template-small.xsl
Xslt relative path are resolved not from the place, template is located, but from bin
directory (from which is JBoss started)
<xsl:variable name="locs"
select="document('region/pl/Warszawa.xml')"/>
complains about not being able to find the file in
D:\opt\jbossesb-server-4.6\bin\region\pl\Warshawa.xml even though the tempate is located
inside of esb package.
Using XSLT 2.0 I tried also
<xsl:attribute name="resolvedUri"><xsl:value-of
select="resolve-uri('region/pl/Warshawa.xml',
base-uri(/))"/></xsl:attribute>
and result shows exactly the same value of
"D:\opt\jbossesb-server-4.6\bin\region\pl\Warshawa.xml".
For testing I used this template
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:element name="jbossesb">
<xsl:attribute name="resolvedUri"><xsl:value-of
select="resolve-uri('region/pl/Warshawa.xml',
base-uri(/))"/></xsl:attribute>
<xsl:text>Local name of root element is: </xsl:text><xsl:value-of
select="local-name(/*)"/><xsl:text>
Number of children elements on second level is: </xsl:text><xsl:value-of
select="count(/*/*)"/>
<xsl:text>
Total number of elements in the document is: </xsl:text><xsl:value-of
select="count(//*)"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
and following Esb file
<?xml version="1.0"?>
<jbossesb parameterReloadSecs="5"
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trun...
http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schem...
<providers>
<fs-provider name="FSprovider1">
<fs-bus busid="helloFileChannel">
<fs-message-filter
directory="D:\var\projects\EsbSimpleFileGate\filegate\input"
error-delete="false"
error-directory="D:\var\projects\EsbSimpleFileGate\filegate\error"
error-suffix=".IN_ERROR" input-suffix=".xml"
post-delete="false"
post-directory="D:\var\projects\EsbSimpleFileGate\filegate\output"
post-suffix=".sentToEsb" work-suffix=".esbWorking"/>
</fs-bus>
</fs-provider>
</providers>
<services>
<service category="myCategory"
description="Hello World File Action (esb listener)"
invmScope="GLOBAL" name="myFileListener">
<listeners>
<fs-listener busidref="helloFileChannel" is-gateway="true"
name="FileGateway" poll-frequency-seconds="10"/>
</listeners>
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.SystemPrintln"
name="printBeforeXslt">
<property name="message"/>
</action>
<action
class="org.jboss.soa.esb.actions.transformation.xslt.XsltAction"
name="XsltAction">
<property name="templateFile"
value="/template-small.xsl"/>
<property name="resultType" value="STRING"/>
<property name="failOnWarning" value="true"/>
</action>
<action class="org.jboss.soa.esb.actions.SystemPrintln"
name="printAfterXslt">
<property name="message"/>
</action>
</actions>
</service>
</services>
</jbossesb>
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira