Hi all,

I need to serialize FeatureType instances.

I am trying to use org.geotools.gml.producer.FeatureTypeTransformer to
create a XML flow :

{code}

SimpleFeatureType next = ...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FeatureTypeTransformer t = new FeatureTypeTransformer();
baos.write("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\
">\n".getBytes());
                                                 // added because
SchemaFactory complains about not finding this tag
t.transform(next, baos);
baos.write("</xs:schema>".getBytes());

{code}

Then I try to read my XML back :

{code}

bais = new ByteArrayInputStream(baos.toByteArray());
Schema schema = SchemaFactory.getInstance(new URI("
http://www.w3.org/2001/XMLSchema";),bais);
               // raise NullPointerException
SimpleFeatureType type = (SimpleFeatureType)
GMLComplexTypes.createFeatureType(schema.getComplexTypes()[0]));

{code}

I get a NullPointerException at this point :

java.lang.NullPointerException
    at java.net.URI$Parser.parse(URI.java:3010)
    at java.net.URI.<init>(URI.java:578)
    at org.geotools.xml.handlers.xsi.SchemaHandler.startElement(
SchemaHandler.java:134)
    at org.geotools.xml.XSISAXHandler.startElement(XSISAXHandler.java:226)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
    at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:176)
    at org.geotools.xml.SchemaFactory.parseSchema(SchemaFactory.java:364)
    at org.geotools.xml.SchemaFactory.getRealInstance(SchemaFactory.java
:334)
    at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:326)
    at org.geotools.xml.SchemaFactory.getInstance(SchemaFactory.java:195)

Any idea about what I should do ?

Thanks,

Christophe
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to