Okay, here's a contrived example of what I'm talking about. All the XML and XSLT
data is embedded in the JSP, but it's sufficient as a demo.

<%@ page contentType="text/xml" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"; %>

<c:set var="doc">
<doc>
    <child>Doc 1</child>
    <child>Doc 2</child>
</doc>
</c:set>

<c:set var="xslt">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">
    <xsl:param name="stationStatus"/>
    <xsl:template match="/">
        <new-doc>
            <child><xsl:value-of
select="$stationStatus//child[position()=1]"/></child>
            <child><xsl:value-of select="//child[position()=1]"/></child>
        </new-doc>
    </xsl:template>
</xsl:stylesheet>
</c:set>

<c:set var="statusDoc">
<status>
    <child>Status 1</child>
    <child>Status 2</child>
</status>
</c:set>
<x:parse doc="${statusDoc}" varDom="parsedStatus"/>

<x:transform doc="${doc}" xslt="${xslt}">
    <x:param name="stationStatus" value="${parsedStatus}"/>
</x:transform>

Which outputs the equivalent of:

<?xml version="1.0" encoding="UTF-8" ?> 
<new-doc>
    <child>Status 1</child> 
    <child>Doc 1</child> 
</new-doc>

Quoting Kris Schneider <[EMAIL PROTECTED]>:

> The type of the scoped varible named by the "var" attribute of <c:import> is
> String. Since String is also an acceptable type for both the "doc" and
> "xslt"
> attributes of <x:transform>, you should be able to do:
> 
> <c:import var="doc" url="uiConfig.xml"/>
> <c:import var="xslt" url="station_list.xsl"/>
> <x:transform doc="${doc}" xslt="${xslt}"/>
> 
> As for the HTTP error, the handling of the URI passed to the document
> function
> is under the control of the XSLT processor. In fact, the XSLT spec says, "An
> XSLT processor is not required to support any particular URI schemes."
> Although, in practice, http is a pretty likely candidate for support. Even
> if
> it is supported, it's up to the XSLT processor implementation to handle the
> generation of the http request, which may or may not play nicely with your
> middleware setup. Hence, my attempt at an alternate approach. Can you provide
> a
> snippet from your stylesheet where you're using the document function?
> 
> If it's still of any help, here's what it looks like my example would be
> with
> your setup (assuming the "WebUI" servlet is part of the same app):
> 
> <c:import var="statusDoc" url="/WebUI">
>     <c:param name="action" value="getStationStatus"/>
> </c:import>
> <x:parse doc="${statusDoc}" varDom="parsedStatus"/>
> 
> <c:import var="doc" url="uiConfig.xml"/>
> <c:import var="xslt" url="station_list.xsl"/>
> 
> <x:transform doc="${doc}" xslt="${xslt}">
>     <x:param name="stationStatus" value="${parsedStatus}"/>
> </x:transform>
> 
> Quoting "Johnson, Chris" <[EMAIL PROTECTED]>:
> 
> > Still nothing.  But, the error message did change (see below).  It now
> > has the station_list file as the file containing the offending url.
> > Before it was some crazy file that doesn't exist.  But, I'm still
> > getting the same error.  Is it possible that it can't get output from a
> > servlet (in the same context anyway)?  If I call the url in a brower, it
> > works fine, so I know the url is valid, and there's valid xml being
> > returned.
> > 
> > jstl:station_list.xsl; Line #9; Column #124; Can not load requested doc:
> > Server returned HTTP response code: 500 for URL:
> > http://raptor.mtc.ti.com:9081/rtdui/WebUI?action=getStationStatus
> > 
> > -----Original Message-----
> > From: Mark R. Diggory [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, April 07, 2004 12:52 PM
> > To: Tag Libraries Users List
> > Subject: Re: XSLT question
> > 
> > 
> > Try just:
> > 
> > <c:import url="uiConfig.xml" var="config"/>
> > <x:parse var="xml" doc="${config}"/>
> > <c:import url="station_list.xsl" var="stylesheet"/> <x:transform
> > doc="${xml}" xslt="${stylesheet}" xsltSystemId="station_list.xsl"/>
> > 
> > I speculate that the c:import stores the content in a byte[] or pulls it
> > as an InputStream, creating a jaxp StreamSource for the template, the
> > problem is that the systemId gets lost in the process, for me its just a
> > workaround to stick it back into the JAXP transformers template Source
> > object. I really think JSTL is poorly mapped to JAXP, I believe one
> > should just be able to do
> > 
> > <x:transform doc="doc.xml" xslt="style.xml"/>
> > 
> > without all the importing crap...
> > 
> > -Mark
> > 
> > 
> > Johnson, Chris wrote:
> > 
> > >I guess I don't understand what the xlstSystemId needs to be set to.
> > >
> > >Here's my code as it is now:
> > >
> > ><c:import url="uiConfig.xml" var="config"/>
> > ><x:parse var="xml" doc="${config}"/>
> > ><c:import url="station_list.xsl" var="stylesheet"/> <x:transform 
> > >doc="${xml}" xslt="${stylesheet}"/>
> > >
> > >Inside this transform, I want to access something like: 
> > >http://host.name.com:port/context/servlet?param=value
> > >
> > >I'm running tomcat 5.0.19 and JSTL 1.1
> > >
> > >-----Original Message-----
> > >From: Mark R. Diggory [mailto:[EMAIL PROTECTED]
> > >Sent: Wednesday, April 07, 2004 12:29 PM
> > >To: Tag Libraries Users List
> > >Subject: Re: XSLT question
> > >
> > >
> > >Johnson, Chris wrote:
> > >
> > >  
> > >
> > >>I guess what I really want is an answer as to why document() isn't
> > >>working as it seems it should.
> > >> 
> > >>
> > >>    
> > >>
> > >Mostly, I think the unexpected behavior has to do with the standard
> > >implementations masking of underlying absolute paths to be relative to 
> > >the webapplication instead of the filesystem. For example, if your 
> > >webapp was installed in /usr/share/tomcat4/webapps/blaa
> > >
> > >/foo/bar actually maps to /usr/share/tomcat4/webapps/blaa/foo/bar.
> > >
> > >  
> > >
> > >>Besides, I'm already doing a transform on one document, so I don't
> > >>understand how doing this second transform on this other "document" 
> > >>(servlet call) would be able to be used in the first transform.
> > That's
> > >>    
> > >>
> > >
> > >  
> > >
> > >>why I was using document(), so I could read in another xml doc while
> > >>doing a transform.  I'm using the 2nd doc to do some conditional stuff
> > 
> > >>in the first transform.
> > >> 
> > >>
> > >>    
> > >>
> > >I do it now, but I'm working on tomcat4.1 and jstl 1.1
> > >
> > >  
> > >
> > >>But since I had nowhere to go but up, I did part of what Kris said.  I
> > >>tried doing an import of the doc, which worked, but I put the output 
> > >>(after parsing) into an x:param associated with the original (only) 
> > >>transform.  But that doesn't seem to work.
> > >> 
> > >>
> > >>    
> > >>
> > >It wouldn't really because most transformers use a different object 
> > >tree
> > >
> > >than DOM which the x:parse is producing.
> > >
> > >  
> > >
> > >>If I do a 2nd transform on the 2nd doc, how do I reference that in the
> > >>first transform?
> > >>
> > >>    
> > >>
> > >
> > >Did you try adding the xlstSystemId? this sets the systemId of the xslt
> > >and allows the document function to do relative resolution from the 
> > >systemId, thats just straight xslt spec/JAXP  behavior. I'm using it in
> > 
> > >jstl 1.1 because of this very issue.
> > >
> > >What version of JSTL/standard.jar are you working with, which version 
> > >of
> > >
> > >Tomcat?
> > >
> > >  
> > >
> > >>-----Original Message-----
> > >>From: Mark R. Diggory [mailto:[EMAIL PROTECTED]
> > >>Sent: Wednesday, April 07, 2004 12:04 PM
> > >>To: Tag Libraries Users List
> > >>Subject: Re: XSLT question
> > >>
> > >>
> > >>Try setting the systemId for the stylesheet, this may help configure
> > >>the
> > >>
> > >>proper resolution.
> > >>
> > >>           <c:import var="xslt" scope="request" url='${url}'/>
> > >>           <x:transform xml="${xml}" xslt="${xslt}"
> > >>xsltSystemId="${url}"> -Mark
> > >>
> > >>Kris Schneider wrote:
> > >>
> > >> 
> > >>
> > >>    
> > >>
> > >>>As an alternative, perhaps you can use an XSLT parameter to hold the 
> > >>>servlet
> > >>>output:
> > >>>
> > >>><c:import url="/xmlServlet" var="servletXml"/>
> > >>><x:parse xml="${servletXml}" var="servletDoc"/>
> > >>><x:transform xml="${xml}" xslt="${xslt}">
> > >>>  <x:param name="dynamicXml" value="${servletDoc}"/> </x:transform>
> > >>>
> > >>>Where your stylesheet would include an <xsl:param> element:
> > >>>
> > >>><xsl:param name="dynamicXml"/>
> > >>>
> > >>>Haven't tried this with a full-blown document as a parameter 
> > >>>before...
> > >>>
> > >>>Quoting "Johnson, Chris" <[EMAIL PROTECTED]>:
> > >>>
> > >>>
> > >>>
> > >>>   
> > >>>
> > >>>      
> > >>>
> > >>>>I'm having trouble using the XSLT document() function.
> > >>>>
> > >>>>What I need to do is to call a servlet which will send back some 
> > >>>>dynamic xml that I need to reference in my XSLT template.
> > >>>>
> > >>>>I've tried using various relative paths, and the full (http://...) 
> > >>>>path with no luck.  When I use the full path, I get this error in 
> > >>>>the
> > >>>>        
> > >>>>
> > >
> > >  
> > >
> > >>>>catalina.out file: Can not load requested doc: Server returned HTTP
> > >>>>response code: 500 for
> > >>>>URL: http:...  I've made sure there are no typos in the url.
> > >>>>
> > >>>>When using a relative path, the error suggests that document() is 
> > >>>>looking for the resource as a file on the server.
> > >>>>
> > >>>>I've looked around on the web and see people supposedly using
> > >>>>document() with full paths, but nothing describing the problem I'm
> > >>>>having.
> > >>>>
> > >>>>Any help would be greatly appreciated.
> > >>>>
> > >>>>Thanks,
> > >>>>Chris
> 
> -- 
> Kris Schneider <mailto:[EMAIL PROTECTED]>
> D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to