/** * Returns the URI of prefix (if any) * * @param prefix the prefix whose URI is searched for * @return the namespace URI currently associated with the * prefix, null if the prefix is undefined. */ public String getNamespaceURIFromPrefix(String prefix) { String uri = null; if (m_prefixMap != null) uri = m_prefixMap.lookupNamespace(prefix); return uri; }
/** * Returns the URI of prefix (if any) * * @param prefix the prefix whose URI is searched for * @return the namespace URI currently associated with the * prefix, null if the prefix is undefined. */ public String getNamespaceURIFromPrefix(String prefix) { String uri = null; if (m_prefixMap != null) uri = m_prefixMap.lookupNamespace(prefix); return uri; }
uri = m_prefixMap.lookupNamespace(""); } else { uri = m_prefixMap.lookupNamespace(prefix);
/** * Given a namespace uri, and the namespaces mappings for the * current element, return the current prefix for that uri. * * @param uri the namespace URI to be search for * @return an existing prefix that maps to the given URI, null if no prefix * maps to the given namespace URI. */ public String lookupPrefix(String uri) { String foundPrefix = null; Enumeration prefixes = m_namespaces.keys(); while (prefixes.hasMoreElements()) { String prefix = (String) prefixes.nextElement(); String uri2 = lookupNamespace(prefix); if (uri2 != null && uri2.equals(uri)) { foundPrefix = prefix; break; } } return foundPrefix; }
uri = m_prefixMap.lookupNamespace(""); } else { uri = m_prefixMap.lookupNamespace(prefix);
/** * If at runtime, when the qname of the attribute is * known, another prefix is specified for the attribute, then we can * patch or hack the name with this method. For * a qname of the form "ns?:otherprefix:name", this function patches the * qname by simply ignoring "otherprefix". * TODO: This method is a HACK! We do not have access to the * XML file, it sometimes generates a NS prefix of the form "ns?" for * an attribute. */ protected String patchName(String qname) { final int lastColon = qname.lastIndexOf(':'); if (lastColon > 0) { final int firstColon = qname.indexOf(':'); final String prefix = qname.substring(0, firstColon); final String localName = qname.substring(lastColon + 1); // If uri is "" then ignore prefix final String uri = m_prefixMap.lookupNamespace(prefix); if (uri != null && uri.length() == 0) { return localName; } else if (firstColon != lastColon) { return prefix + ':' + localName; } } return qname; }
/** * If at runtime, when the qname of the attribute is * known, another prefix is specified for the attribute, then we can * patch or hack the name with this method. For * a qname of the form "ns?:otherprefix:name", this function patches the * qname by simply ignoring "otherprefix". * TODO: This method is a HACK! We do not have access to the * XML file, it sometimes generates a NS prefix of the form "ns?" for * an attribute. */ protected String patchName(String qname) { final int lastColon = qname.lastIndexOf(':'); if (lastColon > 0) { final int firstColon = qname.indexOf(':'); final String prefix = qname.substring(0, firstColon); final String localName = qname.substring(lastColon + 1); // If uri is "" then ignore prefix final String uri = m_prefixMap.lookupNamespace(prefix); if (uri != null && uri.length() == 0) { return localName; } else if (firstColon != lastColon) { return prefix + ':' + localName; } } return qname; }
/** * Given a namespace uri, get all prefixes bound to the Namespace URI in the current scope. * * @param uri the namespace URI to be search for * @return An array of Strings which are * all prefixes bound to the namespace URI in the current scope. * An array of zero elements is returned if no prefixes map to the given * namespace URI. */ public String[] lookupAllPrefixes(String uri) { java.util.ArrayList foundPrefixes = new java.util.ArrayList(); Enumeration prefixes = m_namespaces.keys(); while (prefixes.hasMoreElements()) { String prefix = (String) prefixes.nextElement(); String uri2 = lookupNamespace(prefix); if (uri2 != null && uri2.equals(uri)) { foundPrefixes.add(prefix); } } String[] prefixArray = new String[foundPrefixes.size()]; foundPrefixes.toArray(prefixArray); return prefixArray; } }
/** * Returns the URI of an element or attribute. Note that default namespaces * do not apply directly to attributes. * @param qname a qualified name * @param isElement true if the qualified name is the name of * an element. * @return returns the namespace URI associated with the qualified name. */ public String getNamespaceURI(String qname, boolean isElement) { String uri = EMPTYSTRING; int col = qname.lastIndexOf(':'); final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING; if (!EMPTYSTRING.equals(prefix) || isElement) { if (m_prefixMap != null) { uri = m_prefixMap.lookupNamespace(prefix); if (uri == null && !prefix.equals(XMLNS_PREFIX)) { throw new RuntimeException( Utils.messages.createMessage( MsgKey.ER_NAMESPACE_PREFIX, new Object[] { qname.substring(0, col) } )); } } } return uri; }
/** * Returns the URI of an element or attribute. Note that default namespaces * do not apply directly to attributes. * @param qname a qualified name * @param isElement true if the qualified name is the name of * an element. * @return returns the namespace URI associated with the qualified name. */ public String getNamespaceURI(String qname, boolean isElement) { String uri = EMPTYSTRING; int col = qname.lastIndexOf(':'); final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING; if (!EMPTYSTRING.equals(prefix) || isElement) { if (m_prefixMap != null) { uri = m_prefixMap.lookupNamespace(prefix); if (uri == null && !prefix.equals(XMLNS_PREFIX)) { throw new RuntimeException( Utils.messages.createMessage( MsgKey.ER_NAMESPACE_PREFIX, new Object[] { qname.substring(0, col) } )); } } } return uri; }
void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException { if (ns != null && ns.length() > 0) { int index; final boolean no_prefix = ((index = rawName.indexOf(":")) < 0); String prefix = (no_prefix) ? "" : rawName.substring(0, index); if (null != prefix) { String foundURI = m_prefixMap.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(ns)) { this.startPrefixMapping(prefix, ns); // Bugzilla1133: Generate attribute as well as namespace event. // SAX does expect both. this.addAttributeAlways( "http://www.w3.org/2000/xmlns/", no_prefix ? "xmlns" : prefix, // local name no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname "CDATA", ns, false); } } } }
void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException { if (ns != null && ns.length() > 0) { int index; final boolean no_prefix = ((index = rawName.indexOf(":")) < 0); String prefix = (no_prefix) ? "" : rawName.substring(0, index); if (null != prefix) { String foundURI = m_prefixMap.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(ns)) { this.startPrefixMapping(prefix, ns); // Bugzilla1133: Generate attribute as well as namespace event. // SAX does expect both. this.addAttributeAlways( "http://www.w3.org/2000/xmlns/", no_prefix ? "xmlns" : prefix, // local name no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname "CDATA", ns, false); } } } }
private void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException { if (ns != null && ns.length() > 0) { int index; final boolean no_prefix = ((index = rawName.indexOf(":")) < 0); String prefix = (no_prefix) ? "" : rawName.substring(0, index); if (null != prefix) { String foundURI = m_prefixMap.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(ns)) { this.startPrefixMapping(prefix, ns, false); if (getShouldOutputNSAttr()) { // Bugzilla1133: Generate attribute as well as namespace event. // SAX does expect both. this.addAttributeAlways( "http://www.w3.org/2000/xmlns/", no_prefix ? "xmlns" : prefix, // local name no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname "CDATA", ns, false); } } } } } /**
private void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException { if (ns != null && ns.length() > 0) { int index; final boolean no_prefix = ((index = rawName.indexOf(":")) < 0); String prefix = (no_prefix) ? "" : rawName.substring(0, index); if (null != prefix) { String foundURI = m_prefixMap.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(ns)) { this.startPrefixMapping(prefix, ns, false); if (getShouldOutputNSAttr()) { // Bugzilla1133: Generate attribute as well as namespace event. // SAX does expect both. this.addAttributeAlways( "http://www.w3.org/2000/xmlns/", no_prefix ? "xmlns" : prefix, // local name no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname "CDATA", ns, false); } } } } } /**
foundURI = ns.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(uri))
foundURI = ns.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(uri))
String uri = m_prefixMap.lookupNamespace(prefixFromRawName); if (uri != null && uri.equals(ns))
String uri = m_prefixMap.lookupNamespace(prefixFromRawName); if (uri != null && uri.equals(ns))
/** * Returns the URI of prefix (if any) * * @param prefix the prefix whose URI is searched for * @return the namespace URI currently associated with the * prefix, null if the prefix is undefined. */ public String getNamespaceURIFromPrefix(String prefix) { String uri = null; if (m_prefixMap != null) uri = m_prefixMap.lookupNamespace(prefix); return uri; }
/** * Returns the URI of prefix (if any) * * @param prefix the prefix whose URI is searched for * @return the namespace URI currently associated with the * prefix, null if the prefix is undefined. */ public String getNamespaceURIFromPrefix(String prefix) { String uri = null; if (m_prefixMap != null) uri = m_prefixMap.lookupNamespace(prefix); return uri; }