当前位置: 首页>>代码示例>>Java>>正文


Java Document.createElementNS方法代码示例

本文整理汇总了Java中org.w3c.dom.Document.createElementNS方法的典型用法代码示例。如果您正苦于以下问题:Java Document.createElementNS方法的具体用法?Java Document.createElementNS怎么用?Java Document.createElementNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Document的用法示例。


在下文中一共展示了Document.createElementNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrapWithSoapEnvelope

import org.w3c.dom.Document; //导入方法依赖的package包/类
public Document wrapWithSoapEnvelope(Element element) {
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        LOG.error("*** ALERT: Failed to create a document builder when trying to construct the the soap message. ***", e);
        throw propagate(e);
    }
    Document document = documentBuilder.newDocument();
    document.adoptNode(element);
    Element envelope = document.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Envelope");
    Element body = document.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Body");
    envelope.appendChild(body);
    body.appendChild(element);
    document.appendChild(envelope);

    return document;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:SoapMessageManager.java

示例2: features

import org.w3c.dom.Document; //导入方法依赖的package包/类
public static final NodeList features(ExpressionContext ctx) {
    NodeSet result = new NodeSet();
    Node node = ctx.getContextNode();
    Element elt = getElement(node);
    if (elt != null) {
        Document doc = node.getOwnerDocument();
        for (String name : elt.getFeatureKeys()) {
            for (String value : elt.getFeature(name)) {
                org.w3c.dom.Element e = doc.createElementNS(ALVISNLP_PROXY_NAMESPACE_URI, "feature");
                e.setAttribute("name", name);
                e.setAttribute("value", value);
                result.addElement(e);
            }
        }
    }
    return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:18,代码来源:XMLWriter2ForINIST.java

示例3: createElementForFamily

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * This method creates an Element in a given namespace with a given localname.
 * It uses the {@link ElementProxy#getDefaultPrefix} method to decide whether
 * a particular prefix is bound to that namespace.
 * <BR />
 * This method was refactored out of the constructor.
 *
 * @param doc
 * @param namespace
 * @param localName
 * @return The element created.
 */
public static Element createElementForFamily(Document doc, String namespace, String localName) {
    Element result = null;
    String prefix = ElementProxy.getDefaultPrefix(namespace);

    if (namespace == null) {
        result = doc.createElementNS(null, localName);
    } else {
        if ((prefix == null) || (prefix.length() == 0)) {
            result = doc.createElementNS(namespace, localName);
            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
        } else {
            result = doc.createElementNS(namespace, prefix + ":" + localName);
            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, namespace);
        }
    }

    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ElementProxy.java

示例4: determineEndpointReference

import org.w3c.dom.Document; //导入方法依赖的package包/类
private EndpointReference determineEndpointReference(String serviceName)
        throws ParserConfigurationException {
    Document doc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().newDocument();
    Element eprNode = doc.createElementNS(
            "http://www.w3.org/2005/08/addressing", "EndpointReference");
    Element addressNode = doc.createElement("Address");
    Element metadataNode = doc.createElement("Metadata");
    String wsdlURL = remoteWSDLUrl.replace("{service}", serviceName);
    addressNode.setTextContent(wsdlURL);
    doc.appendChild(eprNode);
    eprNode.appendChild(addressNode);
    eprNode.appendChild(metadataNode);
    EndpointReference epr = EndpointReference.readFrom(new DOMSource(doc));
    return epr;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:ServiceFactory.java

示例5: createElementForFamilyLocal

import org.w3c.dom.Document; //导入方法依赖的package包/类
protected Element createElementForFamilyLocal(
    Document doc, String namespace, String localName
) {
    Element result = null;
    if (namespace == null) {
        result = doc.createElementNS(null, localName);
    } else {
        String baseName = this.getBaseNamespace();
        String prefix = ElementProxy.getDefaultPrefix(baseName);
        if ((prefix == null) || (prefix.length() == 0)) {
            result = doc.createElementNS(namespace, localName);
            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
        } else {
            result = doc.createElementNS(namespace, prefix + ":" + localName);
            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, namespace);
        }
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:ElementProxy.java

示例6: generateEmptyModuleTemplate

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Generates a basic <em>project.xml</em> templates into the given
 * <code>projectXml</code> for <em>standalone</em> or <em>module in
 * suite</em> module.
 */
static void generateEmptyModuleTemplate(FileObject projectXml, String cnb,
        NbModuleType moduleType, String... compileDepsCnbs) throws IOException {

    Document prjDoc = XMLUtil.createDocument("project", PROJECT_NS, null, null); // NOI18N

    // generate general project elements
    Element typeEl = prjDoc.createElementNS(PROJECT_NS, "type"); // NOI18N
    typeEl.appendChild(prjDoc.createTextNode(NbModuleProject.TYPE));
    prjDoc.getDocumentElement().appendChild(typeEl);
    Element confEl = prjDoc.createElementNS(PROJECT_NS, "configuration"); // NOI18N
    prjDoc.getDocumentElement().appendChild(confEl);

    // generate NB Module project type specific elements
    Element dataEl = createModuleElement(confEl.getOwnerDocument(), DATA);
    confEl.appendChild(dataEl);
    Document dataDoc = dataEl.getOwnerDocument();
    dataEl.appendChild(createModuleElement(dataDoc, CODE_NAME_BASE, cnb));
    Element moduleTypeEl = createTypeElement(dataDoc, moduleType);
    if (moduleTypeEl != null) {
        dataEl.appendChild(moduleTypeEl);
    }
    final Element deps = createModuleElement(dataDoc, MODULE_DEPENDENCIES);
    for (String depCnb : compileDepsCnbs) {
        Element modDepEl = createModuleElement(dataDoc, ProjectXMLManager.DEPENDENCY);
        modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.CODE_NAME_BASE, depCnb));
        modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.BUILD_PREREQUISITE));
        modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.COMPILE_DEPENDENCY));
        deps.appendChild(modDepEl);
    }
    dataEl.appendChild(deps);
    dataEl.appendChild(createModuleElement(dataDoc, PUBLIC_PACKAGES));

    // store document to disk
    ProjectXMLManager.safelyWrite(projectXml, prjDoc);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:ProjectXMLManager.java

示例7: createDSctx

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Method createDSctx
 *
 * @param doc
 * @param prefix
 * @param namespace
 * @return the element.
 */
public static Element createDSctx(Document doc, String prefix, String namespace) {
    if ((prefix == null) || (prefix.trim().length() == 0)) {
        throw new IllegalArgumentException("You must supply a prefix");
    }

    Element ctx = doc.createElementNS(null, "namespaceContext");

    ctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix.trim(), namespace);

    return ctx;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:XMLUtils.java

示例8: createElementInSignatureSpace

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Creates an Element in the XML Signature specification namespace.
 *
 * @param doc the factory Document
 * @param elementName the local name of the Element
 * @return the Element
 */
public static Element createElementInSignatureSpace(Document doc, String elementName) {
    if (doc == null) {
        throw new RuntimeException("Document is null");
    }

    if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
        return doc.createElementNS(Constants.SignatureSpecNS, elementName);
    }
    return doc.createElementNS(Constants.SignatureSpecNS, dsPrefix + ":" + elementName);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:XMLUtils.java

示例9: begin

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Implemented to replace the content handler currently in use by a 
 * NodeBuilder.
 * 
 * @param namespaceURI the namespace URI of the matching element, or an 
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just 
 *   the element name otherwise
 * @param attributes The attribute list of this element
 * @throws Exception indicates a JAXP configuration problem
 */
@Override
public void begin(String namespaceURI, String name, Attributes attributes)
    throws Exception {

    XMLReader xmlReader = getDigester().getXMLReader();
    Document doc = documentBuilder.newDocument();
    NodeBuilder builder = null;
    if (nodeType == Node.ELEMENT_NODE) {
        Element element = null;
        if (getDigester().getNamespaceAware()) {
            element =
                doc.createElementNS(namespaceURI, name);
            for (int i = 0; i < attributes.getLength(); i++) {
                element.setAttributeNS(attributes.getURI(i),
                                       attributes.getLocalName(i),
                                       attributes.getValue(i));
            }
        } else {
            element = doc.createElement(name);
            for (int i = 0; i < attributes.getLength(); i++) {
                element.setAttribute(attributes.getQName(i),
                                     attributes.getValue(i));
            }
        }
        builder = new NodeBuilder(doc, element);
    } else {
        builder = new NodeBuilder(doc, doc.createDocumentFragment());
    }
    xmlReader.setContentHandler(builder);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:44,代码来源:NodeCreateRule.java

示例10: createElementInSignature11Space

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Creates an Element in the XML Signature 1.1 specification namespace.
 *
 * @param doc the factory Document
 * @param elementName the local name of the Element
 * @return the Element
 */
public static Element createElementInSignature11Space(Document doc, String elementName) {
    if (doc == null) {
        throw new RuntimeException("Document is null");
    }

    if ((ds11Prefix == null) || (ds11Prefix.length() == 0)) {
        return doc.createElementNS(Constants.SignatureSpec11NS, elementName);
    }
    return doc.createElementNS(Constants.SignatureSpec11NS, ds11Prefix + ":" + elementName);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:XMLUtils.java

示例11: main

import org.w3c.dom.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    KeyInfoFactory fac = KeyInfoFactory.getInstance();
    KeyInfo ki = fac.newKeyInfo
        (Collections.singletonList(fac.newKeyName("foo")), "keyid");
    try {
        ki.marshal(null, null);
        throw new Exception("Should raise a NullPointerException");
    } catch (NullPointerException npe) {}

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document doc = dbf.newDocumentBuilder().newDocument();
    Element elem = doc.createElementNS("http://acme.org", "parent");
    doc.appendChild(elem);
    DOMStructure parent = new DOMStructure(elem);
    ki.marshal(parent, null);

    Element kiElem = DOMUtils.getFirstChildElement(elem);
    if (!kiElem.getLocalName().equals("KeyInfo")) {
        throw new Exception
            ("Should be KeyInfo element: " + kiElem.getLocalName());
    }
    Element knElem = DOMUtils.getFirstChildElement(kiElem);
    if (!knElem.getLocalName().equals("KeyName")) {
        throw new Exception
            ("Should be KeyName element: " + knElem.getLocalName());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:Marshal.java

示例12: getElementProxy

import org.w3c.dom.Document; //导入方法依赖的package包/类
private static org.w3c.dom.Element getElementProxy(Document doc, Element element) {
        org.w3c.dom.Element result = doc.createElementNS(ALVISNLP_PROXY_NAMESPACE_URI, "element");
//		System.err.println("elt: " + element + ", proxy: " + result);
        for (String name : element.getFeatureKeys()) {
            result.setAttribute(name, element.getLastFeature(name));
        }
        result.setUserData(ELEMENT_USER_DATA, element, null);
        return result;
    }
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:10,代码来源:XMLWriter2ForINIST.java

示例13: createModuleElement

import org.w3c.dom.Document; //导入方法依赖的package包/类
private static Element createModuleElement(Document doc, String name) {
    return doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, name);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ProjectXMLManager.java

示例14: getTestElement

import org.w3c.dom.Document; //导入方法依赖的package包/类
private Element getTestElement() throws ParserConfigurationException {
    DocumentBuilder documentBuilder = XmlUtils.newDocumentBuilder();
    Document document = documentBuilder.newDocument();
    return document.createElementNS("urn:oasis:names:tc:SAML:2.0:protocol", "samlp:Response");
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:6,代码来源:SoapMessageManagerTest.java

示例15: makeUserElement

import org.w3c.dom.Document; //导入方法依赖的package包/类
private Node makeUserElement ( final Document doc, final UserInformation userInformation )
{
    final Element user = doc.createElementNS ( NAMESPACE, "request:user" );
    user.setAttributeNS ( NAMESPACE, "request:name", userInformation.getName () );
    return user;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:SignatureRequestBuilder.java


注:本文中的org.w3c.dom.Document.createElementNS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。