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 Robert van Loenhout <r....@greenvalley.nl> on 2004/06/01 15:26:53 UTC

Re: URIResolver

John Gentilin wrote:
> You know the URL resolver will only cache the XSL files that are included
> through xsl:include / import.

I suspected that much, but since I did use xsl:include too I thought I would
try the URIResolver first.
Setting the resolver on the factory helped me to be able to cache the
included xsl file.

After that I tried to use the Templates for caching the main transformer.
Will this automatically cache
the included documents too? Because I am not really able to cache the
included document anymore
with the URIResolver. Because the base parameter of the resolve method is no
longer the actual
file that was used to create the transformer. And now I am unable to 'find'
the included document
with the base and href parameters.



                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

Re: URIResolver & Templates

Posted by Robert van Loenhout <r....@greenvalley.nl>.
John Gentilin wrote:
> How do you create the Templates, SteramSource, SAXSource, DOSource. Are
> you setting the SystemID ??

Ahh the problem was that I also used a generic file caching mechanism so
that I
created the StreamSource with a ByteArrayInputStream and losing the systemid
information.
Setting the systemId for the StreamSource in my Templates cacher and
URIResolver solved the problems.
Thanks for all the help.




                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

Re: URIResolver & Templates

Posted by John Gentilin <ge...@eyecatching.com>.
The Templates object you create will contain the XML elements of the aggregate
including the head XSL file and its includes. So if you cache the Templates
object you will effectively be caching the included XSL file but it is one
object if you have two different head XSL with the same include, the included
XSL will be included separately in each of the respected objects.

How do you create the Templates, SteramSource, SAXSource, DOSource. Are 
you setting the SystemID ??

What JDK are you using ??

I have run into issues with version of the JDK/Xalan/Xerces where the
meaning of "file://" may need to be "file:" or "file:///" it can become 
very confusing. Just look at the source for the Redirect extension. 
See snipit below.

-JG

Redirect.java line:342
  // yuck.
  // Note: this is not the best way to do this, and may not even 
  //    be fully correct! Patches (with test cases) welcomed. -sc
  private String urlToFileName(String base)
  {
    if(null != base)
    {
      if(base.startsWith("file:////"))
      {
        base = base.substring(7);
      }
      else if(base.startsWith("file:///"))
      {
        base = base.substring(6);
      }
      else if(base.startsWith("file://"))
      {
        base = base.substring(5); // absolute?
      }
      else if(base.startsWith("file:/"))
      {
        base = base.substring(5);
      }
      else if(base.startsWith("file:"))
      {
        base = base.substring(4);
      }
    }
    return base;
  }

Robert van Loenhout wrote:

> I have a more general question about using Templates.
> How do I use relative xsl:include hrefs with the TransformerFactory
> newTemplates method?
> I get the following error:
> "Had IO Exception with stylesheet file: templates.xsl"
> 
> 
> Robert van Loenhout wrote:
> 
>>John Gentilin wrote:
>>
>>>You know the URL resolver will only cache the XSL files that are
> 
> included
> 
>>>through xsl:include / import.
>>
>>I suspected that much, but since I did use xsl:include too I thought I
> 
> would
> 
>>try the URIResolver first.
>>Setting the resolver on the factory helped me to be able to cache the
>>included xsl file.
>>
>>After that I tried to use the Templates for caching the main transformer.
>>Will this automatically cache
>>the included documents too? Because I am not really able to cache the
>>included document anymore
>>with the URIResolver. Because the base parameter of the resolve method is
> 
> no
> 
>>longer the actual
>>file that was used to create the transformer. And now I am unable to
> 
> 'find'
> 
>>the included document
>>with the base and href parameters.
> 
> 
> 
> 
>                                                                               
>                                                                               
>                                                                                



Re: URIResolver & Templates

Posted by Robert van Loenhout <r....@greenvalley.nl>.
I have a more general question about using Templates.
How do I use relative xsl:include hrefs with the TransformerFactory
newTemplates method?
I get the following error:
"Had IO Exception with stylesheet file: templates.xsl"


Robert van Loenhout wrote:
> John Gentilin wrote:
> > You know the URL resolver will only cache the XSL files that are
included
> > through xsl:include / import.
>
> I suspected that much, but since I did use xsl:include too I thought I
would
> try the URIResolver first.
> Setting the resolver on the factory helped me to be able to cache the
> included xsl file.
>
> After that I tried to use the Templates for caching the main transformer.
> Will this automatically cache
> the included documents too? Because I am not really able to cache the
> included document anymore
> with the URIResolver. Because the base parameter of the resolve method is
no
> longer the actual
> file that was used to create the transformer. And now I am unable to
'find'
> the included document
> with the base and href parameters.