本文整理了Java中org.w3c.dom.Element.getAttributeNS()
方法的一些代码示例,展示了Element.getAttributeNS()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributeNS()
方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:getAttributeNS
[英]Retrieves an attribute value by local name and namespace URI.
Per [XML Namespaces] , applications must use the value null
as the namespaceURI
parameter for methods if they wish to have no namespace.
[中]按本地名称和命名空间URI检索属性值。
根据[{$0$}],如果应用程序希望没有命名空间,则必须将值null
用作方法的namespaceURI
参数。
代码示例来源:origin: spring-projects/spring-security
private boolean matchesVersionInternal(Element element) {
String schemaLocation = element.getAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
return schemaLocation.matches("(?m).*spring-security-4\\.2.*.xsd.*")
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
|| !schemaLocation.matches("(?m).*spring-security.*");
}
代码示例来源:origin: spring-projects/spring-batch
private static boolean matchesVersionInternal(Element element) {
String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
return schemaLocation.matches("(?m).*spring-batch-3.0.xsd.*")
|| schemaLocation.matches("(?m).*spring-batch-2.2.xsd.*")
|| schemaLocation.matches("(?m).*spring-batch.xsd.*")
|| !schemaLocation.matches("(?m).*spring-batch.*");
}
代码示例来源:origin: robolectric/robolectric
public String getAttribute(String namespace, String name) {
if (currentNode == null) {
return null;
}
Element element = (Element) currentNode;
if (element.hasAttributeNS(namespace, name)) {
return element.getAttributeNS(namespace, name).trim();
} else if (applicationNamespace.equals(namespace)
&& element.hasAttributeNS(AttributeResource.RES_AUTO_NS_URI, name)) {
return element.getAttributeNS(AttributeResource.RES_AUTO_NS_URI, name).trim();
}
return null;
}
代码示例来源:origin: spotbugs/spotbugs
@ExpectWarning("RCN")
public static boolean check2(Element e) {
if (e.getAttributeNS("x", "y") == null)
return true;
return false;
}
}
代码示例来源:origin: plutext/docx4j
protected String getLocalAttribute(String attrName) {
return getElement().getAttributeNS(null, attrName);
}
代码示例来源:origin: TeamNewPipe/NewPipe
attr = node.getAttributeNS(formatVersion, formatAttr);
if (attr == null) {
throw new ParseException("Can't get the format attribute", -1);
int tmp = Integer.parseInt(((Element) node_list.item(i)).getAttributeNS(formatVersion, "ah"));
if (tmp > line_break) {
line_break = tmp;
代码示例来源:origin: plutext/docx4j
String algorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
代码示例来源:origin: plutext/docx4j
Object exArgs[] = { ns, getElement().getAttributeNS(null, ns) };
代码示例来源:origin: robovm/robovm
String uri = element.getAttributeNS(
"http://www.w3.org/XML/1998/namespace", "base"); // or "xml:base"
代码示例来源:origin: org.springframework.security/spring-security-config
private boolean matchesVersionInternal(Element element) {
String schemaLocation = element.getAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
return schemaLocation.matches("(?m).*spring-security-4\\.2.*.xsd.*")
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
|| !schemaLocation.matches("(?m).*spring-security.*");
}
代码示例来源:origin: spring-projects/spring-integration
private static boolean matchesVersion(Element element) {
String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
return !StringUtils.hasText(schemaLocation) // no namespace on this element
|| schemaLocation.matches("(?m).*spring-integration-[a-z-]*" + VERSION + ".xsd.*") // correct version
|| schemaLocation.matches("(?m).*spring-integration[a-z-]*.xsd.*") // version-less schema
|| !schemaLocation.matches("(?m).*spring-integration.*"); // no spring-integration schemas
}
代码示例来源:origin: jamesagnew/hapi-fhir
private Element findSheetByName(String spreadsheetName, String wantedName, Document file, boolean theFailIfNotFound) throws Exception {
Element retVal = null;
for (int i = 0; i < file.getElementsByTagName("Worksheet").getLength() && retVal == null; i++) {
retVal = (Element) file.getElementsByTagName("Worksheet").item(i);
if (!wantedName.equals(retVal.getAttributeNS("urn:schemas-microsoft-com:office:spreadsheet", "Name"))) {
retVal = null;
}
}
if (retVal == null && theFailIfNotFound) {
throw new Exception("Failed to find worksheet with name '" + wantedName + "' in spreadsheet: " + spreadsheetName);
}
return retVal;
}
代码示例来源:origin: jamesagnew/hapi-fhir
private void processCol(Element col) {
String width = col.getAttributeNS("urn:schemas-microsoft-com:office:spreadsheet", "Width");
if (!Utilities.noString(width)) {
Double d = Double.valueOf(width);
width = Double.toString(Math.round(d*2)/2);
col.setAttributeNS("urn:schemas-microsoft-com:office:spreadsheet", "ss:Width", width);
}
}
代码示例来源:origin: mulesoft/mule
private void addNamespaceDeclarationIfNeeded(String prefix, String namespaceURI, String schemaLocation) {
if (isBlank(doc.getDocumentElement().getAttributeNS(XMLNS_ATTRIBUTE_NAMESPACE, XMLNS + prefix))) {
doc.getDocumentElement().setAttributeNS(XMLNS_ATTRIBUTE_NAMESPACE, XMLNS + prefix, namespaceURI);
addSchemaLocationIfNeeded(namespaceURI, schemaLocation);
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
private void processRow(Element row) {
String height = row.getAttributeNS("urn:schemas-microsoft-com:office:spreadsheet", "Height");
if (!Utilities.noString(height) && height.contains(".")) {
Double d = Double.valueOf(height);
row.setAttributeNS("urn:schemas-microsoft-com:office:spreadsheet", "ss:Height", Long.toString(Math.round(d)));
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
public Type makeTypeFromANY(Element e) throws Exception {
if (e == null)
return null;
String t = e.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "type");
if (Utilities.noString(t))
throw new Exception("Missing type on RIM attribute with type any");
if (t.equals("CD") || t.equals("CE"))
return makeCodeableConceptFromCD(e);
else if (t.equals("ST"))
return makeStringFromED(e);
else
throw new Exception("Not done yet (type = "+t+")");
}
代码示例来源:origin: camunda/camunda-bpm-platform
public String getAttribute(String namespaceUri, String localName) {
synchronized(document) {
XmlQName xmlQName = new XmlQName(this, namespaceUri, localName);
String value;
if (xmlQName.hasLocalNamespace()) {
value = element.getAttributeNS(null, xmlQName.getLocalName());
}
else {
value = element.getAttributeNS(xmlQName.getNamespaceUri(), xmlQName.getLocalName());
}
if (value.isEmpty()) {
return null;
}
else {
return value;
}
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
private Row readRow(Element row) throws DOMException, FHIRException {
Row res = new Row();
int ndx = 1;
NodeList cells = row.getElementsByTagNameNS(XLS_NS, "Cell");
for (int i = 0; i < cells.getLength(); i++) {
Element cell = (Element) cells.item(i);
if (cell.hasAttributeNS(XLS_NS, "Index")) {
int index = Integer.parseInt(cell.getAttributeNS(XLS_NS, "Index"));
while (ndx < index) {
res.add("");
ndx++;
}
}
res.add(readData(cell, ndx, res.size() > 0 ? res.get(0) : "?"));
ndx++;
}
return res;
}
代码示例来源:origin: geotools/geotools
public void testEncode() throws Exception {
Document dom = encode(GML3MockData.bounds(), GML.Envelope);
assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE, "lowerCorner").getLength());
assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE, "upperCorner").getLength());
Element lowerCorner =
(Element) dom.getElementsByTagNameNS(GML.NAMESPACE, "lowerCorner").item(0);
assertEquals("0 0", lowerCorner.getFirstChild().getNodeValue());
Element upperCorner =
(Element) dom.getElementsByTagNameNS(GML.NAMESPACE, "upperCorner").item(0);
assertEquals("10 10", upperCorner.getFirstChild().getNodeValue());
// assertEquals("urn:x-ogc:def:crs:EPSG:6.11.2:4326",
assertEquals(
"urn:x-ogc:def:crs:EPSG:4326",
dom.getDocumentElement().getAttributeNS(null, "srsName"));
}
代码示例来源:origin: geotools/geotools
public void testEncode() throws Exception {
Document doc = encode(FilterMockData.gmlObjectId(), OGC.GmlObjectId);
assertEquals("foo", doc.getDocumentElement().getAttributeNS(GML.NAMESPACE, "id"));
}
}
内容来源于网络,如有侵权,请联系作者删除!