XML plugin transform fails when XSL imports from grandparent directories
------------------------------------------------------------------------

                 Key: MOJO-1517
                 URL: http://jira.codehaus.org/browse/MOJO-1517
             Project: Mojo
          Issue Type: Bug
            Reporter: Tim Carpenter


If my XSL file has something like

<xsl:stylesheet>
    <xsl:import href="../../somefile.xsl"/>

    <xsl:template ...>
    </xsl:template>
</xsl:stylesheet>

then the plugin throws an exception (the exception is really caused by 
classworlds) and the transformation fail

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1937)
        at org.codehaus.classworlds.UrlUtils.normalizeUrlPath(UrlUtils.java:28)
        at 
org.codehaus.classworlds.DefaultClassRealm.getResource(DefaultClassRealm.java:284)
        at 
org.codehaus.classworlds.DefaultClassRealm.getResource(DefaultClassRealm.java:314)
        at 
org.codehaus.classworlds.RealmClassLoader.getResource(RealmClassLoader.java:237)
        at org.codehaus.mojo.xml.Resolver.resolveAsResource(Resolver.java:209)
        at org.codehaus.mojo.xml.Resolver.resolve(Resolver.java:280)
        at org.codehaus.mojo.xml.Resolver.resolve(Resolver.java:112)
        at 
net.sf.saxon.style.XSLGeneralIncorporate.getIncludedStylesheet(XSLGeneralIncorporate.java:104)
        at 
net.sf.saxon.style.XSLStylesheet.spliceIncludes(XSLStylesheet.java:754)
        at 
net.sf.saxon.style.XSLGeneralIncorporate.getIncludedStylesheet(XSLGeneralIncorporate.java:168)
        at 
net.sf.saxon.style.XSLStylesheet.spliceIncludes(XSLStylesheet.java:754)
        at net.sf.saxon.style.XSLStylesheet.preprocess(XSLStylesheet.java:676)
        at 
net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:331)
        at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:163)
        at 
net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:139)
        at 
org.codehaus.mojo.xml.TransformMojo.getTemplate(TransformMojo.java:167)
        at org.codehaus.mojo.xml.TransformMojo.transform(TransformMojo.java:451)
        at org.codehaus.mojo.xml.TransformMojo.execute(TransformMojo.java:585)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at 
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

The UrlUtils.normalizeUrlPath is pretty dodgy, it tried to change paths like 

x/y/../z

to

x/z

but when the path starts with ../ (as in this case) it does not work.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to