當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。