also use FeatureReader!! OutputStream out; FeatureTransformer ft = new FeatureTransformer(); // set the indentation to 4 spaces ft.setIndentation(4); // this will allow Features with the FeatureType which has the namespace // "http://somewhere.org" to be prefixed with xxx... ft.getFeatureNamespaces().declarePrefix("xxx","http://somewhere.org"); // transform ft.transform(collection,out);
The above example assumes a homogenous collection of Features whose FeatureType has the namespace "http://somewhere.org" but note that not all DataSources currently provide FeatureTypes with a namespace... There are two other mechanisms for prefixing your Features.
1) Map a specific FeatureType
by identity to prefix and nsURI
FeatureType fc; FeatureTransformer ft = new FeatureTransformer(); ft.getFeatureTypeNamespaces().declareNamespace(fc,"xxx","http://somewhere.org");
2) Provide a default namespace for any Features whose FeatureType either has an empty namespace, OR, has not been mapped using the previous method. This is basically a catch-all mechanism.
FeatureTransformer ft = new FeatureTransformer(); ft.getFeatureTypeNamespaces().declareDefaultNamespace("xxx","http://somewhere.org");
The collectionNamespace and prefix property refers to the prefix and namespace given to the document root and defualts to wfs,http://www.opengis.wfs.
@author Ian Schneider
@author Chris Holmes, TOPP
@source $URL$
@version $Id$
@todo Add support for schemaLocation