Re: Resources Introspection

2006-04-24 Thread Dominique Devienne

 My dream :
 xslt in=somedata.xml out=someresult.html
styleresource=zip:file:foo/bar/my.zip!alpha/beta/style.xml/


No! It was my dream first and you can't have it! :)  I
agree wholeheartedly.  IIRC myself, Stefan, and
probably others took part in a discussion of this
nature some time ago... though I'm too frustrated by
my slow home internet connection to find the thread
ATM.  Maybe we can get some momentum behind this.  I
think the simplest approach would be to default to
file; but let the colon-delimited prefix represent a
defined type in the project, e.g. file, url... and
look it up.  At the time I believe I was able to
convince Stefan that this belonged in
IntrospectionHelper; sounds like you agree.


Hmmm, the proposed syntax looks very much like a URL, no? So why not
let the URL parsing code do all the work? The JDK code that does that
is supposed to follow the appropriate standard for this parsing, no
need to re-invent something that would have be to documented, no? a
URL is implicitly a Resource, isn't it? Are there Resource types which
are not URLs? To support any Resource type, even user-defined ones, to
be created from a plain string, you'd need to re-invent all the stuff
done in URL.

So my vote would be for Antoine's styleresource attribute to take a
URL, no? Of course there's the issue of where to resolve local paths
from? For URLs, it's normally the directory the XML (or HTML)
document was found in (i.e. it's parent URL), which kinda conflicts
with Ant's basedir philosophy.

FWIW, I used to install a custom resource: URL protocol before
import came along, so I could modularize my builds with entity
includes, but without having hard-coded paths. Once it's set, you can
find files (resources in the JDK sense) on the classpath anywhere,
and you get free parsing from the URL framework. The trick is to
install the URL though. Needs to be done as JVM startup, or needs a
custom URL factory I think (I always used the former).

BTW, Something which might be useful to use Resources in legacy tasks
accepting only File attributes would be a PropertyHelper that creates
a temp file from the resource (with proper timestamp copied from the
resource), with the deleteOnExit flag. So we could say xslt
style=${resource:foo.zip!/ant/bar.xsl} ... /. Error reporting might
suffer from such an approach though. A task (get?) could also do the
same, but would then need to expose an attribute name. Then again, it
would allow to remove the file right away after the transform.

Anyways, I'm rambling and might have strayed from the point ;-) --DD

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



Re: Resources Introspection

2006-04-23 Thread Ivan \Rambius\ Ivanov
Hello Antoine,

--- Antoine Levy-Lambert [EMAIL PROTECTED] wrote:

 Hello Matt and others,
 
 I want to change the xslt task, so that the
 stylesheet can be either a
 regular file or a zip entry (or may be even any
 resource).
I finally implemented a working solution of xslt task
accepting its stylesheet as a resource.

 This brings me to point : we do not have yet a
 syntax to generate
 resources from attributes, do we ?
I didn't checked if this syntax exists. Instead, I did
it in the following way:
xslt in=somedata.xml out=someresult.html
file file=style.xml/
/xslt

or

xslt in=somedata.xml out=someresult.html
url url=style.xml/
/xslt

I implemented it by adding addConfigured(Resource) to
XSLTProcess.

XSLTProcess delegates the xslt transformation work to
instances of XSLTLiaison. They accepted the stylesheet
as a file, so I hacked them to accept to is as a
resource.

The attached patch contains the changes for
XSTLProcess.java, XSLTLiaison.java, TRAXLiaision.java
and some unit tests for these changes.

Regards
Ivan  

 
 My dream :
 
 xslt in=somedata.xml out=someresult.html

styleresource=zip:file:foo/bar/my.zip!alpha/beta/style.xml/
 
 which would mean of course take from foo/bar/my.zip
 the entry
 alpha/beta/style.xml and use it to transform
 somedata.xml into
 someresult.html.
 
 Any ideas ?
 
 Regards,
 
 Antoine
 

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

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: Resources Introspection

2006-04-23 Thread Matt Benson
--- Antoine Levy-Lambert [EMAIL PROTECTED] wrote:

 Hello Matt and others,
 
 I want to change the xslt task, so that the
 stylesheet can be either a
 regular file or a zip entry (or may be even any
 resource).
 
 This brings me to point : we do not have yet a
 syntax to generate
 resources from attributes, do we ?
 
 My dream :
 
 xslt in=somedata.xml out=someresult.html

styleresource=zip:file:foo/bar/my.zip!alpha/beta/style.xml/
 

No! It was my dream first and you can't have it! :)  I
agree wholeheartedly.  IIRC myself, Stefan, and
probably others took part in a discussion of this
nature some time ago... though I'm too frustrated by
my slow home internet connection to find the thread
ATM.  Maybe we can get some momentum behind this.  I
think the simplest approach would be to default to
file; but let the colon-delimited prefix represent a
defined type in the project, e.g. file, url... and
look it up.  At the time I believe I was able to
convince Stefan that this belonged in
IntrospectionHelper; sounds like you agree.

-Matt

 which would mean of course take from foo/bar/my.zip
 the entry
 alpha/beta/style.xml and use it to transform
 somedata.xml into
 someresult.html.
 
 Any ideas ?
 
 Regards,
 
 Antoine
 

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


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: Resources Introspection

2006-04-23 Thread Robert Koberg

Hi,

I don't know if this is of interest, but I have made some custom tasks 
and types for XSLT. (I would think these could be used to get a resource 
from a jar) - for example:


- SourceType (have implemented a XmlDomType) - create a top-level DOM 
(dom4j, JDOM, etc...) Document that can be used in multiple XSLT tasks. 
The reason was to avoid reparsing a common XML file for multiple transforms.


- TemplatesType - create a top level Templates object that can be used 
in multiple XSLT tasks. This type can also take a UriResolverType for 
both the factory (resolves xsl:import/includes) and the transformer 
(resolves document function calls)


- UriResolverType - can be assigned to a TemplatesType. I have 
implemented a FallbackUriResolver which allows you to set a default 
directory to look in first and if a file is not found, it falls back to 
an alternate directory.


Additionally I have made a Lucene indexer and search type. The search 
type can be assigned to a UriResolver where a can be used in the 
document function (document('fieldName: matchValue')) and get search 
results back as XML for use in the transform.


Of interest?

best,
-Rob


Matt Benson wrote:

--- Antoine Levy-Lambert [EMAIL PROTECTED] wrote:


Hello Matt and others,

I want to change the xslt task, so that the
stylesheet can be either a
regular file or a zip entry (or may be even any
resource).

This brings me to point : we do not have yet a
syntax to generate
resources from attributes, do we ?

My dream :

xslt in=somedata.xml out=someresult.html


styleresource=zip:file:foo/bar/my.zip!alpha/beta/style.xml/

No! It was my dream first and you can't have it! :)  I
agree wholeheartedly.  IIRC myself, Stefan, and
probably others took part in a discussion of this
nature some time ago... though I'm too frustrated by
my slow home internet connection to find the thread
ATM.  Maybe we can get some momentum behind this.  I
think the simplest approach would be to default to
file; but let the colon-delimited prefix represent a
defined type in the project, e.g. file, url... and
look it up.  At the time I believe I was able to
convince Stefan that this belonged in
IntrospectionHelper; sounds like you agree.

-Matt


which would mean of course take from foo/bar/my.zip
the entry
alpha/beta/style.xml and use it to transform
somedata.xml into
someresult.html.

Any ideas ?

Regards,

Antoine





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



Resources Introspection

2006-04-22 Thread Antoine Levy-Lambert
Hello Matt and others,

I want to change the xslt task, so that the stylesheet can be either a
regular file or a zip entry (or may be even any resource).

This brings me to point : we do not have yet a syntax to generate
resources from attributes, do we ?

My dream :

xslt in=somedata.xml out=someresult.html
styleresource=zip:file:foo/bar/my.zip!alpha/beta/style.xml/

which would mean of course take from foo/bar/my.zip the entry
alpha/beta/style.xml and use it to transform somedata.xml into
someresult.html.

Any ideas ?

Regards,

Antoine

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