List of usage examples for org.jdom2 Namespace getPrefix
public String getPrefix()
Namespace
. From source file:org.cloudsimulator.xml.XmlUtility.java
License:Open Source License
public static Element createPositiveIntegerElement(final Namespace nameSpace, final Document documentParent, final String elementTagName, final int elementValue) { Element element = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":" + elementTagName); element.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":" + DATATYPE, "&xsd;positiveInteger"); element.appendChild(documentParent.createTextNode(String.valueOf(elementValue))); return element; }
From source file:org.cloudsimulator.xml.XmlUtility.java
License:Open Source License
public static Element createUnsignedShortElement(final Namespace nameSpace, final Document documentParent, final String elementTagName, final int elementValue) { Element element = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":" + elementTagName); element.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":" + DATATYPE, "&xsd;unsignedShort"); element.appendChild(documentParent.createTextNode(String.valueOf(elementValue))); return element; }
From source file:org.cloudsimulator.xml.XmlUtility.java
License:Open Source License
public static Element createDateTimeElement(final Namespace nameSpace, final Document documentParent, final String elementTagName, final String elementValue) { Element element = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":" + elementTagName); element.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":" + DATATYPE, "&xsd;dateTime"); element.appendChild(documentParent.createTextNode(String.valueOf(elementValue))); return element; }
From source file:org.cloudsimulator.xml.XmlUtility.java
License:Open Source License
public static Element createResourceElement(final Namespace nameSpace, final Document documentParent, final String elementTagName, final String elementResource) { Element element = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":" + elementTagName); element.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":resource", elementResource);/*from www . ja v a 2 s.c o m*/ return element; }
From source file:org.jahia.utils.osgi.parsers.AbstractXmlFileParser.java
License:Open Source License
public Set<String> getMissingQueryPrefixes(Element root, String xPathQuery) { Set<String> xPathQueryPrefixes = getPrefixesInXPath(xPathQuery); Set<String> elementPrefixes = new HashSet<String>(); for (Namespace additionalNamespaces : (List<Namespace>) root.getAdditionalNamespaces()) { elementPrefixes.add(additionalNamespaces.getPrefix()); }/*from w w w. j a va2 s. co m*/ elementPrefixes.add("beans"); Set<String> missingPrefixes = new TreeSet<String>(); for (String xPathQueryPrefix : xPathQueryPrefixes) { if (!elementPrefixes.contains(xPathQueryPrefix)) { missingPrefixes.add(xPathQueryPrefix); } } return missingPrefixes; }
From source file:org.jahia.utils.osgi.parsers.AbstractXmlFileParser.java
License:Open Source License
public void dumpElementNamespaces(Element element) { Namespace mainNamespace = element.getNamespace(); getLogger().debug("Main namespace prefix=[" + mainNamespace.getPrefix() + "] uri=[" + mainNamespace.getURI() + "] getNamespaceURI=[" + element.getNamespaceURI() + "]"); for (Namespace additionalNamespace : (List<Namespace>) element.getAdditionalNamespaces()) { getLogger().debug("Additional namespace prefix=" + additionalNamespace.getPrefix() + " uri=" + additionalNamespace.getURI()); }/*from w ww . jav a2s . c o m*/ }
From source file:org.mycore.common.MCRConstants.java
License:Open Source License
/** * Adds and registers a standard namespace with prefix. * Note that a default namespace without prefix will be ignored here! *///from www . j a v a 2 s . c o m public static void registerNamespace(Namespace namespace) { String prefix = namespace.getPrefix(); if ((prefix != null) && !prefix.isEmpty()) { namespacesByPrefix.put(prefix, namespace); } }
From source file:org.mycore.common.xml.MCRXPathBuilder.java
License:Open Source License
/** * Returns the namespace prefix for this element, followed by a ":", or the empty string if no namespace prefix known. *///from www. j a va2s .c om public static String getNamespacePrefix(Element element) { Namespace nsElement = element.getNamespace(); for (Namespace ns : MCRConstants.getStandardNamespaces()) if (ns.equals(nsElement)) return ns.getPrefix() + ":"; String prefix = nsElement.getPrefix(); if ((prefix != null) && !prefix.isEmpty()) return prefix + ":"; else return ""; }
From source file:org.mycore.frontend.editor.MCREditorSubmission.java
License:Open Source License
private String getNamespacePrefix(Namespace ns) { if (ns == null || ns.equals(Namespace.NO_NAMESPACE)) { return ""; }// w ww .j a va 2 s. c o m for (String key : nsMap.keySet()) { if (ns.equals(nsMap.get(key))) { return key + ":"; } } String msg = "Namespace " + ns.getURI() + " used in editor source input, but not declared in editor definition. Using: " + ns.getPrefix(); LOGGER.warn(msg); return ns.getPrefix() + ":"; }
From source file:org.mycore.frontend.editor.MCREditorSubmission.java
License:Open Source License
/** * Stores the list of additional namespaces declared in the components * element of the editor definition. These namespaces and its prefixes can * be used in editor variable paths (var attributes of cells). */// ww w . java2 s .c om @SuppressWarnings("unchecked") private void setAdditionalNamespaces(Element editor) { Element components = editor.getChild("components"); List<Namespace> namespaces = components.getAdditionalNamespaces(); for (Namespace ns : namespaces) { nsMap.put(ns.getPrefix(), ns); } nsMap.put("xml", Namespace.XML_NAMESPACE); for (Namespace ns : MCRConstants.getStandardNamespaces()) { setNamespaceIfUndefined(ns); } }