本文整理汇总了Java中org.w3c.dom.Element.getElementsByTagNameNS方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getElementsByTagNameNS方法的具体用法?Java Element.getElementsByTagNameNS怎么用?Java Element.getElementsByTagNameNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.getElementsByTagNameNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeChildElements
import org.w3c.dom.Element; //导入方法依赖的package包/类
/** Removes child elements as specified in the input collection. */
private static void removeChildElements(Element complexType, Collection<String> excludedFieldNames) {
NodeList elements = complexType.getElementsByTagNameNS(NAMESPACE_URI_XS, "element");
if (elements != null) {
for (int i = 0; i < elements.getLength(); i++) {
Node element = elements.item(i);
if (element != null && element.getNodeType() == Node.ELEMENT_NODE) {
String elementName = ((Element) element).getAttribute("name");
if (excludedFieldNames.contains(elementName)) {
element.getParentNode().removeChild(element);
--i;
}
}
}
}
}
示例2: list
import org.w3c.dom.Element; //导入方法依赖的package包/类
private Collection<String> list(String elementName) throws DOMException {
Element dom = findRelative(path, false);
if (dom == null) {
return Collections.emptyList();
}
List<String> names = new LinkedList<String>();
NodeList nl = dom.getElementsByTagNameNS(NAMESPACE, elementName);
for (int cntr = 0; cntr < nl.getLength(); cntr++) {
Node n = nl.item(cntr);
names.add(((Element) n).getAttribute(ATTR_NAME));
}
return names;
}
示例3: parse
import org.w3c.dom.Element; //导入方法依赖的package包/类
public WSDLDocument parse() throws SAXException, IOException {
// parse external binding files
for (InputSource value : options.getWSDLBindings()) {
errReceiver.pollAbort();
Document root = forest.parse(value, false);
if(root==null) continue; // error must have been reported
Element binding = root.getDocumentElement();
if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS)
|| !binding.getLocalName().equals("bindings")){
errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE(
binding.getNamespaceURI(),
binding.getLocalName()));
continue;
}
NodeList nl = binding.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chains");
for(int i = 0; i < nl.getLength(); i++){
options.addHandlerChainConfiguration((Element) nl.item(i));
}
}
return buildWSDLDocument();
}
示例4: newEncryptionProperties
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* @param element
* @return a new EncryptionProperties
*/
EncryptionProperties newEncryptionProperties(Element element) {
EncryptionProperties result = newEncryptionProperties();
result.setId(element.getAttributeNS(null, EncryptionConstants._ATT_ID));
NodeList encryptionPropertyList =
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_ENCRYPTIONPROPERTY);
for (int i = 0; i < encryptionPropertyList.getLength(); i++) {
Node n = encryptionPropertyList.item(i);
if (null != n) {
result.addEncryptionProperty(newEncryptionProperty((Element) n));
}
}
return result;
}
示例5: parse
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Parses the given document and add it to the DOM forest.
*
* @return null if there was a parse error. otherwise non-null.
*/
private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{
Document dom = documentBuilder.newDocument();
systemId = normalizeSystemId(systemId);
// put into the map before growing a tree, to
// prevent recursive reference from causing infinite loop.
core.put(systemId, dom);
dom.setDocumentURI(systemId);
if (root)
rootDocuments.add(systemId);
try {
XMLReader reader = createReader(dom);
InputStream is = null;
if(inputSource.getByteStream() == null){
inputSource = entityResolver.resolveEntity(null, systemId);
}
reader.parse(inputSource);
Element doc = dom.getDocumentElement();
if (doc == null) {
return null;
}
NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema");
for (int i = 0; i < schemas.getLength(); i++) {
inlinedSchemaElements.add((Element) schemas.item(i));
}
} catch (ParserConfigurationException e) {
errorReceiver.error(e);
throw new SAXException(e.getMessage());
}
resolvedCache.put(systemId, dom.getDocumentURI());
return dom;
}
示例6: readGroups
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void readGroups(NodeList configFileGroupEls, File basedir, List<ConfigFileGroup> groups) {
for (int i = 0; i < configFileGroupEls.getLength(); i++) {
Element configFileGroupEl = (Element)configFileGroupEls.item(i);
String name = configFileGroupEl.getAttribute(NAME);
NodeList configFileEls = configFileGroupEl.getElementsByTagNameNS(SPRING_DATA_NS, CONFIG_FILE);
List<File> configFiles = new ArrayList<File>(configFileEls.getLength());
readFiles(configFileEls, basedir, configFiles);
groups.add(ConfigFileGroup.create(name, configFiles));
}
}
示例7: getOpenFilesUrls
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Set<String> getOpenFilesUrls(Project p, String groupName) {
AuxiliaryConfiguration aux = ProjectUtils.getAuxiliaryConfiguration(p);
Element openFiles = aux.getConfigurationFragment (OPEN_FILES_ELEMENT, OPEN_FILES_NS2, false);
if (openFiles == null) {
return Collections.emptySet();
}
Element groupEl = null;
NodeList groups = openFiles.getElementsByTagNameNS(OPEN_FILES_NS2, GROUP_ELEMENT);
for (int i = 0; i < groups.getLength(); i++) {
Element g = (Element) groups.item(i);
String attr = g.getAttribute(NAME_ATTR);
if (attr.equals(groupName) || (attr.equals("") && groupName == null)) {
groupEl = g;
break;
}
}
if (groupEl == null) {
return Collections.emptySet();
}
NodeList list = groupEl.getElementsByTagNameNS(OPEN_FILES_NS2, FILE_ELEMENT);
Set<String> toRet = new HashSet<String>();
for (int i = 0; i < list.getLength (); i++) {
String url = list.item (i).getChildNodes ().item (0).getNodeValue ();
toRet.add(url);
}
return toRet;
}
示例8: readActiveConfigurationName
import org.w3c.dom.Element; //导入方法依赖的package包/类
public static String readActiveConfigurationName(AuxiliaryConfiguration config) throws DOMException {
String active = null;
Element el = config.getConfigurationFragment(ROOT, NAMESPACE, false);
if (el != null) {
NodeList list = el.getElementsByTagNameNS(NAMESPACE, ACTIVATED);
if (list.getLength() > 0) {
Element enEl = (Element)list.item(0);
active = enEl.getTextContent();
}
}
return active;
}
示例9: load
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* load the info from FS for this Dav resouce.
*/
public final void load() {
this.metaFile.load();
/*
* Analyze JSON Object, and set metadata such as ACL.
*/
this.name = fsDir.getName();
this.acl = this.translateAcl(this.metaFile.getAcl());
@SuppressWarnings("unchecked")
Map<String, String> props = (Map<String, String>) this.metaFile.getProperties();
if (props != null) {
for (Map.Entry<String, String> entry : props.entrySet()) {
String key = entry.getKey();
String val = entry.getValue();
int idx = key.indexOf("@");
String elementName = key.substring(0, idx);
String namespace = key.substring(idx + 1);
QName keyQName = new QName(namespace, elementName);
Element element = parseProp(val);
String elementNameSpace = element.getNamespaceURI();
// ownerRepresentativeAccountsの取り出し
if (Key.PROP_KEY_OWNER_REPRESENTIVE_ACCOUNTS.equals(keyQName)) {
NodeList accountNodeList = element.getElementsByTagNameNS(elementNameSpace,
Key.PROP_KEY_OWNER_REPRESENTIVE_ACCOUNT.getLocalPart());
for (int i = 0; i < accountNodeList.getLength(); i++) {
this.ownerRepresentativeAccounts.add(accountNodeList.item(i).getTextContent().trim());
}
}
}
}
}
示例10: isSign
import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isSign(final byte[] sign) {
if (sign == null) {
LOGGER.warning("Se han introducido datos nulos para su comprobacion"); //$NON-NLS-1$
return false;
}
try {
// Carga el documento a validar
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
// JXades no captura un nodo de firma si se pasa este como raiz del arbol de firmas, asi
// que nos vemos obligados a crear un nodo padre, del que colgara todo el arbol de firmas,
// para que lo detecte correctamente
final Element rootNode = dbf.newDocumentBuilder().parse(
new ByteArrayInputStream(sign)
).getDocumentElement();
final List<Node> signNodes = new ArrayList<Node>();
if (rootNode.getNodeName().equals(SIGNATURE_NODE_NAME)) {
signNodes.add(rootNode);
}
final NodeList signatures = rootNode.getElementsByTagNameNS(DSIGNNS, SIGNATURE_TAG);
for (int i = 0; i < signatures.getLength(); i++) {
signNodes.add(signatures.item(i));
}
// Si no se encuentran firmas, no es un documento de firma (obviamos si son XAdES o no)
if (signNodes.size() == 0) {
return false;
}
}
catch (final Exception e) {
return false;
}
return true;
}
示例11: getSchemaImport
import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Element getSchemaImport(Element schemaElement, String namespace) {
if (schemaElement != null) {
NodeList imports = schemaElement.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "import");
for (int i=0; i<imports.getLength(); i++) {
Element importElement = (Element)imports.item(i);
if (namespace.equals((importElement).getAttribute("namespace"))) {
return importElement;
}
}
}
return null;
}
示例12: load
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Loads a configuration after it's been schema validated.
*
* @param configurationRoot root of the configuration
*
* @throws ConfigurationException thrown if there is a problem processing the configuration
*/
protected void load(Element configurationRoot) throws ConfigurationException {
// Initialize object providers
NodeList objectProviders = configurationRoot.getElementsByTagNameNS(XMLConstants.XMLTOOLING_CONFIG_NS,
"ObjectProviders");
if (objectProviders.getLength() > 0) {
log.debug("Preparing to load ObjectProviders");
initializeObjectProviders((Element) objectProviders.item(0));
log.debug("ObjectProviders load complete");
}
// Initialize validator suites
NodeList validatorSuitesNodes = configurationRoot.getElementsByTagNameNS(XMLConstants.XMLTOOLING_CONFIG_NS,
"ValidatorSuites");
if (validatorSuitesNodes.getLength() > 0) {
log.debug("Preparing to load ValidatorSuites");
initializeValidatorSuites((Element) validatorSuitesNodes.item(0));
log.debug("ValidatorSuites load complete");
}
// Initialize ID attributes
NodeList idAttributesNodes = configurationRoot.getElementsByTagNameNS(XMLConstants.XMLTOOLING_CONFIG_NS,
"IDAttributes");
if (idAttributesNodes.getLength() > 0) {
log.debug("Preparing to load IDAttributes");
initializeIDAttributes((Element) idAttributesNodes.item(0));
log.debug("IDAttributes load complete");
}
}
示例13: createOrGetUseSdk
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static XmlElement createOrGetUseSdk(
ActionRecorder actionRecorder, XmlDocument document) {
Element manifest = document.getXml().getDocumentElement();
NodeList usesSdks = manifest
.getElementsByTagName(ManifestModel.NodeTypes.USES_SDK.toXmlName());
if (usesSdks.getLength() == 0) {
usesSdks = manifest
.getElementsByTagNameNS(
SdkConstants.ANDROID_URI,
ManifestModel.NodeTypes.USES_SDK.toXmlName());
}
if (usesSdks.getLength() == 0) {
// create it first.
Element useSdk = manifest.getOwnerDocument().createElement(
ManifestModel.NodeTypes.USES_SDK.toXmlName());
manifest.appendChild(useSdk);
XmlElement xmlElement = new XmlElement(useSdk, document);
Actions.NodeRecord nodeRecord = new Actions.NodeRecord(
Actions.ActionType.INJECTED,
new Actions.ActionLocation(xmlElement.getSourceLocation(),
PositionImpl.UNKNOWN),
xmlElement.getId(),
"use-sdk injection requested",
NodeOperationType.STRICT);
actionRecorder.recordNodeAction(xmlElement, nodeRecord);
return xmlElement;
} else {
return new XmlElement((Element) usesSdks.item(0), document);
}
}
示例14: identifyRootWsdls
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Identifies WSDL documents from the {@link DOMForest}. Also identifies the root wsdl document.
*/
private void identifyRootWsdls(){
for(String location: rootDocuments){
Document doc = get(location);
if(doc!=null){
Element definition = doc.getDocumentElement();
if(definition == null || definition.getLocalName() == null || definition.getNamespaceURI() == null)
continue;
if(definition.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && definition.getLocalName().equals("definitions")){
rootWsdls.add(location);
//set the root wsdl at this point. Root wsdl is one which has wsdl:service in it
NodeList nl = definition.getElementsByTagNameNS(WSDLConstants.NS_WSDL, "service");
//TODO:what if there are more than one wsdl with wsdl:service element. Probably such cases
//are rare and we will take any one of them, this logic should still work
if(nl.getLength() > 0)
rootWSDL = location;
}
}
}
//no wsdl with wsdl:service found, throw error
if(rootWSDL == null){
StringBuilder strbuf = new StringBuilder();
for(String str : rootWsdls){
strbuf.append(str);
strbuf.append('\n');
}
errorReceiver.error(null, WsdlMessages.FAILED_NOSERVICE(strbuf.toString()));
}
}
示例15: writeHandlerConfig
import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
if (e == null) {
return;
}
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
handlerChainAnn.param("file", fName);
generateHandlerChainFile(e, className);
}
}