You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Dr. Uwe Meyer-Gruhl" <Uw...@congenio.de> on 2001/01/09 15:53:04 UTC

How to get the URI of an XML document in an XSL stylesheet?

Hi,


I have several XML files which are to be presented in either HTML or WML
by Cocoon.

The problem with WML is that there are severe length restrictions, which
I avoid by displaying only a certain aspect at a time. This can be done
by using <xsl:choose> and supplying an "aspekt" parameter in the XSLT
stylesheet like this:


        <xsl:choose>

        <xsl:when test="$aspekt='infos'">

        .
        .
        .

        </xsl:when>

        <xsl:otherwise>

                        <card id="rezept"><xsl:attribute
name="title"><xsl:value-of select="TITEL"/></xsl:attribute><p>
                        <big><xsl:value-of
select="TITEL"/></big><br/><br/>

                        <a href="?aspekt=zutaten">Zutaten</a><br/>
                        <a href="?aspekt=anleitung">Anleitung</a><br/>
                        <a href="?aspekt=infos">Informationen</a><br/>
                        </p></card>

        </xsl:otherwise>

        </xsl:choose>


Alas, I found out that some WAP browsers (like the Nokia) interpret
relative URLs starting with a question mark relative to the last but one
path component (i.e. the file name). That means if the XML source
document was: "http://www.xyz.com/abc/duck.xml" then following the
relative link "?aspekt=zutaten" would result in:
"http://www.xyz.com/abc/?aspekt=zutaten" instead of
"http://www.xyz.com/abc/duck.xml?aspekt=zutaten" as intended.
Matter-of-fact, this kind of relative URL is interpreted the "wrong" way
by Netscape Navigator and the "right" way by Internet Explorer also.

So I guess I have to find a way of generating the source document file
name from the stylesheet prepended to the "?aspekt=" part but have been
unlucky at finding out how. Is there a function or pre-defined variable
in Cocoon or Xalan or a method for that in standard XSLT?


Kind regards



Dr. Uwe Meyer-Gruhl


Re: How to get the URI of an XML document in an XSL stylesheet?

Posted by Johannes Koch <ko...@pixelpark.com>.
"Dr. Uwe Meyer-Gruhl" schrieb:
> 
> Hi,
> 
[...]
> So I guess I have to find a way of generating the source document file
> name from the stylesheet prepended to the "?aspekt=" part but have been
> unlucky at finding out how. Is there a function or pre-defined variable
> in Cocoon or Xalan or a method for that in standard XSLT?

You can get the XML file URI using XSP
(<xsp:expr>request.getRequestURI()</xsp:expr>)

-- 
Johannes Koch  . IT Developer
Pixelpark AG   . http://www.pixelpark.com
Rotherstraße 8 . 10553 Berlin  .  Germany
phone: +49 30 5058 - 1288  .  fax: - 1355

Re: How to get the URI of an XML document in an XSL stylesheet?

Posted by Viktors Rotanovs <vi...@riga.nu>.
Hi,

[C2] is there any way to make this inside XSL stylesheet
without using XSP?

On Tuesday 09 January 2001 18:18, you wrote:
> You could try
>
> <xsp-request:get-uri/> (cocoon 2), but I guess there must be an equivalent
> for this in the 'request' internal xsp page..
> ah, in cocoon 1 it is:
>
> <request:get-request-uri/>
>
> It does not return the complete URL, but usually just the filename..
>
> On Tue, 9 Jan 2001, Dr. Uwe Meyer-Gruhl wrote:
> > Hi,
> >
> >
> > I have several XML files which are to be presented in either HTML or WML
> > by Cocoon.
> >
> > The problem with WML is that there are severe length restrictions, which
> > I avoid by displaying only a certain aspect at a time. This can be done
> > by using <xsl:choose> and supplying an "aspekt" parameter in the XSLT
> > stylesheet like this:
> >
> >
> >         <xsl:choose>
> >
> >         <xsl:when test="$aspekt='infos'">
> >
> >         .
> >         .
> >         .
> >
> >         </xsl:when>
> >
> >         <xsl:otherwise>
> >
> >                         <card id="rezept"><xsl:attribute
> > name="title"><xsl:value-of select="TITEL"/></xsl:attribute><p>
> >                         <big><xsl:value-of
> > select="TITEL"/></big><br/><br/>
> >
> >                         <a href="?aspekt=zutaten">Zutaten</a><br/>
> >                         <a href="?aspekt=anleitung">Anleitung</a><br/>
> >                         <a href="?aspekt=infos">Informationen</a><br/>
> >                         </p></card>
> >
> >         </xsl:otherwise>
> >
> >         </xsl:choose>
> >
> >
> > Alas, I found out that some WAP browsers (like the Nokia) interpret
> > relative URLs starting with a question mark relative to the last but one
> > path component (i.e. the file name). That means if the XML source
> > document was: "http://www.xyz.com/abc/duck.xml" then following the
> > relative link "?aspekt=zutaten" would result in:
> > "http://www.xyz.com/abc/?aspekt=zutaten" instead of
> > "http://www.xyz.com/abc/duck.xml?aspekt=zutaten" as intended.
> > Matter-of-fact, this kind of relative URL is interpreted the "wrong" way
> > by Netscape Navigator and the "right" way by Internet Explorer also.
> >
> > So I guess I have to find a way of generating the source document file
> > name from the stylesheet prepended to the "?aspekt=" part but have been
> > unlucky at finding out how. Is there a function or pre-defined variable
> > in Cocoon or Xalan or a method for that in standard XSLT?
> >
> >
> > Kind regards
> >
> >
> >
> > Dr. Uwe Meyer-Gruhl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

-- 
Best Wishes,
Viktors Rotanovs
Riga, Latvia. Phone/Fax +371 7377-472

Re: How to get the URI of an XML document in an XSL stylesheet?

Posted by fo...@neonics.com.

You could try

<xsp-request:get-uri/> (cocoon 2), but I guess there must be an equivalent
for this in the 'request' internal xsp page..
ah, in cocoon 1 it is:

<request:get-request-uri/>

It does not return the complete URL, but usually just the filename..


On Tue, 9 Jan 2001, Dr. Uwe Meyer-Gruhl wrote:

> Hi,
> 
> 
> I have several XML files which are to be presented in either HTML or WML
> by Cocoon.
> 
> The problem with WML is that there are severe length restrictions, which
> I avoid by displaying only a certain aspect at a time. This can be done
> by using <xsl:choose> and supplying an "aspekt" parameter in the XSLT
> stylesheet like this:
> 
> 
>         <xsl:choose>
> 
>         <xsl:when test="$aspekt='infos'">
> 
>         .
>         .
>         .
> 
>         </xsl:when>
> 
>         <xsl:otherwise>
> 
>                         <card id="rezept"><xsl:attribute
> name="title"><xsl:value-of select="TITEL"/></xsl:attribute><p>
>                         <big><xsl:value-of
> select="TITEL"/></big><br/><br/>
> 
>                         <a href="?aspekt=zutaten">Zutaten</a><br/>
>                         <a href="?aspekt=anleitung">Anleitung</a><br/>
>                         <a href="?aspekt=infos">Informationen</a><br/>
>                         </p></card>
> 
>         </xsl:otherwise>
> 
>         </xsl:choose>
> 
> 
> Alas, I found out that some WAP browsers (like the Nokia) interpret
> relative URLs starting with a question mark relative to the last but one
> path component (i.e. the file name). That means if the XML source
> document was: "http://www.xyz.com/abc/duck.xml" then following the
> relative link "?aspekt=zutaten" would result in:
> "http://www.xyz.com/abc/?aspekt=zutaten" instead of
> "http://www.xyz.com/abc/duck.xml?aspekt=zutaten" as intended.
> Matter-of-fact, this kind of relative URL is interpreted the "wrong" way
> by Netscape Navigator and the "right" way by Internet Explorer also.
> 
> So I guess I have to find a way of generating the source document file
> name from the stylesheet prepended to the "?aspekt=" part but have been
> unlucky at finding out how. Is there a function or pre-defined variable
> in Cocoon or Xalan or a method for that in standard XSLT?
> 
> 
> Kind regards
> 
> 
> 
> Dr. Uwe Meyer-Gruhl
> 
>