Java Code Examples for org.jdom2.Element#getNamespacePrefix()
The following examples show how to use
org.jdom2.Element#getNamespacePrefix() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersisterJdomUtil.java From n2o-framework with Apache License 2.0 | 5 votes |
public static void installPrefix(Element element, Element rootElement) { if (element == null) return; if (rootElement.getNamespace() == null) return; if (element.getNamespacePrefix() == null) return; if (element.getNamespace() == null) return; if (element.getNamespace().getURI().equals(rootElement.getNamespace().getURI())) return; if (element.getNamespace().getURI().isEmpty()) return; if (rootElement.getAdditionalNamespaces().contains(element.getNamespace())) return; Namespace additional = element.getNamespace(); rootElement.addNamespaceDeclaration(additional); }
Example 2
Source File: DataSchemaBuilder.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
/** * Clones a set of attributes. Needs to be done this way to (i) break the * parental attachment to the attribute; and (ii) to fix any errant namespace * prefixes * @param element the element with the attributes to clone * @param defNS the default namespace * @return the List of clone attributes */ private List<Attribute> cloneAttributes(Element element, Namespace defNS) { String prefix = element.getNamespacePrefix(); List<Attribute> cloned = new ArrayList<Attribute>(); for (Attribute attribute : element.getAttributes()) { String value = getAttributeValue(attribute, prefix, defNS); Attribute copy = new Attribute(attribute.getName(), value); cloned.add(copy); } return cloned; }
Example 3
Source File: ConvertXmlToJsonService.java From cs-actions with Apache License 2.0 | 5 votes |
@NotNull private String getElementFullName(final Element element) { final StringBuilder name = new StringBuilder(element.getNamespacePrefix()); if (!element.getNamespacePrefix().isEmpty()) name.append(PREFIX_DELIMITER); name.append(element.getName()); return name.toString(); }
Example 4
Source File: BaseWireFeedGenerator.java From rome with Apache License 2.0 | 5 votes |
private static void collectUsedPrefixes(final Element el, final Set<String> collector) { final String prefix = el.getNamespacePrefix(); if (prefix != null && prefix.length() > 0 && !collector.contains(prefix)) { collector.add(prefix); } final List<Element> kids = el.getChildren(); for (final Element kid : kids) { // recursion- worth it collectUsedPrefixes(kid, collector); } }