You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by stephen <st...@yorksignal.org> on 2007/02/27 19:49:20 UTC
URIResolver base for document()
I am using Xalan in an HttpServlet to transform Documents created on the fly. I
wrote a URIResolver to pull the templates from the Servlet context
(ServletConfig.getServletContext().getResourceAsStream()). My resolver works
perfectly for xsl:includes. The calls to MyURIResolver for the includes in the
base template has a null base. I assign a base to the Sources I return via
Source.setSystemId() as appropriate. However, any uses of document() result in a
call to resolve() with a base of the directory from which java was called
prefixing the base I expect.
For example, with this war:
myapp.war/
xslt/
default.xsl
include/
fun.xsl
data/
fundata.xml
And this code:
Source source = new DOMSource( myDocument );
Source xslt = new StreamSource( myURIResolver.resolve( "default.xsl", null ) );
myTransformerFactory.setURIResolver( myURIResolver );
myTransformerFactor.newTransformer( xslt ).transform( source,
new StreamResult( someOutputStream ) );
default.xsl has
<xsl:include href="include/fun.xsl" />
which results in resolve( "include/fun.xsl", null )
my URIResolver returns a Source with fun.xsl, and a base of "include/".
fun.xsl has
document('data/fundata.xml')
which results in resolve( "data/fundata.xml", "file:///opt/jboss/bin/include/" )
Obviously, what I want is resolve( "data/fundata.xml" "include/" ).
Where exactly is the "file:///opt/jboss/bin/" coming from, and how do I set
something else instead?