You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael Schuerig <mi...@schuerig.de> on 2004/11/21 20:05:01 UTC

Accessing a file from a Serializer?

In a serializer, I would like to implement writeSchema by reading in a 
file that contains the schema definition. I have the file anyway and 
this way consistency is ensured. Using Types.loadInputSchema(URL) 
things could be really easy. If only I could obtain a URL pointing to 
my file. ServletContext.getResource(path) would help a lot -- but how 
do I get hold of the relevant ServletContext instance?

Michael

-- 
Michael Schuerig                 Nothing is as brilliantly adaptive
mailto:michael@schuerig.de       as selective stupidity.
http://www.schuerig.de/michael/    --A.O. Rorty, The Deceptive Self

Re: Accessing a file from a Serializer?

Posted by Michael Schuerig <mi...@schuerig.de>.
On Sunday 21 November 2004 20:05, Michael Schuerig wrote:
> If only I could obtain a URL pointing to my file.

    public Element writeSchema( Class javaType, Types types )
        throws Exception {
        if (StringUtils.isNotBlank(_schemaName)) {
            URL schemaURL = getClass().getResource(_schemaName);
            if (schemaURL != null) {
                types.loadInputSchema(schemaURL.toString());
            } else {
                logger.error("No XML schema file found for name: " +
                         _schemaName);
            }
        }
        return null;
    }

M.

-- 
Michael Schuerig                       Face reality and stare it down
mailto:michael@schuerig.de        --Jethro Tull, Silver River Turning
http://www.schuerig.de/michael/