Java 类org.w3c.dom.Element 实例源码

项目:kaltura-ce-sakai-extension    文件:KalturaRule.java   
public KalturaRule(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("message")) {
            this.message = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("actions")) {
            this.actions = ParseUtils.parseArray(KalturaAccessControlAction.class, aNode);
            continue;
        } else if (nodeName.equals("conditions")) {
            this.conditions = ParseUtils.parseArray(KalturaCondition.class, aNode);
            continue;
        } else if (nodeName.equals("contexts")) {
            this.contexts = ParseUtils.parseArray(KalturaAccessControlContextTypeHolder.class, aNode);
            continue;
        } else if (nodeName.equals("stopProcessing")) {
            this.stopProcessing = ParseUtils.parseBool(txt);
            continue;
        } 
    }
}
项目:kaltura-ce-sakai-extension    文件:KalturaSessionService.java   
/**  Start a session with Kaltura's server.   The result KS is the session key that
you should pass to all services that requires a ticket.     */
 public String start(String secret, String userId, KalturaSessionType type, int partnerId, int expiry, String privileges) throws KalturaApiException {
     KalturaParams kparams = new KalturaParams();
     kparams.add("secret", secret);
     kparams.add("userId", userId);
     kparams.add("type", type);
     kparams.add("partnerId", partnerId);
     kparams.add("expiry", expiry);
     kparams.add("privileges", privileges);
     this.kalturaClient.queueServiceCall("session", "start", kparams);
     if (this.kalturaClient.isMultiRequest())
         return null;
     Element resultXmlElement = this.kalturaClient.doQueue();
     String resultText = resultXmlElement.getTextContent();
     return ParseUtils.parseString(resultText);
 }
项目:rapidminer    文件:ParameterTypeTupel.java   
@Override
protected void writeDefinitionToXML(Element typeElement) {

    Element childTypesElement = XMLTools.addTag(typeElement, ELEMENT_CHILD_TYPES);
    for (ParameterType type : types) {
        Element childTypeElement = XMLTools.addTag(childTypesElement, ELEMENT_CHILD_TYPE);
        type.writeDefinitionToXML(childTypeElement);
    }

    // now default list
    Element defaultEntriesElement = XMLTools.addTag(typeElement, ELEMENT_DEFAULT_ENTRIES);
    for (Object defaultValue : defaultValues) {
        Element defaultEntryElement = XMLTools.addTag(defaultEntriesElement, ELEMENT_DEFAULT_ENTRY);
        if (defaultValue != null && defaultValue instanceof String) {
            defaultEntryElement.setTextContent(defaultValue.toString());
        } else {
            defaultEntriesElement.setAttribute(ATTRIBUTE_IS_NULL, "true");
        }
    }
}
项目:dble    文件:XMLRuleLoader.java   
/**
 * tableRule tag:
 * <tableRule name="sharding-by-month">
 * <rule>
 * <columns>create_date</columns>
 * <algorithm>partbymonth</algorithm>
 * </rule>
 * </tableRule>
 *
 * @param root
 * @throws SQLSyntaxErrorException
 */
private void loadTableRules(Element root) throws SQLSyntaxErrorException {
    NodeList list = root.getElementsByTagName("tableRule");
    for (int i = 0, n = list.getLength(); i < n; ++i) {
        Node node = list.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            String name = e.getAttribute("name");
            if (StringUtil.isEmpty(name)) {
                throw new ConfigException("name is null or empty");
            }
            if (tableRules.containsKey(name)) {
                throw new ConfigException("table rule " + name + " duplicated!");
            }
            NodeList ruleNodes = e.getElementsByTagName("rule");
            int length = ruleNodes.getLength();
            if (length > 1) {
                throw new ConfigException("only one rule can defined :" + name);
            }
            //rule has only one element now. Maybe it will not contains one rule in feature
            //RuleConfig:rule->function
            RuleConfig rule = loadRule((Element) ruleNodes.item(0));
            tableRules.put(name, new TableRuleConfig(name, rule));
        }
    }
}
项目:pay    文件:XMLParser.java   
public static Map<String,Object> getMapFromXML(String xmlString) throws ParserConfigurationException, IOException, SAXException {

        //这里用Dom的方式解析回包的最主要目的是防止API新增回包字段
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputStream is =  IOUtils.toInputStream(xmlString);
        Document document = builder.parse(is);
        //获取到document里面的全部结点
        NodeList allNodes = document.getFirstChild().getChildNodes();
        Node node;
        Map<String, Object> map = new HashMap<String, Object>();
        int i=0;
        while (i < allNodes.getLength()) {
            node = allNodes.item(i);
            if(node instanceof Element){
                map.put(node.getNodeName(),node.getTextContent());
            }
            i++;
        }
        return map;

    }
项目:ChronoBike    文件:CEntityResourceForm.java   
/**
 * @param root
 */
public void ExportCustomProperties(Document doc)
{
    Element eForm = doc.getDocumentElement() ;
    if (!m_csCustomOnloadMethod.equals(""))
    {
        eForm.setAttribute("customOnload", m_csCustomOnloadMethod) ;
    }
    if (!m_csCustomSubmitMethod.equals(""))
    {
        eForm.setAttribute("customSubmit", m_csCustomSubmitMethod) ;
    }
    if (!m_csDefaultCursor.equals(""))
    {
        eForm.setAttribute("defaultCursor", m_csDefaultCursor) ;
    }
}
项目:kaltura-ce-sakai-extension    文件:KalturaCountryRestriction.java   
public KalturaCountryRestriction(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("countryRestrictionType")) {
            this.countryRestrictionType = KalturaCountryRestrictionType.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("countryList")) {
            this.countryList = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
项目:kaltura-ce-sakai-extension    文件:KalturaConversionAttribute.java   
public KalturaConversionAttribute(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("flavorParamsId")) {
            this.flavorParamsId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("name")) {
            this.name = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("value")) {
            this.value = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
项目:OpenJSharp    文件:Util.java   
public static Element nextElement(Iterator iter) {
    while (iter.hasNext()) {
        Node n = (Node) iter.next();
        if (n instanceof Text) {
            Text t = (Text) n;
            if (t.getData().trim().length() == 0)
                continue;
            fail("parsing.nonWhitespaceTextFound", t.getData().trim());
        }
        if (n instanceof Comment)
            continue;
        if (!(n instanceof Element))
            fail("parsing.elementExpected");
        return (Element) n;
    }

    return null;
}
项目:ibench    文件:XSDReader.java   
private Schema visitRoot(Node root, String nameSchema){
    Schema s = new Schema(nameSchema);
    types = new SetAssociativeArray();
    dummyNr = 0;
    //process the complexType nodes under the schema node
    NodeList children = root.getChildNodes();
    int nr=children.getLength();
    for(int j=0; j<nr; j++){
        if (children.item(j).getNodeName().equalsIgnoreCase("xs:complexType")){
            Node nodeCT = children.item(j);
            String name = getAttr("name",nodeCT);
            vtools.dataModel.schema.Element eCT = processComplexTypeNode(nodeCT,name,false);
            types.add(eCT.getLabel(), eCT.getType().clone());
        }   
    }
    //process the element nodes under the schema node
    for(int j=0; j<nr; j++){
        if (children.item(j).getNodeName().equalsIgnoreCase("xs:element")){
            vtools.dataModel.schema.Element elem = processElementNode(children.item(j));
            s.addRootElement(elem);
        }
    }

    return s;
}
项目:springboot-shiro-cas-mybatis    文件:AbstractMetadataResolverAdapter.java   
/**
 * Build single metadata resolver.
 *
 * @param metadataFilterChain the metadata filters chained together
 * @param resource the resource
 * @param document the xml document to parse
 * @return list of resolved metadata from resources.
 * @throws IOException the iO exception
 */
private List<MetadataResolver> buildSingleMetadataResolver(final MetadataFilter metadataFilterChain,
                                         final Resource resource, final Document document) throws IOException {
    final List<MetadataResolver> resolvers = new ArrayList<>();
    final Element metadataRoot = document.getDocumentElement();
    final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);

    metadataProvider.setParserPool(this.configBean.getParserPool());
    metadataProvider.setFailFastInitialization(true);
    metadataProvider.setRequireValidMetadata(this.requireValidMetadata);
    metadataProvider.setId(metadataProvider.getClass().getCanonicalName());
    if (metadataFilterChain != null) {
        metadataProvider.setMetadataFilter(metadataFilterChain);
    }
    logger.debug("Initializing metadata resolver for [{}]", resource.getURL());

    try {
        metadataProvider.initialize();
    } catch (final ComponentInitializationException ex) {
        logger.warn("Could not initialize metadata resolver. Resource will be ignored", ex);
    }
    resolvers.add(metadataProvider);
    return resolvers;
}
项目:jdk8u-jdk    文件:DOMExcC14NMethod.java   
private void unmarshalParams(Element paramsElem) {
    String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
    this.inclusiveNamespaces = prefixListAttr;
    int begin = 0;
    int end = prefixListAttr.indexOf(' ');
    List<String> prefixList = new ArrayList<String>();
    while (end != -1) {
        prefixList.add(prefixListAttr.substring(begin, end));
        begin = end + 1;
        end = prefixListAttr.indexOf(' ', begin);
    }
    if (begin <= prefixListAttr.length()) {
        prefixList.add(prefixListAttr.substring(begin));
    }
    this.params = new ExcC14NParameterSpec(prefixList);
}
项目:bdf2    文件:ProcessDefinition.java   
@Override
public Element parseModel(Document doc){
    Element process=doc.createElement("process");
    if(StringHelper.isNotEmpty(name)){
        process.setAttribute("name", name);
    }
    process.setAttribute("xmlns", "http://jbpm.org/4.4/jpdl");
    if(StringHelper.isNotEmpty(key)){
        process.setAttribute("key", key);
    }
    if(StringHelper.isNotEmpty(version)){
        process.setAttribute("version", version);
    }
    if(StringHelper.isNotEmpty(description)){
        Element desc=doc.createElement("description");
        desc.setTextContent(description);
        process.appendChild(desc);
    }
    return process;
}
项目:incubator-netbeans    文件:XMLUtil.java   
/**
 * Find all direct child elements of an element.
 * More useful than {@link Element#getElementsByTagNameNS} because it does
 * not recurse into recursive child elements.
 * Children which are all-whitespace text nodes or comments are ignored; others cause
 * an exception to be thrown.
 * @param parent a parent element in a DOM tree
 * @return a list of direct child elements (may be empty)
 * @throws IllegalArgumentException if there are non-element children besides whitespace
 */
static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
    NodeList l = parent.getChildNodes();
    List<Element> elements = new ArrayList<>(l.getLength());
    for (int i = 0; i < l.getLength(); i++) {
        Node n = l.item(i);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            elements.add((Element)n);
        } else if (n.getNodeType() == Node.TEXT_NODE) {
            String text = ((Text)n).getNodeValue();
            if (text.trim().length() > 0) {
                throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
            }
        } else if (n.getNodeType() == Node.COMMENT_NODE) {
            // OK, ignore
        } else {
            throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
        }
    }
    return elements;
}
项目:cuttlefish    文件:GraphMLExporter.java   
private Element createGraphElement(Element root) {
    Element graphEl = doc.createElement("graph");
    root.appendChild(graphEl);

    if (network.getEdgeCount(true) > network.getEdgeCount(false)) {
        graphEl.setAttribute("edgedefault", "directed");
    } else {
        graphEl.setAttribute("edgedefault", "undirected");
    }

    // Create nodes
    createNodes(graphEl);

    // Create edges
    createEdges(graphEl);

    return graphEl;
}
项目:incubator-netbeans    文件:ShortcutWizard.java   
ShortcutWizard(AntProjectCookie project, Element target, ShortcutIterator it) {
    this.project = project;
    this.target = target;
    this.it = it;
    it.initialize(this);
    setPanelsAndSettings(it, this);
    setTitle(NbBundle.getMessage(ShortcutWizard.class, "TITLE_wizard"));
    putProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
    String desc = target.getAttribute("description"); // NOI18n
    putProperty(PROP_DISPLAY_NAME, desc);
    // XXX deal with toolbar short desc somehow: #39985
    // Need to have another field in toolbar panel, and also patch AntActionInstance
    // to respond to Action.SHORT_DESCRIPTION, presumably as the <description>.
}
项目:EspressoViews    文件:QueryDefinitionParser.java   
public static void addConnectionDetailsToDefFile(String filePath, Map<String,String> connDet ){
    Document doc = getXmlDocument(filePath);
    Element newConnection= doc.createElement("DBConnectionDefinition");
    newConnection.appendChild(doc.createElement("connectionName"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("CONNECTIONNAME")));
    newConnection.appendChild(doc.createElement("connectionType"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("CONNECTIONTYPE")));        
    newConnection.appendChild(doc.createElement("dbType"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("DBTYPE")));
    newConnection.appendChild(doc.createElement("serviceName"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("SERVICENAME")));
    newConnection.appendChild(doc.createElement("host"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("HOST")));
    newConnection.appendChild(doc.createElement("userName"));
        newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("USERNAME")));

    getElementByTagName(doc,"DBConnectionDefinition").getParentNode().appendChild(newConnection);   
    //getElementByTagName(doc,"ROOT").appendChild(newConnection);   
    storeXmlDocToFile(filePath, doc);       
    showMeTheDoc(newConnection, 1);
}
项目:incubator-netbeans    文件:TestUtilTest.java   
public void testCreateCompletion() throws Exception {
    HintContext c = TestUtil.createCompletion("<fooHERE/>");
    assertHintContext(c, Node.ELEMENT_NODE, "foo", null, "foo");
    assertTrue("right type acc. to instanceof", c instanceof Element);
    c = TestUtil.createCompletion("<foo/>");
    assertNull("no hint here", c);
    c = TestUtil.createCompletion("<foo><barHERE/></foo>");
    assertHintContext(c, Node.ELEMENT_NODE, "bar", null, "bar");
    Node n = c.getParentNode();
    assertEquals("parent is an element", Node.ELEMENT_NODE, n.getNodeType());
    assertEquals("parent is <foo>", "foo", n.getNodeName());
    c = TestUtil.createCompletion("<foo><bar attrHERE='whatever'/></foo>");
    assertHintContext(c, Node.ATTRIBUTE_NODE, "attr", null, "attr");
    Element owner = ((Attr)c).getOwnerElement();
    assertEquals("parent is <bar>", "bar", owner.getNodeName());
    c = TestUtil.createCompletion("<foo><bar attr='somethingHERE'/></foo>");
    assertHintContext(c, Node.ATTRIBUTE_NODE, null, "something", "something");
    owner = ((Attr)c).getOwnerElement();
    assertEquals("parent is <bar>", "bar", owner.getNodeName());
    c = TestUtil.createCompletion("<foo>somethingHERE</foo>");
    assertHintContext(c, Node.TEXT_NODE, null, "something", "something");
    n = c.getParentNode();
    assertEquals("parent is an element", Node.ELEMENT_NODE, n.getNodeType());
    assertEquals("parent is <foo>", "foo", n.getNodeName());
}
项目:incubator-netbeans    文件:CslJar.java   
private List<Element> getAttributeElements(Document doc, String path) {
    Element parent = findPath(doc, path);

    List<Element> attributes = new ArrayList<Element>();

    if (parent != null) {
        for (Element f : getElementChildren(parent)) {
            String tag = f.getTagName();
            if (ATTR.equals(tag)) { // NOI18N
                attributes.add(f);
            }
        }
    }

    return attributes;
}
项目:openjdk-jdk10    文件:ElementImpl.java   
/**
 * @see <a
 * href="http://www.w3.org/TR/2008/REC-ElementTraversal-20081222/#attribute-lastElementChild">
 * Element Traversal Specification</a>
 */
@Override
public final Element getLastElementChild() {
    Node n = getLastChild();
    while (n != null) {
        switch (n.getNodeType()) {
            case Node.ELEMENT_NODE:
                return (Element) n;
            case Node.ENTITY_REFERENCE_NODE:
                final Element e = getLastElementChild(n);
                if (e != null) {
                    return e;
                }
                break;
        }
        n = n.getPreviousSibling();
    }
    return null;
}
项目:Proyecto-DASI    文件:ReadXMLTestRobots.java   
private String getRobotCoordinateZ(Element info, String tagcoordinate, String tagdimension){
      String valuez = "";        
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
 Element coorInfo = (Element) coordinateNode;                         
 //Obtain information about z coordinate for the current robot 
 NodeList zNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
 Element zNmElmnt = (Element) zNmElmntLst.item(0);
 NodeList zNm = zNmElmnt.getChildNodes();                     
 valuez = ((Node)zNm.item(0)).getNodeValue();                 
}
return valuez;
}
项目:oscm    文件:MigrationBillingSharesResultOperatorRevShare.java   
private void migrateOperatorRevenueAttribute(Element element) {
    if (!element
            .hasAttribute(BillingShareResultXmlTags.ATTRIBUTE_NAME_OPERATOR_REVENUE)) {
        element.setAttribute(
                BillingShareResultXmlTags.ATTRIBUTE_NAME_OPERATOR_REVENUE,
                "0.00");
    }
}
项目:kaltura-ce-sakai-extension    文件:KalturaEntryDistributionService.java   
/**  Add new Entry Distribution     */
public KalturaEntryDistribution add(KalturaEntryDistribution entryDistribution) throws KalturaApiException {
    KalturaParams kparams = new KalturaParams();
    kparams.add("entryDistribution", entryDistribution);
    this.kalturaClient.queueServiceCall("contentdistribution_entrydistribution", "add", kparams);
    if (this.kalturaClient.isMultiRequest())
        return null;
    Element resultXmlElement = this.kalturaClient.doQueue();
    return ParseUtils.parseObject(KalturaEntryDistribution.class, resultXmlElement);
}
项目:ciguan    文件:ConfigurationTest.java   
private static Class<?> ensureType(String pType, Element pSource) {
    Class<?> tType = cObjectTypes.get(pType);
    if (tType != null) {
        return tType;
    }
    if (pType.endsWith("_list")) {
        pType = pType.replace("_list", "");
        if (cAsList.containsKey(pType)) {
            tType = Object.class;
        }
    }
    if (pType.endsWith("[]")) {
        pType = pType.replace("[]", "");
    }
    if (tType == null && pType.startsWith("com.")) {
        cObjectTypes.put(pType, tType = find(pType));
    }
    else if (tType == null) {
        int tPos = pType.indexOf(":");
        String tSimpleName = pType.substring(tPos + 1);
        String tNamespace = tPos == -1 ? "" : pType.substring(0, tPos);
        for (Map.Entry<String, String> tPackage : cSearchPackages.entrySet()) {
            if (tNamespace.equals(tPackage.getValue())) {
                tType = find(tPackage.getKey() + "." + tSimpleName);
                if (tType != null) {
                    cObjectTypes.put(pType, tType);
                    break;
                }
            }
        }
    }
    if (tType == null) {
        error("Type not found: " + pType, pSource);
    }
    return tType;
}
项目:incubator-netbeans    文件:AnnotationProcessingQueryImpl.java   
public @Override Set<? extends Trigger> annotationProcessingEnabled() {
    Set<Trigger> result = triggerCache;
    if (result != null) {
        return result;
    }
    result = EnumSet.noneOf(Trigger.class);
    if (ap != null) {
        for (Element e : XMLUtil.findSubElements(ap)) {
            if (e.getLocalName().equals(EL_SCAN_TRIGGER)) {
                result.add(Trigger.ON_SCAN);
            } else if (e.getLocalName().equals(EL_EDITOR_TRIGGER)) {
                result.add(Trigger.IN_EDITOR);
            }
        }
    }
    if (result.size() == 1 && result.contains(Trigger.IN_EDITOR)) {
        //Contains only editor-trigger
        //Add required scan-trigger and log
        result.add(Trigger.ON_SCAN);
        LOG.log(
            Level.WARNING, 
            "Project {0} project.xml contains annotation processing editor-trigger only. The scan-trigger is required as well, adding it into the APQ.Result.", //NOI18N
            FileUtil.getFileDisplayName(helper.getProjectDirectory()));
    }
    synchronized (LCK) {
        if (triggerCache == null) {
            triggerCache = result;
        }
    }
    return result;
}
项目:QN-ACTR-Release    文件:JabaModel.java   
private Element makeSolutionElement(Document root) {
    //TODO: non sono compresi i risultati aggregati (quelli che prendo sono giusti?? gli aggregati sono gli ultimi??)
    Element result_element = root.createElement("solutions");
    result_element.setAttribute("ok", "true");
    result_element.setAttribute("solutionMethod", "analytical");
    for (int i = 0; i < stations; i++) {
        Element stationresults_element = (Element) result_element.appendChild(root.createElement("stationresults"));
        stationresults_element.setAttribute("station", this.stationNames[i]);
        for (int j = 0; j < classes; j++) {
            Element classesresults_element = (Element) stationresults_element.appendChild(root.createElement("classresults"));
            classesresults_element.setAttribute("customerclass", classNames[j]);

            Element Q_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
            Q_element.setAttribute("measureType", "Queue length");
            Q_element.setAttribute("successful", "true");
            Q_element.setAttribute("meanValue", Double.toString(this.queueLen[i][j]));

            Element X_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
            X_element.setAttribute("measureType", "Throughput");
            X_element.setAttribute("successful", "true");
            X_element.setAttribute("meanValue", Double.toString(this.throughput[i][j]));

            Element R_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
            R_element.setAttribute("measureType", "Response time");
            R_element.setAttribute("successful", "true");
            R_element.setAttribute("meanValue", Double.toString(this.resTimes[i][j]));

            Element U_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
            U_element.setAttribute("measureType", "Utilization");
            U_element.setAttribute("successful", "true");
            U_element.setAttribute("meanValue", Double.toString(this.util[i][j]));
        }
    }
    return result_element;
}
项目:Equella    文件:OAIProtocol.java   
protected void processMetadataToLO(Object o, PropBagEx xml)
{
    PropBagEx element = new PropBagEx((Element) o);
    try
    {
        String xsltName = getProfile().getAttribute("schemaInputTransform"); //$NON-NLS-1$
        if( xsltName != null && !xsltName.isEmpty() )
        {
            xml.append("item/oai", element); //$NON-NLS-1$

            LOGGER.info(CurrentLocale.get(KEY_PFX + "log.transform.before")); //$NON-NLS-1$
            LOGGER.info(xml.toString());

            xml.setXML(transformSchema(xml, xsltName));

            LOGGER.info(CurrentLocale.get(KEY_PFX + "log.transform.after")); //$NON-NLS-1$
            LOGGER.info(xml.toString());
        }
        else
        {
            new OAIDublinCore().processMetadataToLO(element, xml);
        }
    }
    catch( Exception e )
    {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
项目:lams    文件:AttributeValueTypeMarshaller.java   
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;

    if(attributeValue.getValue() != null){
        XMLHelper.appendTextContent(domElement, attributeValue.getValue());
    }
}
项目:Lagerta    文件:KeyValuePersistenceSettingsRegistry.java   
/**
 * Parses xml from String.
 *
 * @param xml String containing xml.
 * @return XML DOM element.
 */
private static Element parse(String xml) {
    try {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        return builder.parse(new InputSource(new StringReader(xml))).getDocumentElement();
    }
    catch (Throwable e) {
        throw new IllegalArgumentException("Failed to parse persistence settings:" +
            SystemHelper.LINE_SEPARATOR + xml, e);
    }
}
项目:jdk8u-jdk    文件:XMLSignature.java   
/**
 * Returns the KeyInfo child. If we are in signing mode and the KeyInfo
 * does not exist yet, it is created on demand and added to the Signature.
 * <br>
 * This allows to add arbitrary content to the KeyInfo during signing.
 *
 * @return the KeyInfo object
 */
public KeyInfo getKeyInfo() {
    // check to see if we are signing and if we have to create a keyinfo
    if (this.state == MODE_SIGN && this.keyInfo == null) {

        // create the KeyInfo
        this.keyInfo = new KeyInfo(this.doc);

        // get the Element from KeyInfo
        Element keyInfoElement = this.keyInfo.getElement();
        Element firstObject =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, 0
            );

        if (firstObject != null) {
            // add it before the object
            this.constructionElement.insertBefore(keyInfoElement, firstObject);
            XMLUtils.addReturnBeforeChild(this.constructionElement, firstObject);
        } else {
            // add it as the last element to the signature
            this.constructionElement.appendChild(keyInfoElement);
            XMLUtils.addReturnToElement(this.constructionElement);
        }
    }

    return this.keyInfo;
}
项目:OpenJSharp    文件:DOMKeyValue.java   
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    // create KeyValue element
    Element kvElem = DOMUtils.createElement(ownerDoc, "KeyValue",
                                            XMLSignature.XMLNS, dsPrefix);
    marshalPublicKey(kvElem, ownerDoc, dsPrefix, context);

    parent.appendChild(kvElem);
}
项目:verify-hub    文件:ExecuteAttributeQueryRequestTest.java   
@Test
public void run_shouldCallInboundMessageValidatorWithAttributeQuery() throws Exception {
    when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
    Response response = aResponse().build();
    when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);

    executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);

    verify(matchingRequestSignatureValidator).validate(attributeQuery, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
项目:kaltura-ce-sakai-extension    文件:KalturaPartnerService.java   
/**  Create a new Partner object     */
public KalturaPartner register(KalturaPartner partner, String cmsPassword, int templatePartnerId) throws KalturaApiException {
    KalturaParams kparams = new KalturaParams();
    kparams.add("partner", partner);
    kparams.add("cmsPassword", cmsPassword);
    kparams.add("templatePartnerId", templatePartnerId);
    this.kalturaClient.queueServiceCall("partner", "register", kparams);
    if (this.kalturaClient.isMultiRequest())
        return null;
    Element resultXmlElement = this.kalturaClient.doQueue();
    return ParseUtils.parseObject(KalturaPartner.class, resultXmlElement);
}
项目:jdk8u-jdk    文件:XMLCipher.java   
Element toElement() {
    Element result =
        XMLUtils.createElementInEncryptionSpace(
            contextDocument, EncryptionConstants._TAG_CIPHERDATA
        );
    if (cipherType == VALUE_TYPE) {
        result.appendChild(((CipherValueImpl) cipherValue).toElement());
    } else if (cipherType == REFERENCE_TYPE) {
        result.appendChild(((CipherReferenceImpl) cipherReference).toElement());
    }

    return result;
}
项目:OpenJSharp    文件:XSDHandler.java   
/**
 * Extract location information from an Element node, and create a
 * new SimpleLocator object from such information. Returning null means
 * no information can be retrieved from the element.
 */
public SimpleLocator element2Locator(Element e) {
    if (!( e instanceof ElementImpl))
        return null;

    SimpleLocator l = new SimpleLocator();
    return element2Locator(e, l) ? l : null;
}
项目:openjdk-jdk10    文件:SCDBasedBindingSet.java   
private Target(Target parent, Element src, SCD scd) {
    if(parent==null) {
        this.nextSibling = topLevel;
        topLevel = this;
    } else {
        this.nextSibling = parent.firstChild;
        parent.firstChild = this;
    }
    this.src = src;
    this.scd = scd;
}
项目:lams    文件:PasswordMarshaller.java   
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    Password password = (Password) xmlObject;
    if (!DatatypeHelper.isEmpty(password.getType())) {
        domElement.setAttributeNS(null, Password.TYPE_ATTRIB_NAME, password.getType());
    }
    super.marshallAttributes(xmlObject, domElement);
}
项目:bohemia    文件:XmlUtils.java   
/** 
 * Sets the namespace to specific element. 
 * 
 * @param element the element to set 
 * @param namespace the namespace to set 
 * @param schemaLocation the XML schema file location URI 
 */  
public static void setNamespace(Element element, String namespace,  
        String schemaLocation) {  
    element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,  
            XMLConstants.XMLNS_ATTRIBUTE, namespace);  
    element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLNS_XSI,  
            XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);  
    element.setAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,  
            XSI_SCHEMA_LOCATION, schemaLocation);  
}
项目:convertigo-engine    文件:ComparableFieldElement.java   
public static int getLine(Element fieldElement) throws ClassCastException {
    int line = -1;
    String fieldName = fieldElement.getAttribute("name");
    if (fieldName.indexOf(Parameter.JavelinField.getName()) != 0)
        throw new ClassCastException("[ComparableFieldElement] The object trying to be compared with is not a ComparableFieldElement.");
    String ln = fieldName.substring(fieldName.indexOf("l", 8)+1);
    line = Integer.parseInt(ln);
    return line;
}
项目:incubator-netbeans    文件:RatReportTask.java   
private void doPopulateUnapproved(Map<String, ModuleInfo> moduleRATInfo, Element rootElement, XPath path) throws XPathExpressionException {
    NodeList evaluate = (NodeList) path.evaluate("descendant::resource[license-approval/@name=\"false\"]", rootElement, XPathConstants.NODESET);
    for (int i = 0; i < evaluate.getLength(); i++) {
        String resources = relativize(evaluate.item(i).getAttributes().getNamedItem("name").getTextContent());
        String moduleName = getModuleName(resources);
        if (!moduleRATInfo.containsKey(moduleName)) {
            moduleRATInfo.get(NOT_CLUSTER).addUnapproved(resources);
        } else {
            moduleRATInfo.get(moduleName).addUnapproved(resources);
        }
    }
}