本文整理了Java中org.w3c.dom.Element.setPrefix()
方法的一些代码示例,展示了Element.setPrefix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setPrefix()
方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:setPrefix
暂无
代码示例来源:origin: robovm/robovm
element.setPrefix(prefix);
node.appendChild(element);
代码示例来源:origin: stackoverflow.com
String namespace = "http://com";
String prefix = "ns2";
// Upgrade the DOM level 1 to level 2 with the correct namespace
Element originalDocumentElement = document.getDocumentElement();
Element newDocumentElement = document.createElementNS(namespace, originalDocumentElement.getNodeName());
// Set the desired namespace and prefix
newDocumentElement.setPrefix(prefix);
// Copy all children
NodeList list = originalDocumentElement.getChildNodes();
while(list.getLength()!=0) {
newDocumentElement.appendChild(list.item(0));
}
// Replace the original element
document.replaceChild(newDocumentElement, originalDocumentElement);
代码示例来源:origin: axis/axis
/**
* Get the Types element for the WSDL document. If not present, create one
*/
private void writeWsdlTypesElement() {
if (wsdlTypesElem == null) {
// Create a <wsdl:types> element corresponding to the wsdl namespaces.
wsdlTypesElem = docHolder.createElementNS(Constants.NS_URI_WSDL11,
"types");
wsdlTypesElem.setPrefix(Constants.NS_PREFIX_WSDL);
}
}
代码示例来源:origin: org.apache.axis/axis
/**
* Get the Types element for the WSDL document. If not present, create one
*/
private void writeWsdlTypesElement() {
if (wsdlTypesElem == null) {
// Create a <wsdl:types> element corresponding to the wsdl namespaces.
wsdlTypesElem = docHolder.createElementNS(Constants.NS_URI_WSDL11,
"types");
wsdlTypesElem.setPrefix(Constants.NS_PREFIX_WSDL);
}
}
代码示例来源:origin: kohsuke/msv
public void onElement( Element e ) {
String uri = nullAdjust(e.getNamespaceURI());
if( uri.equals(defaultNs) )
; // don't touch
else
e.setPrefix((String)uri2prefix.get(uri));
}
public void onAttr( Attr a ) {
代码示例来源:origin: org.n52.security/52n-security-core
public void preVisit(final Element element) {
String currentNamespace =
m_currentNamespaceStack.isEmpty() ? null : (String) m_currentNamespaceStack.getFirst();
if (currentNamespace == null || !currentNamespace.equals(element.getNamespaceURI())) {
currentNamespace = element.getNamespaceURI();
element.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, currentNamespace);
}
element.setPrefix(XMLConstants.DEFAULT_NS_PREFIX);
m_currentNamespaceStack.addFirst(currentNamespace);
}
代码示例来源:origin: com.kloudtek.ktutils/ktutils
public static Element createNSElement(final String name, final String namespace, String prefix, final Node parent, final Object... attrs) {
final Document doc = parent instanceof Document ? (Document) parent : parent.getOwnerDocument();
final Element element = doc.createElementNS(namespace != null ? namespace : parent.getNamespaceURI(), name);
if (prefix != null) {
element.setPrefix(prefix);
} else if (parent.getPrefix() != null) {
element.setPrefix(parent.getPrefix());
}
setAttributes(element, attrs);
parent.appendChild(element);
return element;
}
代码示例来源:origin: com.kloudtek.ktutils/ktutils-core
public static Element createNSElement(final String name, final String namespace, String prefix, final Node parent, final Object... attrs) {
final Document doc = parent instanceof Document ? (Document) parent : parent.getOwnerDocument();
final Element element = doc.createElementNS(namespace != null ? namespace : parent.getNamespaceURI(), name);
if (prefix != null) {
element.setPrefix(prefix);
} else if (parent.getPrefix() != null) {
element.setPrefix(parent.getPrefix());
}
setAttributes(element, attrs);
parent.appendChild(element);
return element;
}
代码示例来源:origin: com.kloudtek.ktutils/ktutils-xml
public static Element createNSElement(final String name, final String namespace, String prefix, final Node parent, final Object... attrs) {
final Document doc = parent instanceof Document ? (Document) parent : parent.getOwnerDocument();
final Element element = doc.createElementNS(namespace != null ? namespace : parent.getNamespaceURI(), name);
if (prefix != null) {
element.setPrefix(prefix);
} else if (parent.getPrefix() != null) {
element.setPrefix(parent.getPrefix());
}
setAttributes(element, attrs);
parent.appendChild(element);
return element;
}
代码示例来源:origin: net.java.xades/jxades
protected Element createElement(String elementName)
{
Element element = getDocument().createElementNS(xadesNamespace, elementName);
element.setPrefix(xadesPrefix);
return element;
}
代码示例来源:origin: org.opensingular/singular-commons
/**
* @see org.w3c.dom.Node#setPrefix(String)
*/
@Override
public void setPrefix(String arg0) {
original.get().setPrefix(arg0);
}
代码示例来源:origin: org.opensingular/form-core
/**
* @see org.w3c.dom.Node#setPrefix(String)
*/
public void setPrefix(String arg0) throws DOMException {
getAtualInterno().setPrefix(arg0);
}
代码示例来源:origin: org.opensingular/form-core
/**
* @see org.w3c.dom.Node#setPrefix(String)
*/
@Override
public void setPrefix(String arg0) {
original.get().setPrefix(arg0);
}
代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS(null, "test");
try {
element.setPrefix("p");
fail("Expected DOMException");
} catch (DOMException ex) {
assertEquals(DOMException.NAMESPACE_ERR, ex.code);
}
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS("urn:ns", "p:test");
element.setPrefix(null);
assertNull(element.getPrefix());
assertEquals("test", element.getTagName());
// DOM doesn't add namespace declarations automatically
assertEquals(0, element.getAttributes().getLength());
}
}
代码示例来源:origin: org.ojbc.bundles.connectors/ojb-web-application-connector
public static Document createSubscriptionSearchRequest() throws Exception {
Document doc = OJBCXMLUtils.createDocument();
Element root = doc.createElementNS(OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_REQUEST, "SubscriptionSearchRequest");
doc.appendChild(root);
root.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUBSCRIPTION_SEARCH_REQUEST);
OJBC_NAMESPACE_CONTEXT.populateRootNamespaceDeclarations(root);
return doc;
}
代码示例来源:origin: org.codehaus.xfire/xfire-core
private org.w3c.dom.Element createElement(String value){
org.w3c.dom.Element elem = w3cDocument.createElementNS(WSDL11_NS, "documentation");
String prefix = getNamespacePrefix(WSDL11_NS);
elem.setPrefix(prefix);
elem.setNodeValue(value);
return elem;
}
代码示例来源:origin: apache/cxf
private void addPolicyRef(Extensible ext, Policy p) {
Document doc = DOMUtils.getEmptyDocument();
Element el = doc.createElementNS(p.getNamespace(), Constants.ELEM_POLICY_REF);
el.setPrefix(Constants.ATTR_WSP);
el.setAttribute(Constants.ATTR_URI, "#" + p.getId());
UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
uee.setElementType(new QName(p.getNamespace(), Constants.ELEM_POLICY_REF));
uee.setElement(el);
uee.setRequired(true);
ext.addExtensor(uee);
}
代码示例来源:origin: org.apache.cxf/cxf-rt-ws-policy
private void addPolicyRef(Extensible ext, Policy p) {
Document doc = DOMUtils.getEmptyDocument();
Element el = doc.createElementNS(p.getNamespace(), Constants.ELEM_POLICY_REF);
el.setPrefix(Constants.ATTR_WSP);
el.setAttribute(Constants.ATTR_URI, "#" + p.getId());
UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
uee.setElementType(new QName(p.getNamespace(), Constants.ELEM_POLICY_REF));
uee.setElement(el);
uee.setRequired(true);
ext.addExtensor(uee);
}
代码示例来源:origin: stackoverflow.com
Element usernameElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Username");
usernameElement.addChild(Node.TEXT, username);
Element passwordElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Password");
passwordElement.addChild(Node.TEXT, password);
Element usernameTokenElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "UsernameToken");
usernameTokenElement.addChild(Node.ELEMENT, usernameElement);
usernameTokenElement.addChild(Node.ELEMENT, passwordElement);
Element securityElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Security");
securityElement.setPrefix(null, OASIS_SECURITY_XSD_URL);
securityElement.addChild(Node.ELEMENT, usernameTokenElement);
内容来源于网络,如有侵权,请联系作者删除!