当前位置: 首页>>代码示例>>Java>>正文


Java XMLSymbols.PREFIX_XMLNS属性代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLSymbols.PREFIX_XMLNS属性的典型用法代码示例。如果您正苦于以下问题:Java XMLSymbols.PREFIX_XMLNS属性的具体用法?Java XMLSymbols.PREFIX_XMLNS怎么用?Java XMLSymbols.PREFIX_XMLNS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.org.apache.xerces.internal.util.XMLSymbols的用法示例。


在下文中一共展示了XMLSymbols.PREFIX_XMLNS属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNamespaceDeclarations

private void addNamespaceDeclarations(final int prefixCount) {
    String prefix = null;
    String localpart = null;
    String rawname = null;
    String nsPrefix = null;
    String nsURI = null;
    for (int i = 0; i < prefixCount; ++i) {
        nsPrefix = fNamespaceContext.getDeclaredPrefixAt(i);
        nsURI = fNamespaceContext.getURI(nsPrefix);
        if (nsPrefix.length() > 0) {
            prefix = XMLSymbols.PREFIX_XMLNS;
            localpart = nsPrefix;
            rawname = fSymbolTable.addSymbol(prefix + ":" + localpart);
        }
        else {
            prefix = XMLSymbols.EMPTY_STRING;
            localpart = XMLSymbols.PREFIX_XMLNS;
            rawname = XMLSymbols.PREFIX_XMLNS;
        }
        fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
        fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, nsURI);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SchemaContentHandler.java

示例2: getPrefix

public String getPrefix(String uri, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (uri == NamespaceContext.XML_URI) {
        return XMLSymbols.PREFIX_XML;
    }
    if (uri == NamespaceContext.XMLNS_URI) {
        return XMLSymbols.PREFIX_XMLNS;
    }

    // find uri in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 1] == uri) {
            if (getURI(fNamespace[i - 2]) == uri)
                return fNamespace[i - 2];
        }
    }

    // uri not found
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:MultipleScopeNamespaceSupport.java

示例3: getURI

public String getURI(String prefix, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (prefix == XMLSymbols.PREFIX_XML) {
        return NamespaceContext.XML_URI;
    }
    if (prefix == XMLSymbols.PREFIX_XMLNS) {
        return NamespaceContext.XMLNS_URI;
    }

    // find prefix in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 2] == prefix) {
            return fNamespace[i - 1];
        }
    }

    // prefix not found
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:MultipleScopeNamespaceSupport.java

示例4: startElement

/**
 * The start of an element. If the document specifies the start element
 * by using an empty tag, then the startElement method will immediately
 * be followed by the endElement method, with no intervening methods.
 * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startElement (QName element, XMLAttributes attributes, Augmentations augs) {
    // namespace declarations parameter has no effect if namespaces is false.
    if (!fNamespaceDeclarations && fNamespaceAware) {
        int len = attributes.getLength();
        for (int i = len - 1; i >= 0; --i) {
            if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
                XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
                attributes.removeAttributeAt(i);
            }
        }
    }
    super.startElement(element, attributes, augs);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:DOMParserImpl.java

示例5: processAttributes

private void processAttributes(NamedNodeMap attrMap) {
    final int attrCount = attrMap.getLength();
    fAttributes.removeAllAttributes();
    for (int i = 0; i < attrCount; ++i) {
        Attr attr = (Attr) attrMap.item(i);
        String value = attr.getValue();
        if (value == null) {
            value = XMLSymbols.EMPTY_STRING;
        }
        fillQName(fAttributeQName, attr);
        // REVISIT: Assuming all attributes are of type CDATA. The actual type may not matter. -- mrglavas
        fAttributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, value);
        fAttributes.setSpecified(i, attr.getSpecified());
        // REVISIT: Should we be looking at non-namespace attributes
        // for additional mappings? Should we detect illegal namespace
        // declarations and exclude them from the context? -- mrglavas
        if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
            // process namespace attribute
            if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                fNamespaceContext.declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
            else {
                fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:DOMValidatorHelper.java

示例6: fillNamespaceContext

private void fillNamespaceContext() {
    if (fRoot != null) {
        Node currentNode = fRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix0(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix0(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }

            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:DOMValidatorHelper.java

示例7: addNamespaceDeclarations

private void addNamespaceDeclarations() {
    String prefix = null;
    String localpart = null;
    String rawname = null;
    String nsPrefix = null;
    String nsURI = null;

    final Iterator iter = fDeclaredPrefixes.iterator();
    while (iter.hasNext()) {
        nsPrefix = (String) iter.next();
        nsURI = fNamespaceContext.getURI(nsPrefix);
        if (nsPrefix.length() > 0) {
            prefix = XMLSymbols.PREFIX_XMLNS;
            localpart = nsPrefix;
            fStringBuffer.clear();
            fStringBuffer.append(prefix);
            fStringBuffer.append(':');
            fStringBuffer.append(localpart);
            rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
        }
        else {
            prefix = XMLSymbols.EMPTY_STRING;
            localpart = XMLSymbols.PREFIX_XMLNS;
            rawname = XMLSymbols.PREFIX_XMLNS;
        }
        fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
        fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol,
                (nsURI != null) ? nsURI : XMLSymbols.EMPTY_STRING);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:StAXSchemaParser.java

示例8: prefixBoundToNullURI

protected boolean prefixBoundToNullURI(String uri, String localpart) {
    return (uri == XMLSymbols.EMPTY_STRING && localpart != XMLSymbols.PREFIX_XMLNS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:3,代码来源:XMLNamespaceBinder.java

示例9: startAnnotation

void startAnnotation(String elemRawName, XMLAttributes attributes,
        NamespaceContext namespaceContext) {
    if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256);
    fAnnotationBuffer.append("<").append(elemRawName).append(" ");

    // attributes are a bit of a pain.  To get this right, we have to keep track
    // of the namespaces we've seen declared, then examine the namespace context
    // for other namespaces so that we can also include them.
    // optimized for simplicity and the case that not many
    // namespaces are declared on this annotation...
    ArrayList namespaces = new ArrayList();
    for (int i = 0; i < attributes.getLength(); ++i) {
        String aValue = attributes.getValue(i);
        String aPrefix = attributes.getPrefix(i);
        String aQName = attributes.getQName(i);
        // if it's xmlns:* or xmlns, must be a namespace decl
        if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
            namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ?
                    attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
        }
        fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");
    }
    // now we have to look through currently in-scope namespaces to see what
    // wasn't declared here
    Enumeration currPrefixes = namespaceContext.getAllPrefixes();
    while(currPrefixes.hasMoreElements()) {
        String prefix = (String)currPrefixes.nextElement();
        String uri = namespaceContext.getURI(prefix);
        if (uri == null) {
            uri = XMLSymbols.EMPTY_STRING;
        }
        if (!namespaces.contains(prefix)) {
            // have to declare this one
            if(prefix == XMLSymbols.EMPTY_STRING) {
                fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" ");
            }
            else {
                fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" ");
            }
        }
    }
    fAnnotationBuffer.append(">\n");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:SchemaDOM.java


注:本文中的com.sun.org.apache.xerces.internal.util.XMLSymbols.PREFIX_XMLNS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。