cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <je...@apache.org>
Subject Re: InspectableSources and InputModules (Re: [RT]: Dynamic variables in the Sitemap / Input Modules revisited)
Date Thu, 09 Jan 2003 13:46:03 GMT
On Thu, Jan 09, 2003 at 02:14:49PM +0100, Stephan Michels wrote:
> On Thu, 9 Jan 2003, Jeff Turner wrote:
...
> > Why not have the SourceDescriptionGenerator do:
> >
> > for (each file in the directory):
> > if (source instanceof InspectableSource) {
> >     sourceProperty = source.getSourceProperties(),
> >     createNewXMLAttribute(sourceProp.getName(), sourceProp.getValue());
> > }
> >
> > Then you'd automatically get attributes for any file metadata that is
> > made available by the InspectableSource.
> 
> The difference between SourceInspector and InspectableSource is that
> SourceInspector retrieves Properties independend of the Source
> implementation.
> For example, if want get height/width from a image it doesn't have
> anything to do with if had a ResourceSource or SitemapSource.

I see.  Well, same idea applies.. the generator feeds the Source to every
available SourceInspector, and for every SourceProperty it gets back,
creates an attribute.

...
> > How about:
> >
> > <source name="dir" collection="true">
> >  <source name="file.xml"/>
> >  <source name="file.jpg" height="${jpg:file.jpg#height}" width="${jpg:file.jpg#width}"/>
> > </source>
> 
> Something like that.
> 
> > Although, for your specific need, I think the InspectableSource-aware
> > Generator sounds simpler.  Assuming I've understood correctly.
> 
> Hmm, I think I had an idea. What about something like that
> 
> abstract SourceInputModule
> {
>   Object getAttribute( String name, Configuration modeConf, Map
>                        objectModel ) throws ConfigurationException
>   {
>     int index = name.indexOf("#");
>     String uri = name.substring(0, index-1);
>     String name = name.substring(index+1);
> 
>     return getSourceAttribute(uri, name, modeConf, objectModel);
>   }
> 
>   abstarct Object getSourceAttribute( String uri , String name ,
>                              Configuration modeConf, Map objectModel )
>     throws ConfigurationException;
> }
> 
> It uses the conventional interface.

Looks decent, but in practice, most classes will want to inherit from
more functional superclasses like AbstractJXPathModule, or
AbstractMetaModule, and Java doesn't have multiple inheritance.  For
example, XMLFileModule works on a Source, but needs AbstractJXPathModule,
so couldn't use SourceInputModule.


--Jeff

> Stephan Michels.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message