You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Dzmura <md...@digital-mission.com> on 2000/04/03 20:28:19 UTC

absolute references to stylesheets??

Hi:

Can anybody tell me a way to make a low-overhead way to make an absolute
reference to a stylesheet??

The following fragment:

    <?xml-stylesheet href="/dphome.xsl" type="text/xsl"?>

rather than specify the file "dphome.xsl" in the virtual root of the webserver,
always attempts to build a a path relative to the current file, with the
href stuck on the end...

Ulrich offered an XSP-based technique, but this has the overhead
of the URL lookup plus running the java code, just to return an absolute file??

Thanks in advance,
Mark Dzmura

--
)))) This email routed via a wireless gateway!! ((((



Re: absolute references to stylesheets??

Posted by Stefano Mazzocchi <st...@apache.org>.
Ulrich Mayring wrote:
> 
> #postgres@digital-mission.com wrote:
> >
> > Hi:
> >
> > Can anybody tell me a way to make a low-overhead way to make an absolute
> > reference to a stylesheet??
> >
> > The following fragment:
> >
> >     <?xml-stylesheet href="/dphome.xsl" type="text/xsl"?>
> 
> href="http://your.host.tld/dphome.xsl"
> 
> This is a Xalan issue, not a cocoon thing.

No, the xml-stylesheet PI is interpreted by Cocoon, not Xalan because we
need more control on the media type.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: absolute references to stylesheets??

Posted by Mark Dzmura <md...@digital-mission.com>.
Oops!

In my haste I spoke too soon on this one... I think the idea was right, but the
implementation was flawed.  What really needs to be done in the case of
a relative path is to:

    1. strip off getPathInfo() from getPathTranslated()
    2. concatentate the result and the "absolute" file name

Fix the appropriate line of my earlier code snippet as follows:

   String fullPath = request.getPathTranslated;
   local = new File(fullPath.substring(0,  fullPath.length() - request.getPathInfo().length()) + url);

Of course, this code is assuming that

    (request.getPathTranslated().endsWith(request.getPathInfo())) == true

As regards the consistency of these calls from servlet engine to servlet
engine, I have regrettably used only JServ and can provide no insight...

Regards,
Mark D

> On Tue, 4 Apr 2000, Mark Dzmura wrote:
>
> > Ulrich:
> >
> > Using a URL to access an absolute resource means I have to:
> >
> > 1. process a URL instead of a file at run time
> > 2. change URL's when I move from development to deployment
> >
> > I believe I have found the place in the XSLT code where this
> > questionable interpretation of file location occurs:
> >
> >                     try {
> >                         if (url.indexOf("://") < 0) {
> >                             local = new File(path + url);
> >                         } else {
> >                             local = new URL(url);
> >                         }
> >
> > This code very simply concatenates path and url to form the
> > full file path...  It seems to me this code should not be so simple-minded,
> > but should look more like this:
> >
> >     try
> >         {
> >         if (url.indexOf("://") < 0)
> >             {
> >             if (url.startsWith("/"))
> >                 local = new File(request.getPathInfo() + url);
> >             else
> >                 local = new File(path + url);
> >             }
> >         else
> >             local = new URL(url);
> >         }
> >
> > With this implementation, requestes for absolute files are not hopelessly broken.
> > Does anybody else agree??
>
> That sounds reasonable to me, but before I commit the patch, does anyone
> know if request.getPathInfo() is in fact reliably portable across servlet
> engines? It seems to me that this might be one of those things that varies
> from engine to engine...
>
> - donald
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

--
)))) This email routed via a wireless gateway!! ((((



Re: absolute references to stylesheets??

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 4 Apr 2000, Mark Dzmura wrote:

> Ulrich:
> 
> Using a URL to access an absolute resource means I have to:
> 
> 1. process a URL instead of a file at run time
> 2. change URL's when I move from development to deployment
> 
> I believe I have found the place in the XSLT code where this
> questionable interpretation of file location occurs:
> 
>                     try {
>                         if (url.indexOf("://") < 0) {
>                             local = new File(path + url);
>                         } else {
>                             local = new URL(url);
>                         }
> 
> This code very simply concatenates path and url to form the
> full file path...  It seems to me this code should not be so simple-minded,
> but should look more like this:
> 
>     try
>         {
>         if (url.indexOf("://") < 0)
>             {
>             if (url.startsWith("/"))
>                 local = new File(request.getPathInfo() + url);
>             else
>                 local = new File(path + url);
>             }
>         else
>             local = new URL(url);
>         }
> 
> With this implementation, requestes for absolute files are not hopelessly broken.
> Does anybody else agree??

That sounds reasonable to me, but before I commit the patch, does anyone
know if request.getPathInfo() is in fact reliably portable across servlet
engines? It seems to me that this might be one of those things that varies
from engine to engine...

- donald


Re: absolute references to stylesheets??

Posted by Mark Dzmura <md...@digital-mission.com>.
Ulrich:

Using a URL to access an absolute resource means I have to:

1. process a URL instead of a file at run time
2. change URL's when I move from development to deployment

I believe I have found the place in the XSLT code where this
questionable interpretation of file location occurs:

                    try {
                        if (url.indexOf("://") < 0) {
                            local = new File(path + url);
                        } else {
                            local = new URL(url);
                        }

This code very simply concatenates path and url to form the
full file path...  It seems to me this code should not be so simple-minded,
but should look more like this:

    try
        {
        if (url.indexOf("://") < 0)
            {
            if (url.startsWith("/"))
                local = new File(request.getPathInfo() + url);
            else
                local = new File(path + url);
            }
        else
            local = new URL(url);
        }

With this implementation, requestes for absolute files are not hopelessly broken.
Does anybody else agree??

Regards,
Mark


> #postgres@digital-mission.com wrote:
> >
> > Hi:
> >
> > Can anybody tell me a way to make a low-overhead way to make an absolute
> > reference to a stylesheet??
> >
> > The following fragment:
> >
> >     <?xml-stylesheet href="/dphome.xsl" type="text/xsl"?>
>
> href="http://your.host.tld/dphome.xsl"
>
> This is a Xalan issue, not a cocoon thing.
>
> Ulrich
>
> --
> Ulrich Mayring
> DENIC eG, Softwareentwicklung
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

--
)))) This email routed via a wireless gateway!! ((((



Re: absolute references to stylesheets??

Posted by Ulrich Mayring <ul...@denic.de>.
#postgres@digital-mission.com wrote:
> 
> Hi:
> 
> Can anybody tell me a way to make a low-overhead way to make an absolute
> reference to a stylesheet??
> 
> The following fragment:
> 
>     <?xml-stylesheet href="/dphome.xsl" type="text/xsl"?>

href="http://your.host.tld/dphome.xsl"

This is a Xalan issue, not a cocoon thing.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung