List of usage examples for org.jdom2 Namespace XML_NAMESPACE
Namespace XML_NAMESPACE
To view the source code for org.jdom2 Namespace XML_NAMESPACE.
Click Source Link
Namespace
for the standard xml prefix. From source file:org.mycore.restapi.v1.MCRRestAPIClassifications.java
License:Open Source License
/** * output children in JSON format used as input for Dijit Checkbox Tree * * @param eParent - the parent xml element * @param writer - the JSON writer//from www. jav a 2s.co m * @param lang - the language to be filtered or null if all languages should be displayed * * @throws IOException */ private static void writeChildrenAsJSONCBTree(Element eParent, JsonWriter writer, String lang, boolean checked) throws IOException { writer.beginArray(); for (Element e : eParent.getChildren("category")) { writer.beginObject(); writer.name("ID").value(e.getAttributeValue("ID")); for (Element eLabel : e.getChildren("label")) { if (lang == null || lang.equals(eLabel.getAttributeValue("lang", Namespace.XML_NAMESPACE))) { writer.name("text").value(eLabel.getAttributeValue("text")); } } writer.name("checked").value(checked); if (e.getChildren("category").size() > 0) { writer.name("children"); writeChildrenAsJSONCBTree(e, writer, lang, checked); } writer.endObject(); } writer.endArray(); }
From source file:org.mycore.restapi.v1.MCRRestAPIClassifications.java
License:Open Source License
/** * output children in JSON format used as input for a jsTree * * @param eParent - the parent xml element * @param writer - the JSON writer/*from w w w . j a v a2 s .c om*/ * @param lang - the language to be filtered or null if all languages should be displayed * @param opened - true, if all leaf nodes should be displayed * @param disabled - true, if all nodes should be disabled * @param selected - true, if all node should be selected * * @throws IOException */ private static void writeChildrenAsJSONJSTree(Element eParent, JsonWriter writer, String lang, boolean opened, boolean disabled, boolean selected) throws IOException { writer.beginArray(); for (Element e : eParent.getChildren("category")) { writer.beginObject(); writer.name("id").value(e.getAttributeValue("ID")); for (Element eLabel : e.getChildren("label")) { if (lang == null || lang.equals(eLabel.getAttributeValue("lang", Namespace.XML_NAMESPACE))) { writer.name("text").value(eLabel.getAttributeValue("text")); } } if (opened || disabled || selected) { writer.name("state"); writer.beginObject(); if (opened) { writer.name("opened").value(true); } if (disabled) { writer.name("disabled").value(true); } if (selected) { writer.name("selected").value(true); } writer.endObject(); } if (e.getChildren("category").size() > 0) { writer.name("children"); writeChildrenAsJSONJSTree(e, writer, lang, opened, disabled, selected); } writer.endObject(); } writer.endArray(); }
From source file:org.mycore.user2.MCRRealmFactory.java
License:Open Source License
/** * /* w ww . j a v a2 s.co m*/ */ private static void loadRealms() { Element root; try { root = getRealms().getRootElement(); } catch (SAXException | JDOMException | TransformerException | IOException e) { throw new MCRException("Could not load realms from URI: " + realmsURI); } String localRealmID = root.getAttributeValue("local"); /** Map of defined realms, key is the ID of the realm */ HashMap<String, MCRRealm> realmsMap = new HashMap<String, MCRRealm>(); HashMap<String, MCRUserAttributeMapper> attributeMapper = new HashMap<String, MCRUserAttributeMapper>(); /** List of defined realms */ List<MCRRealm> realmsList = new ArrayList<MCRRealm>(); List<Element> realms = (List<Element>) (root.getChildren("realm")); for (Element child : realms) { String id = child.getAttributeValue("id"); MCRRealm realm = new MCRRealm(id); List<Element> labels = (List<Element>) (child.getChildren("label")); for (Element label : labels) { String text = label.getTextTrim(); String lang = label.getAttributeValue("lang", Namespace.XML_NAMESPACE); realm.setLabel(lang, text); } realm.setPasswordChangeURL(child.getChildTextTrim("passwordChangeURL")); Element login = child.getChild("login"); if (login != null) { realm.setLoginURL(login.getAttributeValue("url")); realm.setRedirectParameter(login.getAttributeValue("redirectParameter")); realm.setRealmParameter(login.getAttributeValue("realmParameter")); } Element createElement = child.getChild("create"); if (createElement != null) { realm.setCreateURL(createElement.getAttributeValue("url")); } attributeMapper.put(id, MCRUserAttributeMapper.instance(child)); realmsMap.put(id, realm); realmsList.add(realm); if (localRealmID.equals(id)) { localRealm = realm; } } MCRRealmFactory.realmsDocument = root.getDocument(); MCRRealmFactory.realmsMap = realmsMap; MCRRealmFactory.realmsList = realmsList; MCRRealmFactory.attributeMapper = attributeMapper; }
From source file:org.olanto.myterm.export.GenerateEntries.java
License:Open Source License
public static void addLangset(Element termentry, Concepts con) { Query query = TermDB.em.createNamedQuery("Langsets.findByIdConcept"); query.setParameter("idConcept", con.getIdConcept()); List<Langsets> listOfLangsets = query.getResultList(); for (Langsets lan : listOfLangsets) { Element langset = makeElem("langSet").setAttribute("lang", lan.getIdLanguage(), Namespace.XML_NAMESPACE); addLangsetElem(langset, lan);/*from ww w .j a v a2 s . c o m*/ termentry.addContent(langset); addTerm(langset, lan); } }
From source file:org.olanto.myterm.export.JdomUtilities.java
License:Open Source License
/** * initialise la racine du XML//from ww w .jav a 2 s .c o m * * @param element de la racine * @param nameSpace de la racine * @param url du nameSpace */ public static void initRoot(String element) { Element elementAjoute = new Element(element); racine = elementAjoute; // dtd dependent racine.setAttribute("type", "TBX-Basic"); racine.setAttribute("lang", "en-US", Namespace.XML_NAMESPACE); }
From source file:org.opengroup.archimate.xmlexchange.XMLModelExporter.java
License:Open Source License
private void writeElementTextWithLanguageCode(Element element, String text) { element.setText(text);/*from w w w. jav a2 s .c o m*/ if (fLanguageCode != null) { element.setAttribute(ATTRIBUTE_LANG, fLanguageCode, Namespace.XML_NAMESPACE); } }
From source file:org.opengroup.archimate.xmlexchange.XMLModelImporter.java
License:Open Source License
String getChildElementText(Element parentElement, String childElementName, boolean normalise) { //Check for localised element according to the system's locale String code = Locale.getDefault().getLanguage(); if (code == null) { code = "en"; }/* w ww . java 2 s . c o m*/ for (Element childElement : parentElement.getChildren(childElementName, OPEN_GROUP_NAMESPACE)) { String lang = childElement.getAttributeValue(ATTRIBUTE_LANG, Namespace.XML_NAMESPACE); if (code.equals(lang)) { return normalise ? childElement.getTextNormalize() : childElement.getText(); } } // Default to first element found Element element = parentElement.getChild(childElementName, OPEN_GROUP_NAMESPACE); return element == null ? null : normalise ? element.getTextNormalize() : element.getText(); }
From source file:org.rometools.feed.module.opensearch.impl.OpenSearchModuleParser.java
License:Apache License
/** Use xml:base attributes at feed and entry level to resolve relative links */ private static String resolveURI(URL baseURI, Parent parent, String url) { url = (url.equals(".") || url.equals("./")) ? "" : url; if (isRelativeURI(url) && parent != null && parent instanceof Element) { Attribute baseAtt = ((Element) parent).getAttribute("base", Namespace.XML_NAMESPACE); String xmlBase = (baseAtt == null) ? "" : baseAtt.getValue(); if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) { xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/") + 1); }// w w w . j a va 2s . c o m return resolveURI(baseURI, parent.getParent(), xmlBase + url); } else if (isRelativeURI(url) && parent == null) { return baseURI + url; } else if (baseURI != null && url.startsWith("/")) { String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost(); if (baseURI.getPort() != baseURI.getDefaultPort()) { hostURI = hostURI + ":" + baseURI.getPort(); } return hostURI + url; } return url; }
From source file:org.rometools.feed.module.sle.types.DateValue.java
License:Apache License
public void setNamespace(Namespace namespace) { this.namespace = namespace == null ? Namespace.XML_NAMESPACE : namespace; }
From source file:org.rometools.feed.module.sle.types.Group.java
License:Apache License
/** * Creates a new instance of Group/* www . j a v a2 s . c o m*/ * @param namespace Namespace of the element * @param element Name of the element * @param label Label for the grouping. */ public Group(Namespace namespace, String element, String label) { this.namespace = namespace == null ? Namespace.XML_NAMESPACE : namespace; this.element = element; this.label = label; }