本文整理匯總了Java中org.w3c.dom.Attr.getPrefix方法的典型用法代碼示例。如果您正苦於以下問題:Java Attr.getPrefix方法的具體用法?Java Attr.getPrefix怎麽用?Java Attr.getPrefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Attr
的用法示例。
在下文中一共展示了Attr.getPrefix方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addNamespaces
import org.w3c.dom.Attr; //導入方法依賴的package包/類
private void addNamespaces(Namespaces rv, Element element) {
if (element == null) throw new RuntimeException("element must not be null");
String myDefaultNamespace = toUri(element.lookupNamespaceURI(null));
String parentDefaultNamespace = "";
if (element.getParentNode() != null) {
parentDefaultNamespace = toUri(element.getParentNode().lookupNamespaceURI(null));
}
if (!myDefaultNamespace.equals(parentDefaultNamespace) || !(element.getParentNode() instanceof Element) ) {
rv.declare(Namespace.create("", myDefaultNamespace));
}
NamedNodeMap attributes = element.getAttributes();
for (int i=0; i<attributes.getLength(); i++) {
Attr attr = (Attr)attributes.item(i);
if (attr.getPrefix() != null && attr.getPrefix().equals("xmlns")) {
rv.declare(Namespace.create(attr.getLocalName(), attr.getValue()));
}
}
}
示例2: unmarshalParams
import org.w3c.dom.Attr; //導入方法依賴的package包/類
private void unmarshalParams(Element paramsElem) {
String xPath = paramsElem.getFirstChild().getNodeValue();
// create a Map of namespace prefixes
NamedNodeMap attributes = paramsElem.getAttributes();
if (attributes != null) {
int length = attributes.getLength();
Map<String, String> namespaceMap =
new HashMap<String, String>(length);
for (int i = 0; i < length; i++) {
Attr attr = (Attr)attributes.item(i);
String prefix = attr.getPrefix();
if (prefix != null && prefix.equals("xmlns")) {
namespaceMap.put(attr.getLocalName(), attr.getValue());
}
}
this.params = new XPathFilterParameterSpec(xPath, namespaceMap);
} else {
this.params = new XPathFilterParameterSpec(xPath);
}
}
示例3: visitAttr
import org.w3c.dom.Attr; //導入方法依賴的package包/類
protected void visitAttr(Attr node)
throws XMLStreamException {
String name = node.getLocalName();
if (name.equals("xmlns")) {
out.writeDefaultNamespace(node.getNamespaceURI());
} else {
String prefix = node.getPrefix();
if (prefix != null && prefix.equals("xmlns")) {
out.writeNamespace(prefix, node.getNamespaceURI());
} else if (prefix != null) {
out.writeAttribute(prefix
, node.getNamespaceURI()
, name
, node.getNodeValue()
);
} else {
out.writeAttribute(node.getNamespaceURI()
, name
, node.getNodeValue());
}
}
}
示例4: unmarshalParams
import org.w3c.dom.Attr; //導入方法依賴的package包/類
private void unmarshalParams(Element curXPathElem) throws MarshalException
{
List<XPathType> list = new ArrayList<XPathType>();
while (curXPathElem != null) {
String xPath = curXPathElem.getFirstChild().getNodeValue();
String filterVal = DOMUtils.getAttributeValue(curXPathElem,
"Filter");
if (filterVal == null) {
throw new MarshalException("filter cannot be null");
}
XPathType.Filter filter = null;
if (filterVal.equals("intersect")) {
filter = XPathType.Filter.INTERSECT;
} else if (filterVal.equals("subtract")) {
filter = XPathType.Filter.SUBTRACT;
} else if (filterVal.equals("union")) {
filter = XPathType.Filter.UNION;
} else {
throw new MarshalException("Unknown XPathType filter type" +
filterVal);
}
NamedNodeMap attributes = curXPathElem.getAttributes();
if (attributes != null) {
int length = attributes.getLength();
Map<String, String> namespaceMap =
new HashMap<String, String>(length);
for (int i = 0; i < length; i++) {
Attr attr = (Attr)attributes.item(i);
String prefix = attr.getPrefix();
if (prefix != null && prefix.equals("xmlns")) {
namespaceMap.put(attr.getLocalName(), attr.getValue());
}
}
list.add(new XPathType(xPath, filter, namespaceMap));
} else {
list.add(new XPathType(xPath, filter));
}
curXPathElem = DOMUtils.getNextSiblingElement(curXPathElem);
}
this.params = new XPathFilter2ParameterSpec(list);
}