josegar74 ha scritto:
> Hi,
> 
> I'm parsing a filter like this with geotools
> 
> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc";>
>       <ogc:PropertyIsEqualTo>
>       <ogc:Literal>TRUE</ogc:Literal>
>       <ogc:Function name="During">
>               ...
>       </ogc:Function>
>       </ogc:PropertyIsEqualTo>
> </ogc:Filter>
> 
> 
> using next code
> 
>  Parser parser;
> 
>  // create the parser with the filter 1.1 configuration
>  Configuration configuration = new
> org.geotools.filter.v1_1.OGCConfiguration();
> 
> configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);
> 
> configuration.getProperties().add(Parser.Properties.PARSE_UNKNOWN_ATTRIBUTES);
>         
>  parser = new Parser(configuration);
> 
>  Filter filter = (Filter) parser.parse(data);
> 
> but I'm getting the next Exception
> 
> java.lang.RuntimeException: Parsing failed for Function:
> java.lang.RuntimeException: Unable to find function During
>       at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:158)
>       at
> org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:208)
>       at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:174)
>       at
> org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:222)
>       at 
> org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:582)
>       at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>       at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
> Source)
>       at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>       at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
>       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>       at org.geotools.xml.Parser.parse(Parser.java:180)
>       at org.geotools.xml.Parser.parse(Parser.java:140)
> 
> 
>  I think I have to implement a During class that extends
> FunctionExpressionImpl, but the problem is ¿how to register this class in
> geotools so parser doesnt fails? 

You have to register it in the SPI. If you look in the gt-main module
sources you'll see that in META-INF there is a text file that lists
the functions contained in the main module.
You have to do the same in your module, add a file in the same location,
with the same name, but listing the names of your functions.

See here:
http://svn.osgeo.org/geotools/branches/2.5.x/modules/library/main/src/main/resources/META-INF/services/org.opengis.filter.expression.Function

Cheers
Andrea


-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to