當前位置: 首頁>>代碼示例>>Java>>正文


Java Attr.getPrefix方法代碼示例

本文整理匯總了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()));
        }
    }
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:19,代碼來源:XmlNode.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:DOMXPathTransform.java

示例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());
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:DOMPrinter.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:43,代碼來源:DOMXPathFilter2Transform.java


注:本文中的org.w3c.dom.Attr.getPrefix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。