当前位置: 首页>>代码示例>>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;未经允许,请勿转载。