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 rd...@svb.nl on 2005/11/25 16:11:42 UTC

auto-translet

Hi,

We're using Xalan 2.6.0, xsltc. 

Regarding following codesnippet:

TransformerFactory transFact = TransformerFactory.newInstance();

transFact.setAttribute("generate-translet", Boolean.TRUE);
transFact.setAttribute("auto-translet", Boolean.TRUE);
transFact.setAttribute("package-name", "uniquepackagename));
transFact.setAttribute("destination-directory", templateLocation);

Source source = new StreamSource(xslUri.toExternalForm());
source.setSystemId(xslUri.toExternalForm());
templates = transFact.newTemplates(source);

One issue with stylesheets coming from different directories & bearing
the same name has been solved by passing a unique packagename to the
'package-name' attribute.

However, another issue popped up: it seems the auto-translet isn't
working like it should. Compiled stylesheets & source are physically
located on different machines. It seems the call made to
getStylesheetFileName from getBytecodesFromClasses is where the problem
lies:

    private String getStylesheetFileName(Source source)
    {
    	String systemId = source.getSystemId();
      	if (systemId != null) {
            File file = new File(systemId);
            if (file.exists())
                return systemId;
            else {
              	URL url = null;
          	try {
            	    url = new URL(systemId);
          	}
          	catch (MalformedURLException e) {
            	    return null;
          	}
          
          	if ("file".equals(url.getProtocol()))
            	    return url.getFile();
          	else
            	    return null;
            }
      	}
      	else
            return null;
    } 

In our base & unit tests this return null when compiled stylesheets and
source are located on different systems.

Anyone having a suggestion or confirmation?

Greetings,

Robert

Re: auto-translet

Posted by Robert den Uijl <rd...@svb.nl>.
> Hi,I could not find anything wrong with
> auto-translet using Xalan 2.7.0.  The only thing that seems to cause
> it to misbehave is if the time on the two systems is out of sync.  Could
> you give more details as to what is going wrong (e.g. you changed the source
> but it doesn't recompile), and how you have the two systems set up (how
> does the first system access the source on the second system)?Thanks.
> Erin Harris


Hi,

We're using Xalan 2.6.0. However, in 2.7.0 the getStylesheetFileName method 
has not been changed. 

Description of runtime setup and noticed behavior:

- stylesheet is on a remote server (http://myhost/apath/named.xsl)
- runtime this URL is set via setSystemId
(source.setSystemId(xslUri.toExternalForm());)
- if not yet compiled, compilation will take place
- if compiled, internally in xsltc getBytecodesFromClasses will be called
- remote stylesheet has been changed after compilation took place
- to exclude caching issues, server has been stopped and started
- to exclude out of sync timestamp issues several tests have been run several 
days after compilation took place (timestamps have been verified manually also)
- once compiled, with the current settings, using auto-translet combined with 
http-protocol, as long as the class files remain in the destination directory 
there's no way the remote stylesheet will ever be recompiled again
- crucial in this scenario is the getStylesheetFileName method:
* File file = new File(systemId); --> non existing File object
* ("file".equals(url.getProtocol())) --> nope, getProtocol() returns 'http'
* as a fix URLConnection should be used?
- tests have been run in debug and non-debug mode; in debug mode we noticed 
the behavior regarding the getStylesheetFileName method

I hope this clarifies the issue.

Regards, 

Robert



 





Re: auto-translet

Posted by Erin Harris <eh...@ca.ibm.com>.
Hi,

I could not find anything wrong with auto-translet using Xalan 2.7.0.  The 
only thing that seems to cause it to misbehave is if the time on the two 
systems is out of sync.  Could you give more details as to what is going 
wrong (e.g. you changed the source but it doesn't recompile), and how you 
have the two systems set up (how does the first system access the source 
on the second system)?

Thanks.


Erin Harris





<rd...@svb.nl> 
11/25/2005 10:11 AM

To
<xa...@xml.apache.org>
cc
<ec...@kabelfoon.nl>
Subject
auto-translet






Hi, 
We're using Xalan 2.6.0, xsltc. 
Regarding following codesnippet: 
TransformerFactory transFact = TransformerFactory.newInstance(); 
transFact.setAttribute("generate-translet", Boolean.TRUE); 
transFact.setAttribute("auto-translet", Boolean.TRUE); 
transFact.setAttribute("package-name", "uniquepackagename)); 
transFact.setAttribute("destination-directory", templateLocation); 
Source source = new StreamSource(xslUri.toExternalForm()); 
source.setSystemId(xslUri.toExternalForm()); 
templates = transFact.newTemplates(source); 
One issue with stylesheets coming from different directories & bearing the 
same name has been solved by passing a unique packagename to the 
'package-name' attribute.
However, another issue popped up: it seems the auto-translet isn't working 
like it should. Compiled stylesheets & source are physically located on 
different machines. It seems the call made to getStylesheetFileName from 
getBytecodesFromClasses is where the problem lies:
    private String getStylesheetFileName(Source source) 
    { 
        String systemId = source.getSystemId(); 
        if (systemId != null) { 
            File file = new File(systemId); 
            if (file.exists()) 
                return systemId; 
            else { 
                URL url = null; 
                try { 
                    url = new URL(systemId); 
                } 
                catch (MalformedURLException e) { 
                    return null; 
                } 
 
                if ("file".equals(url.getProtocol())) 
                    return url.getFile(); 
                else 
                    return null; 
            } 
        } 
        else 
            return null; 
    } 
In our base & unit tests this return null when compiled stylesheets and 
source are located on different systems. 
Anyone having a suggestion or confirmation? 
Greetings, 
Robert