List of usage examples for org.jdom2 Namespace NO_NAMESPACE
Namespace NO_NAMESPACE
To view the source code for org.jdom2 Namespace NO_NAMESPACE.
Click Source Link
Namespace
for when not in a namespace From source file:ca.nrc.cadc.reg.CapabilitiesReader.java
License:Open Source License
private Capabilities buildCapabilities(final Element root) { Capabilities caps = new Capabilities(); List<Element> capElementList = root.getChildren("capability", Namespace.NO_NAMESPACE); for (Element capElement : capElementList) { Capability cap = this.buildCapability(capElement); caps.getCapabilities().add(cap); }/*from w w w .j a va 2 s. co m*/ return caps; }
From source file:ca.nrc.cadc.vosi.TableSet.java
License:Open Source License
/** * @param ts//from ww w . j a v a2 s . co m * @return */ private Element toXmlElement(TapSchema ts) { if (ts.getSchemaDescs().isEmpty()) throw new IllegalArgumentException("Error: at least one schema is required."); Element eleTableset = new Element("tableset", vosi); for (SchemaDesc sd : ts.getSchemaDescs()) { eleTableset.addContent(toXmlElement(sd, Namespace.NO_NAMESPACE)); } return eleTableset; }
From source file:ca.nrc.cadc.vosi.TableSet.java
License:Open Source License
/** * @param sd/*from w ww. j a va 2 s .c om*/ * @return */ private Element toXmlElement(SchemaDesc sd, Namespace ns) { Element eleSchema = new Element("schema", ns); Element ele; ele = new Element("name"); if (sd.getSchemaName() == null) ele.setText(DEFAULT_SCHEMA); else ele.setText(sd.getSchemaName()); eleSchema.addContent(ele); if (sd.getTableDescs() != null) for (TableDesc td : sd.getTableDescs()) { eleSchema.addContent(toXmlElement(td, Namespace.NO_NAMESPACE)); } return eleSchema; }
From source file:com.c4om.autoconf.ulysses.extra.svrlinterpreter.SVRLInterpreterProcessor.java
License:Apache License
/** * This method:/* w ww . j a v a2s . co m*/ * <ol> * <li>Takes an attribute from a source element</li> * <li>Detaches it</li> * <li>Removes its namespace</li> * <li>Attaches it to a destination element</li> * </ol> * @param sourceElement source element * @param destinationElement destination element * @param attrName the name of the attribute * @param attrNamespace the namespace of the source attribute (it will be removed at destination) */ private static void moveAndRemoveNSOfAttr(Element sourceElement, Element destinationElement, String attrName, Namespace attrNamespace) { Attribute mandatoryPathAttribute = sourceElement.getAttribute(attrName, attrNamespace); if (mandatoryPathAttribute != null) { mandatoryPathAttribute.detach(); mandatoryPathAttribute.setNamespace(Namespace.NO_NAMESPACE); destinationElement.setAttribute(mandatoryPathAttribute); } }
From source file:com.c4om.utils.xmlutils.JDOMUtils.java
License:Apache License
/** * Given a {@link Collection} of {@link Namespace} objects, it returns the first one (as returned by its iterator) * whose prefix is equal to a given one * @param prefix the prefix whose namespace we are looking for. It may be null, to look for the null namespace. * @param namespaces the collection of namespace * @return the corresponding {@link Namespace} object if found, the null namespace (i.e. {@link Namespace#NO_NAMESPACE}) if prefix is null or "" (regardless of it belongs to the collection or not), null otherwise. *///w w w . j a v a2 s .c o m public static Namespace solveNamespaceForPrefix(String prefix, Collection<Namespace> namespaces) { Namespace namespace = null; if (prefix == null) { namespace = Namespace.NO_NAMESPACE; return namespace; } else { for (Namespace knownNS : namespaces) { if (knownNS.getPrefix().equals(prefix)) { namespace = knownNS; break; } } } if (prefix.equals("") && namespace == null) { namespace = Namespace.NO_NAMESPACE; } return namespace; }
From source file:com.cybernostics.jsp2thymeleaf.api.elements.AvailableNamespaces.java
public static Optional<Namespace> fromUri(String uri) { return Optional.of(namespaces.getOrDefault(uri, Namespace.NO_NAMESPACE)); }
From source file:com.kixeye.kixmpp.KixmppWebSocketCodec.java
License:Apache License
@Override protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { WebSocketFrame frame = null;//from www. j ava 2 s .com if (msg instanceof Element) { Element element = (Element) msg; if (element.getNamespace() == null || element.getNamespace() == Namespace.NO_NAMESPACE) { if ("stream".equals(element.getNamespacePrefix())) { element.setNamespace(Namespace.getNamespace("http://etherx.jabber.org/streams")); } else { element.setNamespace(Namespace.getNamespace("jabber:client")); IteratorIterable<Content> descendants = element.getDescendants(); while (descendants.hasNext()) { Content content = descendants.next(); if (content instanceof Element) { Element descendantElement = (Element) content; if (descendantElement.getNamespace() == null || descendantElement.getNamespace() == Namespace.NO_NAMESPACE) { descendantElement.setNamespace(element.getNamespace()); } } } } } ByteBuf binaryData = ctx.alloc().buffer(); new XMLOutputter().output((Element) msg, new ByteBufOutputStream(binaryData)); frame = new TextWebSocketFrame(binaryData); } else if (msg instanceof KixmppStreamStart) { KixmppStreamStart streamStart = (KixmppStreamStart) msg; StringWriter writer = new StringWriter(); if (streamStart.doesIncludeXmlHeader()) { writer.append("<?xml version='1.0' encoding='UTF-8'?>"); } writer.append("<stream:stream "); if (streamStart.getId() != null) { writer.append(String.format("id=\"%s\" ", streamStart.getId())); } if (streamStart.getFrom() != null) { writer.append(String.format("from=\"%s\" ", streamStart.getFrom().getFullJid())); } if (streamStart.getTo() != null) { writer.append(String.format("to=\"%s\" ", streamStart.getTo())); } writer.append( "version=\"1.0\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\">"); frame = new TextWebSocketFrame(writer.toString()); } else if (msg instanceof KixmppStreamEnd) { frame = new TextWebSocketFrame("</stream:stream>"); } else if (msg instanceof String) { frame = new TextWebSocketFrame((String) msg); } else if (msg instanceof ByteBuf) { frame = new TextWebSocketFrame((ByteBuf) msg); } if (frame != null) { if (logger.isDebugEnabled()) { logger.debug("Sending: [{}]", frame.content().toString(StandardCharsets.UTF_8)); } out.add(frame); } }
From source file:com.rometools.rome.io.impl.Atom03Parser.java
License:Open Source License
private Content parseContent(final Element e) { String value = null;//from ww w . j av a2 s . co m String type = getAttributeValue(e, "type"); if (type == null) { type = "text/plain"; } String mode = getAttributeValue(e, "mode"); if (mode == null) { mode = Content.XML; // default to xml content } if (mode.equals(Content.ESCAPED)) { // do nothing XML Parser took care of this value = e.getText(); } else if (mode.equals(Content.BASE64)) { value = Base64.decode(e.getText()); } else if (mode.equals(Content.XML)) { final XMLOutputter outputter = new XMLOutputter(); final List<org.jdom2.Content> contents = e.getContent(); for (final org.jdom2.Content content : contents) { if (content instanceof Element) { final Element element = (Element) content; if (element.getNamespace().equals(getAtomNamespace())) { element.setNamespace(Namespace.NO_NAMESPACE); } } } value = outputter.outputString(contents); } final Content content = new Content(); content.setType(type); content.setMode(mode); content.setValue(value); return content; }
From source file:com.rometools.rome.io.impl.Atom10Parser.java
License:Open Source License
private String parseTextConstructToString(final Element e) { String type = getAttributeValue(e, "type"); if (type == null) { type = Content.TEXT;// ww w. jav a 2 s. c o m } String value = null; if (type.equals(Content.XHTML) || type.indexOf("/xml") != -1 || type.indexOf("+xml") != -1) { // XHTML content needs special handling final XMLOutputter outputter = new XMLOutputter(); final List<org.jdom2.Content> contents = e.getContent(); for (final org.jdom2.Content content : contents) { if (content instanceof Element) { final Element element = (Element) content; if (element.getNamespace().equals(getAtomNamespace())) { element.setNamespace(Namespace.NO_NAMESPACE); } } } value = outputter.outputString(contents); } else { // Everything else comes in verbatim value = e.getText(); } return value; }
From source file:com.rometools.rome.io.impl.RSS091UserlandGenerator.java
License:Open Source License
@Override protected Namespace getFeedNamespace() { return Namespace.NO_NAMESPACE; }