• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSL includes in a web-app.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a master XSL file which includes several sub xsl files using the
<xsl:include href="" /> directive. However, I load the master XSL file
using the classloader getResourceAsStream.

Something like..

String fileURI = "xsl/main.xsl" // relative to the classpath location of the
// main xsl file.

InputStream in = TransformerManager.class.getClassLoader().getResourceAsStream(fileURI);

javax.xml.transform.stream.StreamSource s = new javax.xml.transform.stream.StreamSource(in)

For some reason the child xsl files are not being resolved.


Any suggestions?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your main XSL file is loaded from an InputStream. So the transformer has no way of knowing what file it came from and hence no way of finding other files relative to it. Use the getResource() method which returns a URL, pass that to the Transformer, and then it will be able to find the other files relative to that URL.
 
Todd Baxter
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks that did it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic