List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException;
From source file:org.apache.flex.compiler.config.Configuration.java
/** * Write a map of values to rdf/xml/*from w w w .j a v a 2s. c om*/ * * @param writer * @param namespaceURI * @param localName * @param mapData * @throws XMLStreamException */ private void writeMap(XMLStreamWriter writer, String namespaceURI, String localName, Map<String, String> mapData) throws XMLStreamException { if (mapData.size() > 0) { writer.writeStartElement(namespaceURI, localName); if ((mapData.size() == 1) && (mapData.get("x-default") != null)) { String data = mapData.get("x-default"); writer.writeCharacters(data); } else { writer.writeStartElement(RDF_URI, "Alt"); for (final String key : mapData.keySet()) { final String value = mapData.get(key); writer.writeStartElement(RDF_URI, "li"); writer.writeAttribute("xml", "", "lang", key); writer.writeCharacters(value); writer.writeEndElement(); } writer.writeEndElement(); } writer.writeEndElement(); } }
From source file:org.apache.flex.compiler.config.Configuration.java
/** * Write a collection values to rdf/xml. * /* w ww.ja va 2 s . com*/ * @param writer * @param namespaceURI * @param localName * @param values * @throws XMLStreamException */ private void writeCollection(XMLStreamWriter writer, String namespaceURI, String localName, Collection<String> values) throws XMLStreamException { if (values.isEmpty()) return; writer.writeStartElement(namespaceURI, localName); if (values.size() > 1) writer.writeStartElement(RDF_URI, "Bag"); for (String value : values) { writer.writeCharacters(value); } if (values.size() > 1) writer.writeEndElement(); writer.writeEndElement(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void inlineEntityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException { writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_ENTRY_REF); writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString()); writer.writeEndElement();//from www . j a va2s . c o m }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet) throws XMLStreamException, EdmPrimitiveTypeException { if (entitySet.getBaseURI() != null) { writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString()); }//from ww w . j a v a 2s. c om if (entitySet.getCount() != null) { writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_COUNT); writer.writeCharacters(Integer.toString(entitySet.getCount())); writer.writeEndElement(); } if (entitySet.getId() != null) { writer.writeStartElement(Constants.ATOM_ELEM_ID); writer.writeCharacters(entitySet.getId().toASCIIString()); writer.writeEndElement(); } common(writer, entitySet); for (Entity entity : entitySet) { if (entity.getType() == null && entity.getProperties().isEmpty()) { entityRef(writer, entity); } else { writer.writeStartElement(Constants.ATOM_ELEM_ENTRY); entity(writer, entity); writer.writeEndElement(); } } if (serverMode) { if (entitySet.getNext() != null) { final Link next = new Link(); next.setRel(Constants.NEXT_LINK_REL); next.setHref(entitySet.getNext().toASCIIString()); links(writer, Collections.<Link>singletonList(next)); } if (entitySet.getDeltaLink() != null) { final Link next = new Link(); next.setRel(Constants.NS_DELTA_LINK_REL); next.setHref(entitySet.getDeltaLink().toASCIIString()); links(writer, Collections.<Link>singletonList(next)); } } }
From source file:org.apache.olingo.commons.core.data.AtomSerializer.java
private void feed(final XMLStreamWriter writer, final Feed feed) throws XMLStreamException { if (feed.getBaseURI() != null) { writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, feed.getBaseURI().toASCIIString()); }//from w w w . j av a 2s .c om if (feed.getCount() != null) { writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATOM_ELEM_COUNT); writer.writeCharacters(Integer.toString(feed.getCount())); writer.writeEndElement(); } if (StringUtils.isNotBlank(feed.getId())) { writer.writeStartElement(Constants.ATOM_ELEM_ID); writer.writeCharacters(feed.getId()); writer.writeEndElement(); } if (feed instanceof AbstractAtomObject) { common(writer, (AbstractAtomObject) feed); } for (Entry entry : feed.getEntries()) { writer.writeStartElement(Constants.ATOM_ELEM_ENTRY); entry(writer, entry); writer.writeEndElement(); } if (feed.getNext() != null) { final LinkImpl next = new LinkImpl(); next.setRel(Constants.NEXT_LINK_REL); next.setHref(feed.getNext().toASCIIString()); links(writer, Collections.<Link>singletonList(next)); } }
From source file:org.apache.olingo.commons.core.serialization.AtomSerializer.java
private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet) throws XMLStreamException, EdmPrimitiveTypeException { if (entitySet.getBaseURI() != null) { writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString()); }/*from w ww .j a v a 2 s . c om*/ if (entitySet.getCount() != null) { writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_COUNT); writer.writeCharacters(Integer.toString(entitySet.getCount())); writer.writeEndElement(); } if (entitySet.getId() != null) { writer.writeStartElement(Constants.ATOM_ELEM_ID); writer.writeCharacters(entitySet.getId().toASCIIString()); writer.writeEndElement(); } if (entitySet instanceof AbstractODataObject) { common(writer, (AbstractODataObject) entitySet); } for (Entity entity : entitySet.getEntities()) { if (entity.getType() == null && entity.getProperties().isEmpty()) { entityRef(writer, entity); writer.writeEndElement(); } else { writer.writeStartElement(Constants.ATOM_ELEM_ENTRY); entity(writer, entity); writer.writeEndElement(); } } if (serverMode) { if (entitySet.getNext() != null) { final LinkImpl next = new LinkImpl(); next.setRel(Constants.NEXT_LINK_REL); next.setHref(entitySet.getNext().toASCIIString()); links(writer, Collections.<Link>singletonList(next)); } if (entitySet.getDeltaLink() != null) { final LinkImpl next = new LinkImpl(); next.setRel(ODataServiceVersion.V40.getNamespace(NamespaceKey.DELTA_LINK_REL)); next.setHref(entitySet.getDeltaLink().toASCIIString()); links(writer, Collections.<Link>singletonList(next)); } } }
From source file:org.deegree.commons.xml.stax.FilteringXMLStreamWriterTest.java
private void writeDocument(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartDocument();/*www . j a v a 2 s . c o m*/ writer.setPrefix("app", app); writer.setPrefix("nix", nix); writer.setPrefix("alles", alles); writer.writeStartElement(app, "a"); writer.writeNamespace("app", app); writer.writeNamespace("nix", nix); writer.writeNamespace("alles", alles); writer.writeStartElement(app, "b"); writer.writeStartElement(nix, "c"); writer.writeStartElement(app, "d"); writer.writeEndElement(); writer.writeStartElement(alles, "e"); writer.writeCharacters("sometext"); writer.writeEndElement(); writer.writeStartElement(app, "b"); writer.writeStartElement(nix, "c"); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.close(); }
From source file:org.deegree.services.csw.exporthandling.EbrimGetCapabilitiesHandler.java
protected void exportOperationsMetadata(XMLStreamWriter writer, String get, String post, String owsNS) throws XMLStreamException { writer.writeStartElement(owsNS, "OperationsMetadata"); for (String name : supportedOperations) { if (!name.equals(CSWRequestType.GetRepositoryItem.name())) { writer.writeStartElement(owsNS, "Operation"); writer.writeAttribute("name", name); exportDCP(writer, get, post, owsNS); if (name.equals(CSWRequestType.GetCapabilities.name())) { writeParam(owsNS, "AcceptVersions", "2.0.2", "1.0.0"); gcHelper.writeGetCapabilitiesParameters(writer, owsNS); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.DescribeRecord.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeDescribeRecordParameters(writer, owsNS, null, outputFormats, schemaLang); writeParam(owsNS, "typeNames", "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject"); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.GetRecords.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeGetRecordsParameters(writer, owsNS, new String[] { "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject" }, outputFormats, new String[] { "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" }, null); writeParam(owsNS, "CONSTRAINTLANGUAGE", "FILTER"); writeParam(owsNS, "ElementSetName", "brief", "summary", "full"); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.GetRecordById.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeGetRecordByIdParameters(writer, owsNS, outputFormats, new String[] { EbrimProfile.RIM_NS }); writeParam(owsNS, "TypeName", "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject"); writer.writeEndElement();// Operation // } else if ( name.equals( CSWebRIMRequestType.GetRepositoryItem.name() ) ) { // writeParam( owsNS, "version", "2.0.2", "1.0.0" ); // writer.writeEndElement();// Operation }/*w w w. j a va 2 s . c o m*/ } } writeParam(owsNS, "service", EbrimProfile.SERVICENAME_CSW, EbrimProfile.SERVICENAME_CSW_EBRIM, EbrimProfile.SERVICENAME_WRS); // if XML and/or SOAP is supported writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "PostEncoding"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("XML"); writer.writeEndElement();// Value writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("SOAP"); writer.writeEndElement();// Value writer.writeEndElement();// Constraint writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "srsName"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("urn:ogc:def:crs:EPSG:4326"); writer.writeEndElement();// Value writer.writeStartElement(owsNS, "Metadata"); writer.writeAttribute(CommonNamespaces.XLNNS, "type", "simple"); writer.writeAttribute(CommonNamespaces.XLNNS, "title", "EPSG geodetic parameters"); writer.writeAttribute(CommonNamespaces.XLNNS, "href", "http://www.epsg-registry.org/"); writer.writeEndElement();// Metadata writer.writeEndElement();// Constraint if (extendedCapabilities != null) { InputStream extCapabilites = null; try { extCapabilites = extendedCapabilities.openStream(); gcHelper.exportExtendedCapabilities(writer, owsNS, extCapabilites, null); } catch (IOException e) { LOG.warn("Could not open stream for extended capabilities. Ignore it!"); } finally { IOUtils.closeQuietly(extCapabilites); } } writer.writeEndElement();// OperationsMetadata }
From source file:org.deegree.services.csw.exporthandling.GetCapabilitiesHandler.java
private void exportOperationsMetadata(XMLStreamWriter writer, String get, String post, String owsNS) throws XMLStreamException { writer.writeStartElement(owsNS, "OperationsMetadata"); if (isTransactionEnabled && !supportedOperations.contains(CSWRequestType.Transaction.name())) { supportedOperations.add(CSWRequestType.Transaction.name()); }/*from w w w . j av a 2s. c om*/ for (String name : supportedOperations) { writer.writeStartElement(owsNS, "Operation"); writer.writeAttribute("name", name); exportDCP(writer, get, post, owsNS); if (name.equals(GetCapabilities.name())) { gcHelper.writeGetCapabilitiesParameters(writer, owsNS); } else if (name.equals(DescribeRecord.name())) { gcHelper.writeDescribeRecordParameters(writer, owsNS, typeNames, schemaOutputFormats, "XMLSCHEMA"); } else if (name.equals(GetRecords.name())) { gcHelper.writeGetRecordsParameters(writer, owsNS, typeNames, dataOutputFormats, outputSchemas, elementSetNames); writeGetRecordsConstraints(writer, owsNS); } else if (name.equals(GetRecordById.name())) { gcHelper.writeGetRecordByIdParameters(writer, owsNS, dataOutputFormats, outputSchemas); } writer.writeEndElement();// Operation } // if xPathQueryables are allowed than this should be set // writer.writeStartElement( owsNS, "Constraint" ); // writer.writeAttribute( "name", "XPathQueryables" ); // // writer.writeStartElement( owsNS, "Value" ); // writer.writeCharacters( "allowed" ); // writer.writeEndElement();// Value // // writer.writeEndElement();// Constraint writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "IsoProfiles"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters(CSWConstants.GMD_NS); writer.writeEndElement();// Value writer.writeEndElement();// Constraint // if XML and/or SOAP is supported writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "PostEncoding"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("XML"); writer.writeEndElement();// Value writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("SOAP"); writer.writeEndElement();// Value writer.writeEndElement();// Constraint InputStream extCapabilites = null; if (extendedCapabilities != null) { try { extCapabilites = extendedCapabilities.openStream(); } catch (IOException e) { LOG.warn("Could not open stream for extended capabilities. Ignore it!"); } } // additional inspire queryables if (this.isEnabledInspireExtension && extCapabilites == null) { extCapabilites = GetCapabilitiesHandler.class.getResourceAsStream("extendedCapInspire.xml"); } gcHelper.exportExtendedCapabilities(writer, owsNS, extCapabilites, varToValue); if (extCapabilites != null) { IOUtils.closeQuietly(extCapabilites); } writer.writeEndElement();// OperationsMetadata }
From source file:org.deegree.services.csw.exporthandling.GetCapabilitiesHandler.java
private void writeGetRecordsConstraints(XMLStreamWriter writer, String owsNS) throws XMLStreamException { writer.writeStartElement(owsNS, "Parameter"); writer.writeAttribute("name", "CONSTRAINTLANGUAGE"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("Filter"); writer.writeEndElement();// Value writer.writeEndElement();// Parameter writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "SupportedISOQueryables"); for (String s : isoQueryables) { writer.writeStartElement(owsNS, "Value"); writer.writeCharacters(s);/* w w w .ja va 2s . com*/ writer.writeEndElement();// Value } writer.writeEndElement();// Constraint writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "AdditionalQueryables"); for (String val : additionalQueryables) { writeElement(writer, owsNS, "Value", val); } writer.writeEndElement();// Constraint }