本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
示例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();
}
}
}
示例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);
}
}
示例8: prefixBoundToNullURI
protected boolean prefixBoundToNullURI(String uri, String localpart) {
return (uri == XMLSymbols.EMPTY_STRING && localpart != XMLSymbols.PREFIX_XMLNS);
}
示例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");
}