protected void transformResponse(OutputStream output, CSWRecordsResult result, RequestBaseType request, CSWInfo csw) { CSWRecordTransformer transformer = new CSWRecordTransformer(request, csw.isCanonicalSchemaLocation()); transformer.setIndentation(2); try { transformer.transform(result, output); } catch (TransformerException e) { throw new ServiceException(e); } }
protected void transformResponse( OutputStream output, CSWRecordsResult result, RequestBaseType request, CSWInfo csw) { CSWRecordTransformer transformer = new CSWRecordTransformer(request, csw.isCanonicalSchemaLocation()); transformer.setIndentation(2); try { transformer.transform(result, output); } catch (TransformerException e) { throw new ServiceException(e); } } }
public void testEncodeSummary() throws Exception { // setup the request CSWRecordsResult response = getCSWResponse(); response.setElementSet(ElementSetType.SUMMARY); GetRecordsType request = getCSWRequest(); // transform it into a GetRecordsResponse (this time with the canonical location) CSWRecordTransformer tx = new CSWRecordTransformer(request, true); tx.setIndentation(2); StringWriter sw = new StringWriter(); tx.transform(response, sw); // System.out.println(sw); Document dom = XMLUnit.buildControlDocument(sw.toString()); // checking root elements assertXpathEvaluatesTo("1", "count(/csw:GetRecordsResponse)", dom); assertXpathEvaluatesTo( "http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/record.xsd", "/csw:GetRecordsResponse/@xsi:schemaLocation", dom); assertXpathEvaluatesTo("2012-07-10T15:00:00Z", "//csw:SearchStatus/@timestamp", dom); // check that we got summary records assertXpathEvaluatesTo("summary", "//csw:SearchResults/@elementSet", dom); assertXpathEvaluatesTo("12", "count(//csw:SummaryRecord)", dom); // check one summary record assertXpathEvaluatesTo("5", "count(//csw:SummaryRecord[dc:identifier = 'urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd']/*)", dom); assertXpathEvaluatesTo("http://purl.org/dc/dcmitype/Service", "//csw:SummaryRecord[dc:identifier = 'urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd']/dc:type", dom); assertXpathEvaluatesTo("Proin sit amet justo. In justo. Aenean adipiscing nulla id tellus.", "//csw:SummaryRecord[dc:identifier = 'urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd']/dct:abstract", dom); assertXpathEvaluatesTo("60.042 13.754", "//csw:SummaryRecord[dc:identifier = 'urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd']/ows:BoundingBox/ows:LowerCorner", dom); assertXpathEvaluatesTo("68.41 17.92", "//csw:SummaryRecord[dc:identifier = 'urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd']/ows:BoundingBox/ows:UpperCorner", dom); }
CSWRecordTransformer tx = new CSWRecordTransformer(request, true); tx.setIndentation(2); StringWriter sw = new StringWriter(); tx.transform(response, sw);
CSWRecordTransformer tx = new CSWRecordTransformer(request, false); tx.setIndentation(2); StringWriter sw = new StringWriter(); tx.transform(response, sw);