Search in sources :

Example 71 with Attribute

use of org.dom4j.Attribute in project pentaho-platform by pentaho.

the class BiPlatformRepositoryClientNavigationService method getLocalizedName.

private String getLocalizedName(Element element) {
    // $NON-NLS-1$
    String name = "";
    // $NON-NLS-1$
    Attribute attr = element.attribute("localized-name");
    if (attr != null) {
        name = attr.getText();
    }
    return name;
}
Also used : Attribute(org.dom4j.Attribute) PropertyString(org.pentaho.commons.util.repository.type.PropertyString)

Example 72 with Attribute

use of org.dom4j.Attribute in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method addAttributeToCategoryElem.

private void addAttributeToCategoryElem(TreeParent category, String attrName, String defaultAttrValue) {
    Element elem = locateCategoryElement(category);
    Attribute attr = elem.attribute(attrName);
    if (attr != null) {
        elem.remove(attr);
    }
    elem.addAttribute(attrName, defaultAttrValue);
}
Also used : Attribute(org.dom4j.Attribute) Element(org.dom4j.Element)

Example 73 with Attribute

use of org.dom4j.Attribute in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method doUpgrade.

private void doUpgrade(String url) {
    Document doc = credentials.get(url).doc;
    String path = // $NON-NLS-1$//$NON-NLS-2$
    "//child::*[text() = '" + TreeObject.CATEGORY_FOLDER + "' and count(@Universe) = 0 and count(@Url) = 0" + // $NON-NLS-1$
    "]";
    List<Element> categorys = doc.selectNodes(path);
    for (Element elem : categorys) {
        Attribute attr = elem.attribute(URL);
        if (attr == null) {
            elem.addAttribute(URL, UnifyUrl(url));
        }
    }
    saveDocument(url);
}
Also used : Attribute(org.dom4j.Attribute) Element(org.dom4j.Element) Document(org.dom4j.Document)

Example 74 with Attribute

use of org.dom4j.Attribute in project free-framework by a601942905git.

the class Config method initTableConf.

/**
 * 初始化配置的表格信息
 * @param e
 * @return
 */
private static TableConf initTableConf(Element e) {
    TableConf table = new TableConf();
    // 表对应的实体类名称
    Attribute attr = XmlUtil.getAttribute(e, "entityName");
    if (attr != null) {
        table.setEntityName(attr.getValue());
    }
    // 表名称
    Attribute name = XmlUtil.getAttribute(e, "name");
    if (name != null) {
        table.setName(name.getValue());
    }
    // 表前缀
    Attribute prefix = XmlUtil.getAttribute(e, "prefix");
    if (prefix != null) {
        table.setPrefix(prefix.getValue());
    }
    // 如果是主从表,则从表需设置该属性,表示父表的关联属性
    Attribute parentField = XmlUtil.getAttribute(e, "parentField");
    if (parentField != null) {
        table.setParentField(parentField.getValue());
    }
    // 表关联类型,分为OneToOne,OneToMany
    Attribute refType = XmlUtil.getAttribute(e, "refType");
    if (refType != null) {
        table.setRefType(refType.getValue());
    } else {
        // 默认OneToMany
        table.setRefType("OneToMany");
    }
    return table;
}
Also used : TableConf(com.free.framework.code.tools.model.TableConf) Attribute(org.dom4j.Attribute)

Example 75 with Attribute

use of org.dom4j.Attribute in project OpenOLAT by OpenOLAT.

the class TextMarkerManagerImpl method loadTextMarkerList.

/**
 * @see org.olat.core.gui.control.generic.textmarker.TextMarkerManager#loadTextMarkerList(org.olat.core.util.vfs.VFSLeaf)
 */
public List<TextMarker> loadTextMarkerList(VFSLeaf textMarkerFile) {
    if (textMarkerFile == null) {
        // filename not defined at all
        return new ArrayList<TextMarker>();
    }
    XMLParser parser = new XMLParser();
    InputStream stream = textMarkerFile.getInputStream();
    if (stream == null) {
        // e.g. file was removed
        return new ArrayList<TextMarker>();
    }
    Document doc = parser.parse(stream, false);
    Element root = doc.getRootElement();
    if (root == null) {
        // file was empty;
        return new ArrayList<TextMarker>();
    }
    // Do version check. Not needed now, for future lazy migration code...
    Attribute versionAttribute = root.attribute(XML_VERSION_ATTRIBUTE);
    int version = (versionAttribute == null ? 1 : Integer.parseInt(versionAttribute.getStringValue()));
    if (version != VERSION) {
        // complain about version conflict or solve it
        throw new OLATRuntimeException("Could not load glossary entries due to version conflict. Loaded version was::" + version, null);
    }
    // parse text marker objects and put them into a list
    List markersElements = root.elements("textMarker");
    List<TextMarker> markers = new ArrayList<TextMarker>();
    Iterator iter = markersElements.iterator();
    while (iter.hasNext()) {
        Element textMarkerElement = (Element) iter.next();
        TextMarker textMarker = new TextMarker(textMarkerElement);
        markers.add(textMarker);
    }
    try {
        stream.close();
    } catch (IOException e) {
        throw new OLATRuntimeException(this.getClass(), "Error while closing text marker file stream", e);
    }
    return markers;
}
Also used : Attribute(org.dom4j.Attribute) InputStream(java.io.InputStream) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.dom4j.Document) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XMLParser(org.olat.core.util.xml.XMLParser)

Aggregations

Attribute (org.dom4j.Attribute)114 Element (org.dom4j.Element)88 Document (org.dom4j.Document)30 ArrayList (java.util.ArrayList)28 List (java.util.List)26 Iterator (java.util.Iterator)23 Node (org.dom4j.Node)14 HashMap (java.util.HashMap)12 File (java.io.File)11 SAXReader (org.dom4j.io.SAXReader)11 IOException (java.io.IOException)10 Map (java.util.Map)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)6 Namespace (org.dom4j.Namespace)5 QName (org.dom4j.QName)5 PropertyString (org.pentaho.commons.util.repository.type.PropertyString)5 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)4 AnnotatedElement (java.lang.reflect.AnnotatedElement)3