本文整理汇总了Java中com.intellij.xml.util.XmlUtil.EMPTY_URI属性的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.EMPTY_URI属性的具体用法?Java XmlUtil.EMPTY_URI怎么用?Java XmlUtil.EMPTY_URI使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.xml.util.XmlUtil
的用法示例。
在下文中一共展示了XmlUtil.EMPTY_URI属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeHeaderByPsi
private static XmlFileHeader computeHeaderByPsi(XmlFile file) {
final XmlDocument document = file.getDocument();
if (document == null) {
return XmlFileHeader.EMPTY;
}
String publicId = null;
String systemId = null;
final XmlProlog prolog = document.getProlog();
if (prolog != null) {
final XmlDoctype doctype = prolog.getDoctype();
if (doctype != null) {
publicId = doctype.getPublicId();
systemId = doctype.getSystemId();
if (systemId == null) {
systemId = doctype.getDtdUri();
}
}
}
final XmlTag tag = document.getRootTag();
if (tag == null) {
return XmlFileHeader.EMPTY;
}
String localName = tag.getLocalName();
if (StringUtil.isNotEmpty(localName)) {
if (tag.getPrevSibling() instanceof PsiErrorElement) {
return XmlFileHeader.EMPTY;
}
String psiNs = tag.getNamespace();
return new XmlFileHeader(localName, psiNs == XmlUtil.EMPTY_URI || Comparing.equal(psiNs, systemId) ? null : psiNs, publicId,
systemId);
}
return XmlFileHeader.EMPTY;
}
示例2: getNamespace
public String getNamespace(){
String name = getName();
if (name == null) return XmlUtil.EMPTY_URI;
if (getNSDescriptor() == null || myDescriptorTag == null) return XmlUtil.EMPTY_URI;
final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
return namespacePrefix.isEmpty() ?
getDefaultNamespace() :
myDescriptorTag.getNamespaceByPrefix(namespacePrefix);
}
示例3: computeNsDescriptorMap
@NotNull
private Map<String, CachedValue<XmlNSDescriptor>> computeNsDescriptorMap() {
Map<String, CachedValue<XmlNSDescriptor>> map = null;
// XSD aware attributes processing
final String noNamespaceDeclaration = getAttributeValue("noNamespaceSchemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
final String schemaLocationDeclaration = getAttributeValue("schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
if (noNamespaceDeclaration != null) {
map = initializeSchema(XmlUtil.EMPTY_URI, null, noNamespaceDeclaration, null, myHasNamespaceDeclarations);
}
if (schemaLocationDeclaration != null) {
final StringTokenizer tokenizer = new StringTokenizer(schemaLocationDeclaration);
while (tokenizer.hasMoreTokens()) {
final String uri = tokenizer.nextToken();
if (tokenizer.hasMoreTokens()) {
map = initializeSchema(uri, getNSVersion(uri, this), tokenizer.nextToken(), map, myHasNamespaceDeclarations);
}
}
}
// namespace attributes processing (XSD declaration via ExternalResourceManager)
if (hasNamespaceDeclarations()) {
for (final XmlAttribute attribute : getAttributes()) {
if (attribute.isNamespaceDeclaration()) {
String ns = attribute.getValue();
if (ns == null) ns = XmlUtil.EMPTY_URI;
ns = getRealNs(ns);
if (map == null || !map.containsKey(ns)) {
map = initializeSchema(ns, getNSVersion(ns, this), getNsLocation(ns), map, true);
}
}
}
}
return map == null ? Collections.<String, CachedValue<XmlNSDescriptor>>emptyMap() : map;
}
示例4: getNamespace
@Override
@NotNull
public String getNamespace() {
final String name = getName();
final String prefixByQualifiedName = XmlUtil.findPrefixByQualifiedName(name);
// The namespace name for an unprefixed attribute name always has no value. Namespace recommendation section 6.2, third paragraph
if (prefixByQualifiedName.isEmpty()) return XmlUtil.EMPTY_URI;
return getParent().getNamespaceByPrefix(prefixByQualifiedName);
}
示例5: getNamespaceByPrefix
@Override
@NotNull
public String getNamespaceByPrefix(String prefix) {
final PsiElement parent = getParent();
if (!parent.isValid()) {
LOG.error(this.isValid());
}
BidirectionalMap<String, String> map = initNamespaceMaps(parent);
if (map != null) {
final String ns = map.get(prefix);
if (ns != null) return ns;
}
if (parent instanceof XmlTag) return ((XmlTag)parent).getNamespaceByPrefix(prefix);
//The prefix 'xml' is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared
if (XML_NS_PREFIX.equals(prefix)) return XmlUtil.XML_NAMESPACE_URI;
if (!prefix.isEmpty() &&
!hasNamespaceDeclarations() &&
getNamespacePrefix().equals(prefix)) {
// When there is no namespace declarations then qualified names should be just used in dtds
// this implies that we may have "" namespace prefix ! (see last paragraph in Namespaces in Xml, Section 5)
String result = ourGuard.doPreventingRecursion("getNsByPrefix", true, new Computable<String>() {
@Override
public String compute() {
final String nsFromEmptyPrefix = getNamespaceByPrefix("");
final XmlNSDescriptor nsDescriptor = getNSDescriptor(nsFromEmptyPrefix, false);
final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(XmlTagImpl.this) : null;
final String nameFromRealDescriptor =
descriptor != null && descriptor.getDeclaration() != null && descriptor.getDeclaration().isPhysical()
? descriptor.getName()
: "";
if (nameFromRealDescriptor.equals(getName())) return nsFromEmptyPrefix;
return XmlUtil.EMPTY_URI;
}
});
if (result != null) {
return result;
}
}
return XmlUtil.EMPTY_URI;
}