List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException;
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportBoundingBoxInput(XMLStreamWriter writer, BoundingBoxInput input) throws XMLStreamException { // "wps:Data" element writer.writeStartElement(WPS_NS, "Data"); // "wps:BoundingBoxData" element writer.writeStartElement(WPS_NS, "BoundingBoxData"); OWSCommonXMLAdapter.exportBoundingBoxType(writer, input.getValue()); writer.writeEndElement();/*w w w .j ava 2 s . c om*/ writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportComplexInput(XMLStreamWriter writer, ComplexInput input) throws XMLStreamException { if (input instanceof EmbeddedComplexInput) { writer.writeStartElement(WPS_NS, "Data"); XMLStreamReader reader = ((EmbeddedComplexInput) input).getComplexDataAsXMLStream(); // copy "wps:ComplexData" element writeElement(writer, reader);/*from w w w . ja v a 2 s . co m*/ writer.writeEndElement(); } else if (input instanceof ReferencedComplexInput) { writer.writeStartElement(WPS_NS, "Reference"); ReferencedComplexInput referencedInput = (ReferencedComplexInput) input; // "mimeType" attribute (optional) if (referencedInput.getMimeType() != null) { writer.writeAttribute("mimeType", referencedInput.getMimeType()); } // "encoding" attribute (optional) if (referencedInput.getEncoding() != null) { writer.writeAttribute("encoding", referencedInput.getEncoding()); } // "schema" attribute (optional) if (referencedInput.getSchema() != null) { writer.writeAttribute("schema", referencedInput.getSchema()); } // "xlink:href" attribute (required) writer.writeAttribute(XLN_NS, "href", "" + referencedInput.getURL()); writer.writeEndElement(); } }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportOutputDefinitions(XMLStreamWriter writer, ExecuteResponse response) throws XMLStreamException { // "wps:OutputDefinitions" (minOccurs="0", maxOccurs="1") writer.writeStartElement(WPS_NS, "OutputDefinitions"); // request must contain a response document (otherwise lineage could not be true) ResponseDocument responseDoc = (ResponseDocument) response.getRequest().getResponseForm(); for (RequestedOutput output : responseDoc.getOutputDefinitions()) { // "ows:Output" (minOccurs="1", maxOccurs="unbounded") writer.writeStartElement(WPS_NS, "Output"); // "asReference" attribute (optional) writer.writeAttribute("asReference", "" + output.getAsReference()); // "uom" attribute (optional) if (output.getUom() != null) { writer.writeAttribute("uom", output.getUom()); }/*from ww w . j a v a 2 s. c om*/ // "mimeType" attribute (optional) if (output.getMimeType() != null) { writer.writeAttribute("mimeType", output.getMimeType()); } // "encoding" attribute (optional) if (output.getEncoding() != null) { writer.writeAttribute("encoding", output.getEncoding()); } // "schema" attribute (optional) if (output.getSchemaURL() != null) { writer.writeAttribute("schema", "" + output.getSchemaURL()); } // "ows:Identifier" (minOccurs="1", maxOccurs="1") writer.writeStartElement(OWS_NS, "Identifier"); if (output.getIdentifier().getCodeSpace() != null) { writer.writeAttribute("codeSpace", output.getIdentifier().getCodeSpace()); } writer.writeCharacters(output.getIdentifier().getCode()); writer.writeEndElement(); // "ows:Title" (minOccurs="0", maxOccurs="1") if (output.getTitle() != null) { writer.writeStartElement(OWS_NS, "Title"); if (output.getTitle().getLanguage() != null) { writer.writeAttribute("xml:lang", output.getTitle().getLanguage()); } writer.writeCharacters(output.getTitle().getString()); writer.writeEndElement(); } // "ows:Abstract" (minOccurs="0", maxOccurs="1") if (output.getAbstract() != null) { writer.writeStartElement(OWS_NS, "Abstract"); if (output.getAbstract().getLanguage() != null) { writer.writeAttribute("xml:lang", output.getAbstract().getLanguage()); } writer.writeCharacters(output.getAbstract().getString()); writer.writeEndElement(); } writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportProcess(XMLStreamWriter writer, ProcessDefinition process) throws XMLStreamException { // "wps:Process" (minOccurs="1", maxOccurs="1") writer.writeStartElement(WPS_NS, "Process"); writer.writeAttribute(WPS_NS, "processVersion", process.getProcessVersion()); // "ows:Identifier" (minOccurs="1", maxOccurs="1") writer.writeStartElement(OWS_NS, "Identifier"); if (process.getIdentifier().getCodeSpace() != null) { writer.writeAttribute("codeSpace", process.getIdentifier().getCodeSpace()); }/*from w w w . ja v a 2 s .c o m*/ writer.writeCharacters(process.getIdentifier().getValue()); writer.writeEndElement(); // "ows:Title" (minOccurs="1", maxOccurs="1") if (process.getTitle() != null) { writer.writeStartElement(OWS_NS, "Title"); if (process.getTitle().getLang() != null) { writer.writeAttribute("xml:lang", process.getTitle().getLang()); } writer.writeCharacters(process.getTitle().getValue()); writer.writeEndElement(); } // "ows:Abstract" (minOccurs="0", maxOccurs="1") if (process.getAbstract() != null) { writer.writeStartElement(OWS_NS, "Abstract"); if (process.getAbstract().getLang() != null) { writer.writeAttribute("xml:lang", process.getAbstract().getLang()); } writer.writeCharacters(process.getAbstract().getValue()); writer.writeEndElement(); } // "ows:Metadata" (minOccurs="0", maxOccurs="unbounded") if (process.getMetadata() != null) { for (Metadata metadata : process.getMetadata()) { writer.writeStartElement(OWS_NS, "Metadata"); if (metadata.getAbout() != null) { writer.writeAttribute("about", metadata.getAbout()); } if (metadata.getHref() != null) { writer.writeAttribute(XLN_NS, "href", metadata.getHref()); } writer.writeEndElement(); } } // "wps:Profile" (minOccurs="0", maxOccurs="unbounded") if (process.getProfile() != null) { for (String profile : process.getProfile()) { writeElement(writer, WPS_NS, "Profile", profile); } } // "wps:WSDL" (minOccurs="0", maxOccurs="unbounded") if (process.getWSDL() != null) { writeElement(writer, WPS_NS, "WSDL", XLN_NS, "href", process.getWSDL()); } writer.writeEndElement(); // wps:Process }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportStatus(XMLStreamWriter writer, ProcessExecution state) throws XMLStreamException { writer.writeStartElement(WPS_NS, "Status"); // "creationTime" attribute (mandatory) long creationTime = state.getFinishTime(); if (creationTime == -1) { // use creation time of document if process execution has not been finished yet creationTime = System.currentTimeMillis(); }/*w w w . j a va 2s . com*/ writer.writeAttribute("creationTime", ISO8601Converter.formatDateTime(new Date(creationTime))); switch (state.getExecutionState()) { case ACCEPTED: writeElement(writer, WPS_NS, "ProcessAccepted", state.getAcceptedMessage()); break; case STARTED: writer.writeStartElement(WPS_NS, "ProcessStarted"); writer.writeAttribute("percentCompleted", "" + state.getPercentCompleted()); if (state.getStartMessage() != null) { writer.writeCharacters(state.getStartMessage()); } writer.writeEndElement(); break; case PAUSED: writer.writeStartElement(WPS_NS, "ProcessPaused"); writer.writeAttribute("percentCompleted", "" + state.getPercentCompleted()); if (state.getPauseMessage() != null) { writer.writeCharacters(state.getPauseMessage()); } writer.writeEndElement(); break; case SUCCEEDED: writeElement(writer, WPS_NS, "ProcessSucceeded", state.getSucceededMessage()); break; case FAILED: writer.writeStartElement(WPS_NS, "ProcessFailed"); OWS110ExceptionReportSerializer exceptionAdapter = new OWS110ExceptionReportSerializer(VERSION_100); exceptionAdapter.serializeExceptionToXML(writer, state.getFailedException()); writer.writeEndElement(); break; } writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportProcessOutputs(XMLStreamWriter writer, ProcessletOutputs outputs, List<RequestedOutput> requestedOutputs) throws XMLStreamException { LOG.debug("Exporting process outputs"); // "wps:ProcessOutputs" element writer.writeStartElement(WPS_NS, "ProcessOutputs"); for (RequestedOutput requestedOutput : requestedOutputs) { LOG.debug("- exporting " + requestedOutput.getIdentifier()); ProcessletOutput output = outputs.getParameter(requestedOutput.getIdentifier()); exportOutput(writer, (ProcessletOutputImpl) output, requestedOutput); }/*from w w w .java 2 s .c o m*/ writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportOutput(XMLStreamWriter writer, ProcessletOutputImpl output, RequestedOutput requestedOutput) throws XMLStreamException { // "wps:Output" element writer.writeStartElement(WPS_NS, "Output"); ProcessletOutputDefinition outputType = output.getDefinition(); // "ows:Identifier" (minOccurs="1", maxOccurs="1") writer.writeStartElement(OWS_NS, "Identifier"); if (outputType.getIdentifier().getCodeSpace() != null) { writer.writeAttribute("codeSpace", outputType.getIdentifier().getCodeSpace()); }// w w w . j a v a 2s .c o m writer.writeCharacters(outputType.getIdentifier().getValue()); writer.writeEndElement(); // "ows:Title" (minOccurs="1", maxOccurs="1") if (outputType.getTitle() != null) { writer.writeStartElement(OWS_NS, "Title"); if (outputType.getTitle().getLang() != null) { writer.writeAttribute("xml:lang", outputType.getTitle().getLang()); } writer.writeCharacters(outputType.getTitle().getValue()); writer.writeEndElement(); } // "ows:Abstract" (minOccurs="0", maxOccurs="1") if (outputType.getAbstract() != null) { writer.writeStartElement(OWS_NS, "Abstract"); if (outputType.getAbstract().getLang() != null) { writer.writeAttribute("xml:lang", outputType.getAbstract().getLang()); } writer.writeCharacters(outputType.getAbstract().getValue()); writer.writeEndElement(); } // "ows:Metadata" (minOccurs="0", maxOccurs="unbounded") if (outputType.getMetadata() != null) { for (ProcessletOutputDefinition.Metadata metadata : outputType.getMetadata()) { writer.writeStartElement(OWS_NS, "Metadata"); if (metadata.getAbout() != null) { writer.writeAttribute("about", metadata.getAbout()); } if (metadata.getHref() != null) { writer.writeAttribute(XLN_NS, "href", metadata.getHref()); } writer.writeEndElement(); } } // choice: "wps:Reference" or "wps:Data" (minOccurs="1", maxOccurs="1") // (ignore asReference for Literal or BoundingBoxOutput) if (!requestedOutput.getAsReference() || output instanceof BoundingBoxOutputImpl || output instanceof LiteralOutputImpl) { writer.writeStartElement(WPS_NS, "Data"); if (output instanceof BoundingBoxOutputImpl) { exportBoundingBoxOutput(writer, (BoundingBoxOutputImpl) output); } else if (output instanceof LiteralOutputImpl) { exportLiteralOutput(writer, (LiteralOutputImpl) output); } else if (output instanceof ComplexOutputImpl) { exportComplexOutput(writer, (ComplexOutputImpl) output); } writer.writeEndElement(); } else { writer.writeStartElement(WPS_NS, "Reference"); String href = null; String mimeType = null; if (output instanceof ComplexOutputImpl) { ComplexOutputImpl complexOutput = (ComplexOutputImpl) output; href = complexOutput.getWebURL(); mimeType = complexOutput.getRequestedMimeType(); } if (mimeType == null) { LOG.warn("No mime type info available -> text/xml"); mimeType = "text/xml"; } writer.writeAttribute("href", "" + href); writer.writeAttribute("mimeType", mimeType); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportBoundingBoxOutput(XMLStreamWriter writer, BoundingBoxOutputImpl output) throws XMLStreamException { // "wps:BoundingBoxData" element writer.writeStartElement(WPS_NS, "BoundingBoxData"); OWSCommonXMLAdapter.exportBoundingBoxType(writer, output.getValue()); writer.writeEndElement();//from w w w. ja va 2s.c om }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportLiteralOutput(XMLStreamWriter writer, LiteralOutputImpl output) throws XMLStreamException { // "wps:LiteralData" element writer.writeStartElement(WPS_NS, "LiteralData"); // "dataType" attribute (optional) if (output.getDataType() != null) { writer.writeAttribute("dataType", output.getDataType()); }// w w w . ja v a2 s . com // "uom" attribute (optional) if (output.getRequestedUOM() != null) { writer.writeAttribute("uom", output.getRequestedUOM()); } writer.writeCharacters(output.getValue()); writer.writeEndElement(); }
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportXMLOutput(XMLStreamWriter writer, ComplexOutputImpl output) throws XMLStreamException { // "wps:ComplexData" element writer.writeStartElement(WPS_NS, "ComplexData"); String mimeType = output.getRequestedMimeType(); if (mimeType != null) { writer.writeAttribute("mimeType", mimeType); }//from ww w . ja v a 2 s . c o m String schema = output.getRequestedSchema(); if (schema != null) { writer.writeAttribute("schema", schema); } // NOTE: Providing the encoding attribute doesn't make any sense for inline XML output (always defined by the // surrounding document) XMLStreamReader reader = output.getStreamReader(); // skip start document event // apadberg: the following line was necessary when Axiom 1.2.8 is used, // it is commented out because of revised behavior in Axiom 1.2.9 if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) { reader.next(); } if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { XMLAdapter.writeElement(writer, reader); } else { LOG.warn("No element in XMLOutput found, skipping it in response document."); } writer.writeEndElement(); }