Java 类org.dom4j.Element 实例源码

项目:joai-project    文件:MdeComplexType.java   
/**
 *  Create "choose" controller for the case where an empty requiredMultiSelect
 *  node is closed. Called from renderComplexTypeConcrete, this controller
 *  provides a prompt for user when the required multiselect boxes are empty
 *  and not visible
 *
 * @return    The requiredMultiSelectControl value
 */
public Element getRequiredMultiSelectControl() {

    Element actionElement = df.createElement("span")
        .addAttribute("class", "action-button");

    // test to see if child node (the multiSelect) is empty
    Element isEmptyTest = actionElement.addElement("logic__equal")
        .addAttribute("name", formBeanName)
        .addAttribute("property", "nodeIsEmpty(" + xpath + ")")
        .addAttribute("value", "true");

    // test to see if the node is closed
    Element isOpenTest = isEmptyTest.addElement("c__if")
        .addAttribute("test", "${not " + formBeanName + ".collapseBean.isOpen}");

    //  "choose" controller link that toogles DisplayState of node
    Element chooseController = isOpenTest.addElement("a")
        .addAttribute("href", "javascript__toggleDisplayState(" + RendererHelper.jspQuotedString("${id}") + ")");
    chooseController.setText("choose");

    return actionElement;
}
项目:PackagePlugin    文件:FileUtil.java   
/**
 * 摸查项目输出目录
 * <p>
 * @param projectPath
 * @param kind        output 或 src
 * @return
 */
public static String readXML(String projectPath, String kind) {
    try {
        SAXReader saxReader = new SAXReader();
        File classpath = new File(projectPath + "/.classpath");
        if (classpath.exists()) {
            Document document = saxReader.read(classpath);
            List<Element> out = (List<Element>) document.selectNodes("/classpath/classpathentry[@kind='" + kind + "']");
            String tmp = "";
            for (Element out1 : out) {
                String combineaccessrules = out1.attributeValue("combineaccessrules");
                if ("false".equals(combineaccessrules) && "src".equals(kind)) {
                    continue;
                }
                tmp += out1.attributeValue("path") + ",";
            }
            return tmp.isEmpty() ? tmp : tmp.substring(0, tmp.length() - 1);
        }
    } catch (DocumentException ex) {
        MainFrame.LOGGER.log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
    }
    return "";
}
项目:bdf2    文件:ModelBuilder.java   
private Element buildValidatorElement(Validator validator){
    BaseElement element=new BaseElement("Validator");
    int pos=validator.getName().lastIndexOf("Validator");
    String validatorType=validator.getName().substring(0,pos);
    validatorType=validatorType.substring(0,1).toLowerCase()+validatorType.substring(1,validatorType.length());
    element.addAttribute("type",validatorType);
    if(validator.getProperties()!=null){
        for(ValidatorProperty vp:validator.getProperties()){
            if(StringHelper.isNotEmpty(vp.getName()) && StringHelper.isNotEmpty(vp.getValue())){
                Element propertyElement=createPropertyElement(vp.getName(),vp.getValue());
                element.add(propertyElement);                   
            }
        }
    }
    return element;
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(Element tree, XMLContext.Default defaults) {
    List<NamedStoredProcedureQuery> queries = buildNamedStoreProcedureQueries( tree, defaults );
    if ( defaults.canUseJavaAnnotations() ) {
        NamedStoredProcedureQuery annotation = getPhysicalAnnotation( NamedStoredProcedureQuery.class );
        addNamedStoredProcedureQueryIfNeeded( annotation, queries );
        NamedStoredProcedureQueries annotations = getPhysicalAnnotation( NamedStoredProcedureQueries.class );
        if ( annotations != null ) {
            for ( NamedStoredProcedureQuery current : annotations.value() ) {
                addNamedStoredProcedureQueryIfNeeded( current, queries );
            }
        }
    }
    if ( queries.size() > 0 ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( NamedStoredProcedureQueries.class );
        ad.setValue( "value", queries.toArray( new NamedStoredProcedureQuery[queries.size()] ) );
        return AnnotationFactory.create( ad );
    }
    else {
        return null;
    }
}
项目:joai-project    文件:MdeNode.java   
/**
 *  Insert an HTML comment into the html source.
 *
 * @param  e  NOT YET DOCUMENTED
 * @param  s  NOT YET DOCUMENTED
 */
protected void insertHtmlComment(Element e, String s) {
    prtln("\ninsertHtmlComment()");
    Element comment = df.createElement("st__htmlComment");
    comment.setText(s);
    Element parent = e.getParent();

    if (parent != null) {
        List children = parent.elements();
        int index = children.indexOf(e);
        children.add(index, comment);
    }
    else {
        // prtlnErr("PARENT NOT FOUND");
    }
}
项目:bdf2    文件:AbstractConverter.java   
protected void fillDataSetAndDataPathProperty(Element element,ComponentInfo component,boolean isCollection){
    String[] dataSetDataPath=this.retriveDataSetAndDataPath(component);
    if(dataSetDataPath!=null){
        if(StringHelper.isNotEmpty(dataSetDataPath[0])){
            BaseElement dataSetElement=new BaseElement("Property"); 
            dataSetElement.addAttribute("name", "dataSet");
            dataSetElement.setText(dataSetDataPath[0]);
            element.add(dataSetElement);
        }
        if(StringHelper.isNotEmpty(dataSetDataPath[1]) && !hasDataPath(component)){
            BaseElement dataPathElement=new BaseElement("Property");
            dataPathElement.addAttribute("name", "dataPath");
            String dataPath=dataSetDataPath[1];
            if(!isCollection){
                int pos=dataPath.lastIndexOf(".");
                if(pos>0){
                    dataPath=dataPath.substring(0,pos)+".#"+dataPath.substring(pos+1,dataPath.length());
                }                   
            }

            dataPathElement.setText(dataPath);
            element.add(dataPathElement);
        }
    }
}
项目:bdf2    文件:ModelBuilder.java   
private Element createReferencePropertyDef(Entity entity,RuleSet ruleSet,boolean isSelf){
    String nodeName=Reference.class.getSimpleName();
    Rule rule=ruleSet.getRule(nodeName);
    Element referenceDefElement=new BaseElement(rule.getNodeName());
    referenceDefElement.addAttribute("name", entity.getName());
    //创建dataType与dataProvider属性
    Element dataTypeElement=createPropertyElement("dataType",null);
    if(isSelf){
        dataTypeElement.setText("[SELF]");          
    }else{
        dataTypeElement.setText("["+ entity.getName()+"]");                     
    }
    referenceDefElement.add(dataTypeElement);
    String entityName=entity.getName();
    Element dataProviderElement=createPropertyElement("dataProvider","dataProvider"+entityName.substring(0,1).toUpperCase()+entityName.substring(1,entityName.length()));
    if(entity.getPageSize()>0){
        Element pageSizeElement=createPropertyElement("pageSize",String.valueOf(entity.getPageSize()));
        referenceDefElement.add(pageSizeElement);
    }
    referenceDefElement.add(dataProviderElement);
    referenceDefElement.add(createReferenceParameterElement(entity));
    return referenceDefElement;
}
项目:lams    文件:HbmBinder.java   
private static void parseFilterDef(Element element, Mappings mappings) {
    String name = element.attributeValue( "name" );
    LOG.debugf( "Parsing filter-def [%s]", name );
    String defaultCondition = element.getTextTrim();
    if ( StringHelper.isEmpty( defaultCondition ) ) {
        defaultCondition = element.attributeValue( "condition" );
    }
    HashMap paramMappings = new HashMap();
    Iterator params = element.elementIterator( "filter-param" );
    while ( params.hasNext() ) {
        final Element param = (Element) params.next();
        final String paramName = param.attributeValue( "name" );
        final String paramType = param.attributeValue( "type" );
        LOG.debugf( "Adding filter parameter : %s -> %s", paramName, paramType );
        final Type heuristicType = mappings.getTypeResolver().heuristicType( paramType );
        LOG.debugf( "Parameter heuristic type : %s", heuristicType );
        paramMappings.put( paramName, heuristicType );
    }
    LOG.debugf( "Parsed filter-def [%s]", name );
    FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
    mappings.addFilterDefinition( def );
}
项目:uflo    文件:ForeachParser.java   
public Object parse(Element element, long processId, boolean parseChildren) {
    ForeachNode node=new ForeachNode();
    node.setProcessId(processId);
    parseNodeCommonInfo(element, node);
    node.setSequenceFlows(parseFlowElement(element,processId,parseChildren));
    String type=element.attributeValue("foreach-type");
    if(StringUtils.isNotEmpty(type)){
        node.setForeachType(ForeachType.valueOf(type));         
    }
    node.setVariable(unescape(element.attributeValue("var")));
    if(StringUtils.isNotBlank(element.attributeValue("process-variable"))){
        node.setProcessVariable(unescape(element.attributeValue("process-variable")));          
    }else{
        node.setProcessVariable(unescape(element.attributeValue("in")));                        
    }
    node.setHandlerBean(unescape(element.attributeValue("handler-bean")));
    NodeDiagram diagram=parseDiagram(element);
    diagram.setIcon("/icons/foreach.svg");
    diagram.setShapeType(ShapeType.Circle);
    diagram.setBorderWidth(1);
    node.setDiagram(diagram);
    return node;
}
项目:minlia-iot    文件:AbstractApiComponent.java   
/**
 * 获取节点值
 * @param root
 * @param clazz
 * @param name
 * @return
 */
@SuppressWarnings("unchecked")
protected Optional<Object> elementValue(Element root, Class<?> clazz, String name) {
    Optional<String> elementTextOptional = elementText(root, name);
    if (elementTextOptional.isPresent()) {
        if (clazz == Integer.class) {
            return Optional.of(new Integer(elementTextOptional.get()));
        } else if (clazz == Long.class) {
            return Optional.of(new Long(elementTextOptional.get()));
        } else if (Enum.class.isAssignableFrom(clazz)) {
            try {
                Class enumClass = Class.forName(clazz.getName());
                return Optional.of(Enum.valueOf(enumClass, elementTextOptional.get()));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                return Optional.empty();
            }
        } else {
            return Optional.of(elementTextOptional.get());
        }
    } else {
        return Optional.empty();
    }
}
项目:joai-project    文件:Choice.java   
/**
 * Returns the members that could be added to the specified instanceElement
 * according to schema constraints.
 */
public List getAcceptableMembers (Element instanceElement) { 
    prtln ("\ngetAcceptableMembers with instanceElement:");
    prtln (instanceElement.asXML());
    ChoiceGuard guard;
    try {
        guard = new ChoiceGuard (this, instanceElement);
    } catch (Exception e) {
        prtln ("ChoiceGard init error: " + e.getMessage());
        return new ArrayList();
    }
    prtln ("about to call ChoiceGuard getAcceptableMembers()");
    List members = guard.getAcceptableMembers();
    prtln ("acceptable members:");
    printMemberList (members);
    return members;
}
项目:joai-project    文件:EditorRenderer.java   
/**
 *  Create label for a mulitBoxLabel element that will collapse the mulitBox
 *  input.<P>
 *
 *  Based on getComplexTypeLabel, but will always display collapse widget,
 *  rather than first testing for nodeIsExpandable as getComplexTypeLabel does.
 *  <P>
 *
 *  Depends on the multibox input having an id and display style initialized to
 *  value of collapseBean.displayState.
 *
 * @param  xpath  NOT YET DOCUMENTED
 * @return        The multiBoxLabel value
 */
public Label getMultiBoxLabel(String xpath) {
    ComplexTypeLabel labelObj = getComplexTypeLabel(xpath);
    Element alwaysExpandable = df.createElement("c__if")
        .addAttribute("test", "${true}");
    Element labelLink = alwaysExpandable.addElement("a")
        .addAttribute("href", "javascript__toggleDisplayState(" + RendererHelper.jspQuotedString("${id}") + ");");

    Element notExpandableTest = df.createElement("c__if")
        .addAttribute("test", "${false}");

    labelObj.isExpandableTest = alwaysExpandable.createCopy();
    labelObj.notExpandableTest = notExpandableTest.createCopy();
    labelObj.collapseWidget = getCollapseWidget().createCopy();
    return labelObj;
}
项目:bdf2    文件:DecisionConverter.java   
public JpdlInfo toJpdl(Element element) {
    BaseElement targetElement=new BaseElement("decision");
    String name=this.buildCommonJpdlElement(element, targetElement);
    String decisionType=element.attributeValue("decisionType");
    String decisionValue=element.attributeValue("decisionValue");
    if(decisionType.equals("handler")){
        BaseElement handlerElement=new BaseElement("handler");
        handlerElement.addAttribute("class", decisionValue);
        targetElement.add(handlerElement);
    }else{
        targetElement.addAttribute("expr",decisionValue);
    }
    JpdlInfo info=new JpdlInfo();
    info.setName(name);
    info.setElement(targetElement);
    return info;
}
项目:uflo    文件:EndParser.java   
public Object parse(Element element,long processId,boolean parseChildren) {
    EndNode node=new EndNode();
    node.setProcessId(processId);
    parseNodeCommonInfo(element, node);
    String terminate=element.attributeValue("terminate");
    if(StringUtils.isNotEmpty(terminate)){
        node.setTerminate(Boolean.valueOf(terminate));
    }
    NodeDiagram diagram=parseDiagram(element);
    if(node.isTerminate()){
        diagram.setIcon("/icons/end-terminate.svg");
    }else{
        diagram.setIcon("/icons/end.svg");
    }
    diagram.setShapeType(ShapeType.Circle);
    diagram.setBorderWidth(1);
    node.setDiagram(diagram);
    return node;
}
项目:Divinity_Original_Sin_2_zhCN    文件:DOS2ToMap.java   
@Override
public Map toMap(Document document) {
  Map<String, String> m = new HashMap<String, String>();
  /**
   * <contentList> <content contentuid=
   * "h00007224gb454g4b8bgb762g7865d9ee3dbb">如果不是这样的话!哈,开玩笑啦,我们在一起很合适,就像面包上的果酱。你想和我组队吗?我敢说你们需要一点野兽风味!</content>
   * <content contentuid="h0001d8b9g13d6g4605g85e9g708fe1e537c8">定制</content> </contentList>
   */
  // 获取根节点元素对象
  Element root = document.getRootElement();
  // 子节点
  List<Element> list = root.elements();
  // 使用递归
  Iterator<Element> iterator = list.iterator();
  while (iterator.hasNext()) {
    Element e = iterator.next();
    Attribute attribute = e.attribute("contentuid");
    m.put(attribute.getValue(), e.getText());
  }
  return m;
}
项目:etagate    文件:GateSetting.java   
public void parse(URL is) {
        SAXReader saxReader = new SAXReader();

        try {
            Document document = saxReader.read(is);
            Element root = document.getRootElement();

            collectProperty(root);
            parseAuth(root);
            parseApp(root);
//          
//          System.out.println("====================parse ok=============");
//          System.out.println(properties.toString());
//          System.out.println(authSetting.toString());
        } catch (DocumentException e) {
            log.error("Load route.xml error.");
            e.printStackTrace();
        }

    }
项目:bdf2    文件:TabControlConverter.java   
public Element convert(ComponentInfo component, RuleSet ruleSet,
        Element rootElement) throws Exception {
    String name=TabControl.class.getSimpleName();
    XmlNode node=TabControl.class.getAnnotation(XmlNode.class);
    if(node!=null && StringHelper.isNotEmpty(node.nodeName())){
        name=node.nodeName();
    }
    Rule rule=ruleSet.getRule(name);
    BaseElement element = fillElement(component,ruleSet,rule,rootElement);
    if(component.getChildren()!=null){
        for(ComponentInfo c:component.getChildren()){
            this.buildChildren(element,c,ruleSet,rootElement);                          
        }
    }
    return element;
}
项目:SimpleController    文件:XmlGenerator.java   
private Document readDocument(String path,String name, int age) throws DocumentException{
    SAXReader reader=new SAXReader();
    Document document=reader.read(path);
    Element root=document.getRootElement();
    List listOfTextView=document.selectNodes("view/body/form/textView");
    for(Iterator<Element> i=listOfTextView.listIterator();i.hasNext();){
        Element textView=i.next();
        if(textView.selectSingleNode("name").getText().equals("userName")){
            textView.selectSingleNode("value").setText(name);
        }
        if(textView.selectSingleNode("name").getText().equals("userAge")){
            textView.selectSingleNode("value").setText(""+age);
        }
    }
    System.out.println(document);
    return document;
}
项目:lams    文件:XMLContext.java   
private List<String> addEntityListenerClasses(Element element, String packageName, List<String> addedClasses) {
    List<String> localAddedClasses = new ArrayList<String>();
    Element listeners = element.element( "entity-listeners" );
    if ( listeners != null ) {
        @SuppressWarnings( "unchecked" )
        List<Element> elements = listeners.elements( "entity-listener" );
        for (Element listener : elements) {
            String listenerClassName = buildSafeClassName( listener.attributeValue( "class" ), packageName );
            if ( classOverriding.containsKey( listenerClassName ) ) {
                //maybe switch it to warn?
                if ( "entity-listener".equals( classOverriding.get( listenerClassName ).getName() ) ) {
                    LOG.duplicateListener( listenerClassName );
                    continue;
                }
                throw new IllegalStateException("Duplicate XML entry for " + listenerClassName);
            }
            localAddedClasses.add( listenerClassName );
            classOverriding.put( listenerClassName, listener );
        }
    }
    LOG.debugf( "Adding XML overriding information for listeners: %s", localAddedClasses );
    addedClasses.addAll( localAddedClasses );
    return localAddedClasses;
}
项目:bdf2    文件:AbstractConverter.java   
protected String buildCommonJpdlElement(Element element,Element targetElement){
    String name=element.attributeValue("name");
    String desc=element.attributeValue("desc");
    targetElement.addAttribute("name",name);
    Element descElement=new BaseElement("description");
    if(StringUtils.isNotEmpty(desc)){
        descElement.setText(desc);          
    }
    int width=Integer.parseInt(element.attributeValue("width"));
    int height=Integer.parseInt(element.attributeValue("height"));
    int x=Integer.parseInt(element.attributeValue("x"));
    int y=Integer.parseInt(element.attributeValue("y"));
    x=x-(width/2);
    y=y-(height/2);
    String g=x+","+y+","+width+","+height;
    if(this instanceof TransitionConverter){
        g=x+","+y;          
    }
    targetElement.addAttribute("g", g);
    /*for(Object obj:element.attributes()){
        Attribute attr=(Attribute)obj;
        targetElement.addAttribute(attr.getName(),attr.getValue());
    }*/
    return name;
}
项目:urule    文件:ParenParser.java   
@Override
public ParenValue parse(Element element) {
    ParenValue value=new ParenValue();
    for(Object obj:element.elements()){
        if(obj==null || !(obj instanceof Element)){
            continue;
        }
        Element ele=(Element)obj;
        if(valueParser.support(ele.getName())){
            value.setValue(valueParser.parse(ele));
        }else if(arithmeticParser.support(ele.getName())){
            value.setArithmetic(arithmeticParser.parse(ele));
        }
    }
    return value;
}
项目:unitimes    文件:CourseOfferingExport.java   
protected void exportCourse(Element courseElement, CourseOffering course, Session session) {
    courseElement.addAttribute("id", (course.getExternalUniqueId()!=null?course.getExternalUniqueId():course.getUniqueId().toString()));
    courseElement.addAttribute("subject", course.getSubjectArea().getSubjectAreaAbbreviation());
    courseElement.addAttribute("courseNbr", course.getCourseNbr());
    if (course.getReservation() != null)
        courseElement.addAttribute("reserved", course.getReservation().toString());
    courseElement.addAttribute("controlling", course.isIsControl()?"true":"false");
    if (course.getConsentType()!=null)
        courseElement.addElement("consent").addAttribute("type", course.getConsentType().getReference());
    if (course.getTitle()!=null)
        courseElement.addAttribute("title", course.getTitle());
    if (course.getScheduleBookNote()!=null)
        courseElement.addAttribute("scheduleBookNote", course.getScheduleBookNote());
    for (Iterator i=course.getCreditConfigs().iterator();i.hasNext();) {
        CourseCreditUnitConfig credit = (CourseCreditUnitConfig)i.next();
        exportCredit(courseElement.addElement("courseCredit"), credit, session);
    }
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * Delete the custom header
 *
 * @param document
 * @param manifestOptions
 */
private static void removeCustomLaunches(Document document, ManifestOptions manifestOptions) {
    if (null == manifestOptions) {
        return;
    }
    Element root = document.getRootElement();// Get the root node
    // Update launch information
    if (manifestOptions.getRetainLaunches() != null && manifestOptions.getRetainLaunches().size() > 0) {
        List<? extends Node> nodes = root.selectNodes(
            "//activity/intent-filter/category|//activity-alias/intent-filter/category");
        for (Node node : nodes) {
            Element e = (Element)node;
            if ("android.intent.category.LAUNCHER".equalsIgnoreCase(e.attributeValue("name"))) {
                Element activityElement = e.getParent().getParent();
                String activiyName = activityElement.attributeValue("name");
                if (!manifestOptions.getRetainLaunches().contains(activiyName)) {
                    if (activityElement.getName().equalsIgnoreCase("activity-alias")) {
                        activityElement.getParent().remove(activityElement);
                    } else {
                        e.getParent().remove(e);
                    }
                }
            }
        }
    }
}
项目:unitimes    文件:PageAccessFilter.java   
public void init(FilterConfig cfg) throws ServletException {
    iContext = cfg.getServletContext();
    try {
        Document config = (new SAXReader()).read(cfg.getServletContext().getResource(cfg.getInitParameter("config")));
        for (Iterator i=config.getRootElement().element("action-mappings").elementIterator("action"); i.hasNext();) {
            Element action = (Element)i.next();
            String path = action.attributeValue("path");
            String input = action.attributeValue("input");
            if (path!=null && input!=null) {
                iPath2Tile.put(path+".do", input);
            }
        }
    } catch (Exception e) {
        sLog.error("Unable to read config "+cfg.getInitParameter("config")+", reason: "+e.getMessage());
    }
    if (cfg.getInitParameter("debug-time")!=null) {
        debugTime = Long.parseLong(cfg.getInitParameter("debug-time"));
    }
    if (cfg.getInitParameter("dump-time")!=null) {
        dumpTime = Long.parseLong(cfg.getInitParameter("dump-time"));
    }
    if (cfg.getInitParameter("session-attributes")!=null) {
        dumpSessionAttribues = Boolean.parseBoolean(cfg.getInitParameter("session-attributes"));
    }
}
项目:sbc-qsystem    文件:QIndicatorBoardMonitor.java   
@Override
public Element getConfig() {
    final File boardFile = new File(getConfigFile());
    if (boardFile.exists()) {
        try {
            return new SAXReader(false).read(boardFile).getRootElement();
        } catch (DocumentException ex) {
            QLog.l().logger()
                .error("Невозможно прочитать файл конфигурации главного табло. " + ex
                    .getMessage());
            return DocumentHelper.createElement("Ответ");
        }
    } else {
        QLog.l().logger()
            .warn("Файл конфигурации главного табло \"" + configFile + "\" не найден. ");
        return DocumentHelper.createElement("Ответ");
    }
}
项目:ats-framework    文件:XmlText.java   
/**
 * Returns the child XPaths of a XML element
 *
 * @return the XPath of the XML element.
 * @return the child XPaths of a XML element
 * @throws XMLException
 */
@PublicAtsApi
public String[] getElementXPaths(
                                  String xpath ) throws XMLException {

    ArrayList<String> elementXPaths = new ArrayList<>(1);

    if (StringUtils.isNullOrEmpty(xpath)) {
        throw new XMLException("Null/empty xpath is not allowed.");
    }

    Element element = findElement(xpath);

    if (element == null) {
        throw new XMLException("'" + xpath + "' is not a valid path");
    }

    Iterator<Element> it = element.elementIterator();

    while (it.hasNext()) {
        elementXPaths.add(it.next().getUniquePath());
    }

    return elementXPaths.toArray(new String[elementXPaths.size()]);
}
项目:ats-framework    文件:XmlText.java   
/**
 * Append text to a XML element.
 *
 * @param xpath XPath , pointing to a XML element
 * @param text the text , which will be appended to a XML element
 * @return this instance
 * @throws XMLException
 */
@PublicAtsApi
public XmlText appendText(
                           String xpath,
                           String text ) throws XMLException {

    if (StringUtils.isNullOrEmpty(xpath)) {
        throw new XMLException("Null/empty xpath is not allowed.");
    }

    if (StringUtils.isNullOrEmpty(text)) {
        throw new XMLException("Null/empty text is not allowed.");
    }

    Element element = findElement(xpath);

    if (element == null) {
        throw new XMLException("'" + xpath + "' is not a valid path");
    }

    element.addText(text);

    return this;
}
项目:unitimes    文件:LowercaseTableNames.java   
protected void writeAttributes(Element element) throws IOException {
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
           char quote = format.getAttributeQuoteCharacter();
           if (element.attributeCount() > 2) {
               writePrintln();
               indent();
               writer.write(format.getIndent());
           } else {
            writer.write(" ");
           }
           writer.write(attribute.getQualifiedName());
           writer.write("=");
           writer.write(quote);
           writeEscapeAttributeEntities(attribute.getValue());
           writer.write(quote);
    }
}
项目:joai-project    文件:DcsViewRecord.java   
private void renderMaster () throws Exception {
    Element base = df.createElement("div");
    /* base.addAttribute ("class", "level--1"); */
    List elements = instanceDocument.getRootElement().elements();
    // prtln("batchRenderAndWrite found " + elements.size() + " elements");
    for (Iterator i = elements.iterator(); i.hasNext(); ) {
        Element child = (Element) i.next();
        String xpath = child.getPath();
        String pageName = XPathUtils.getNodeName(xpath);
        Element include = base.addElement("jsp__include");
        include.addAttribute("page", getMasterComponentPath (pageName));
    }

    File dest = getJspDest (null);
    if (!writeJsp(base, dest, this.getMasterJspHeader())) {
        throw new Exception ("renderMaster(): failed to write jsp to " + dest);
    }

}
项目:ofmeet-openfire-plugin    文件:OfMeetPlugin.java   
public void sessionDestroyed(Session session)
{
    Log.debug("OfMeet Plugin -  sessionDestroyed "+ session.getAddress().toString() + "\n" + ((ClientSession) session).getPresence().toXML());

    boolean skypeAvailable = XMPPServer.getInstance().getPluginManager().getPlugin("ofskype") != null;

    if (OfMeetAzure.skypeids.containsKey(session.getAddress().getNode()))
    {
        String sipuri = OfMeetAzure.skypeids.remove(session.getAddress().getNode());

        IQ iq = new IQ(IQ.Type.set);
        iq.setFrom(session.getAddress());
        iq.setTo(XMPPServer.getInstance().getServerInfo().getXMPPDomain());

        Element child = iq.setChildElement("request", "http://igniterealtime.org/protocol/ofskype");
        child.setText("{'action':'stop_skype_user', 'sipuri':'" + sipuri + "'}");
        XMPPServer.getInstance().getIQRouter().route(iq);

        Log.info("OfMeet Plugin - closing skype session " + sipuri);
    }
}
项目:iBase4J    文件:XmlUtil.java   
/**
 * 将List数据类型转换为符合XML格式规范的字符串(基于节点值的方式)
 * 
 * @param pList 传入的List数据(List对象可以是Dto、VO、Domain的属性集)
 * @param pRootNodeName 根节点名称
 * @param pFirstNodeName 行节点名称
 * @return string 返回XML格式字符串
 */
public static final String parseList2XmlBasedNode(List pList, String pRootNodeName, String pFirstNodeName) {
    Document document = DocumentHelper.createDocument();
    Element output = document.addElement(pRootNodeName);
    for (int i = 0; i < pList.size(); i++) {
        Map map = (Map) pList.get(i);
        Element elRow = output.addElement(pFirstNodeName);
        Iterator it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            Element leaf = elRow.addElement((String) entry.getKey());
            leaf.setText(String.valueOf(entry.getValue()));
        }
    }
    String outXml = document.asXML().substring(39);
    return outXml;
}
项目:joai-project    文件:AttributeGroup.java   
/**
 *  NOT YET DOCUMENTED
 *
 * @return    NOT YET DOCUMENTED
 */
public String toString() {
    String s = "AttributeGroup: " + name;
    s += super.toString();
        String nl = "\n\t";
    for (Iterator i=getAttributes().iterator();i.hasNext();) {
        Element e = (Element)i.next();
        s += nl + e.asXML();
    }
    return s;
}
项目:unitimes    文件:CourseOfferingExport.java   
protected void exportAssignment(Element classElement, Assignment assignment, Session session) {
    exportDatePattern(classElement, assignment.getDatePattern(), session);
    exportTimeLocation(classElement, assignment, session);
    exportRooms(classElement, assignment, session);
    if (iClassEvents != null)
        exportEvent(classElement, iClassEvents.get(assignment.getClassId()), session);
    if (iExportGroupInfos)
        exportGroupInfos(classElement, assignment, session);
}
项目:unitimes    文件:BaseImport.java   
protected String getRequiredStringAttribute(Element element, String attributeName, String elementName) throws Exception{        
    String attributeValue = element.attributeValue(attributeName);
    if (attributeValue == null || attributeValue.trim().length() == 0){
        throw new Exception("For element '" + elementName + "' a '" + attributeName + "' is required");
    } else {
        attributeValue = attributeValue.trim().replace('\u0096', ' ').replace('\u0097', ' ');
    }                       
    return(attributeValue);
}
项目:ARCLib    文件:XmlBuilderTest.java   
@Test
public void addSiblingNodeTest() throws IOException, SAXException, TransformerException {
    Document doc = DocumentHelper.createDocument(DocumentHelper.createElement("root"));

    Element root = doc.getRootElement();

    Element child = DocumentHelper.createElement("child");
    child.setText("test value 1");

    root.add(child);

    xmlBuilder.addNode(doc, "/root/child", "test value 2", uris.get("ARCLIB"));
    assertThat(doc.asXML(), is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><child>test value 1</child><child xmlns=\"http://arclib.lib.cas.cz/ARCLIB_XML\">test value 2</child></root>"));
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private static void buildIndex(AnnotationDescriptor annotation, Element element){
    List indexElementList = element.elements( "index" );
    Index[] indexes = new Index[indexElementList.size()];
    for(int i=0;i<indexElementList.size();i++){
        Element subelement = (Element)indexElementList.get( i );
        AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class );
        copyStringAttribute( indexAnn, subelement, "name", false );
        copyStringAttribute( indexAnn, subelement, "column-list", true );
        copyBooleanAttribute( indexAnn, subelement, "unique" );
        indexes[i] = AnnotationFactory.create( indexAnn );
    }
    annotation.setValue( "indexes", indexes );
}
项目:iBase4J    文件:XmlUtil.java   
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    Document document = null;
    try {
        if (pStrXml.indexOf("<?xml") < 0)
            pStrXml = strTitle + pStrXml;
        document = DocumentHelper.parseText(pStrXml);
    } catch (DocumentException e) {
        log.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
    }
    // 获取到根节点
    Element elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element) elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute) attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
项目:unitimes    文件:PointInTimeDataExport.java   
private void exportCourseType(CourseType courseType){
    Element courseTypeElement = courseTypesElement.addElement(sCourseTypeElementName);
    courseTypeElement.addAttribute(sUniqueIdAttribute, courseType.getUniqueId().toString());
    courseTypeElement.addAttribute(sReferenceAttribute, courseType.getReference());
    courseTypeElement.addAttribute(sLabelAttribute, courseType.getLabel());
    courseTypeElements.put(courseType.getUniqueId(), courseTypeElement);
}
项目:wherehowsX    文件:XMLFileAnalyzer.java   
private void getChildNodes(Element node, String parent) {
    String nodeName = getNodename(node, parent);
    if (!node.getTextTrim().equals(""))
        keyToValues.put(nodeName, node.getTextTrim());

    List<Element> listElement = node.elements();
    for (Element e : listElement) {
        if (!parent.equals(""))
            getChildNodes(e, parent + "." + node.getName());
        else
            getChildNodes(e, node.getName());
    }
}
项目:wherehowsX    文件:XMLFileAnalyzer.java   
private String getNodename(Element node, String parent) {
    String nodeName = "";
    if (!parent.equals(""))
        nodeName = parent + "." + node.getName();
    else
        nodeName = node.getName();
    return nodeName;
}