Nifty..
Attached is a patch that allows the user to specify relative URLs (relative to
the context root) in the "uri" attribute.
--Jeff
On Mon, Apr 30, 2001 at 11:21:02AM -0700, Morgan Delagrange wrote:
> Hi all,
>
> I checked in a very preliminary version of some new XSL transform tags in
> the repository on the "rel2" branch. The build script doesn't really work
> yet; you'll need jaxp to compile it.
>
> It has new syntax compared to the current XSL tag library (see the example
> JSP for now, until the docs are ready.) It is based
> on TraX, so it should be pluggable with any trax parser. Right now it
> does simple transformations based on URIs, Readers, InputStreams, Strings
> and/or tag bodies.
>
> However, since it's based on TraX, it should be possible to also work with
> DOMs and possibly SAX events. Also, we can take advantage of other nice
> TraX features, like configurable output properties.
>
> I ripped out some features, like stylesheet caching, in this version to
> make the TraX conversion simpler. In a follow-up email, I'm going to
> nominate Rod Waldhoff as a committer, since he actually designed this tag
> library and I mostly just ported it to TraX.
>
> - Morgan
Index: BaseSourceTag.java
===================================================================
RCS file:
/home/cvspublic/jakarta-taglibs/xsl/src/org/apache/taglibs/xsl/Attic/BaseSourceTag.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 BaseSourceTag.java
--- BaseSourceTag.java 2001/04/30 18:06:05 1.1.2.1
+++ BaseSourceTag.java 2001/05/07 02:10:12
@@ -4,6 +4,7 @@
import java.io.Reader;
import java.io.StringReader;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -81,9 +82,33 @@
}
} else if(null != _uri) {
+ if (_uri.indexOf("://") == -1) {
+ _uri = getContextURI()+_uri;
+ }
source = new StreamSource(_uri);
}
-
return source;
}
+
+ /** Get the context's URI.
+ @return The URL string up to the end of the context, eg
+ <code>http://localhost:8080/context/</code>.
+ */
+ private String getContextURI() {
+ HttpServletRequest req = (HttpServletRequest)pageContext.getRequest();
+ String scheme = req.getScheme();
+ int port = req.getServerPort ();
+ StringBuffer url = new StringBuffer();
+ url.append (scheme); // http, https
+ url.append ("://");
+ url.append (req.getServerName ());
+ if ((scheme.equals ("http") && port != 80)
+ || (scheme.equals ("https") && port != 443)) {
+ url.append (':');
+ url.append (req.getServerPort ());
+ }
+ url.append(req.getContextPath());
+ return url.toString();
+ }
+
}