private static boolean compareAttributeAwareConfigTag(Element e, AttributeAwareConfigTag attributeAwareConfigTag) { return attributeAwareConfigTag.value().equals(e.getName()) && attributeAwareConfigTag.attributeValue().equals(e.getAttributeValue(attributeAwareConfigTag.attribute())) && e.getNamespace().getURI().equals(attributeAwareConfigTag.namespaceURI()); }
@Override public final String getElementQName(Object element) { Element e = (Element)element; if (e.getNamespace().getPrefix().length() == 0) { return e.getName(); } return e.getNamespacePrefix() + ":" + e.getName(); }
namespaces.put(getNamespacePrefix(), getNamespace()); if (additionalNamespaces != null) { for (Namespace ns : getAdditionalNamespaces()) { al.add(getNamespace()); namespaces.remove(getNamespacePrefix()); al.addAll(namespaces.values());
try { Namespace ns = element.getNamespace(); Iterator<Attribute> ait = element.hasAttributes() ? element.getAttributes().iterator() :
((Element) content).getNamespace() == Namespace.NO_NAMESPACE) { pnt.getChildren(emt.getName(), emt.getNamespace()); String xps = "*[local-name() = '" + emt.getName() + "' and namespace-uri() = '" +
if (uri == null) { ns = (current == null) ? Namespace.NO_NAMESPACE : current.getNamespace(prefix);
public static boolean compare(Element e, Class<?> implementation, ConfigCache configCache) { final AttributeAwareConfigTag attributeAwareConfigTag = annotationFor(implementation, AttributeAwareConfigTag.class); if (attributeAwareConfigTag != null) { return compareAttributeAwareConfigTag(e, attributeAwareConfigTag); } ConfigTag configTag = configTag(implementation, configCache); return configTag.value().equals(e.getName()) && e.getNamespace().getURI().equals(configTag.namespaceURI()); }
return getNamespace(); return ((Element)parent).getNamespace(prefix);
@Test public void shouldAddPluginNamespaceToPassedInElement() throws MalformedURLException { ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(pluginExtns); registry.xsdFor(PluginTestUtil.bundleCtxWithHeaders(m(PluginNamespace.XSD_NAMESPACE_PREFIX, "something", PluginNamespace.XSD_NAMESPACE_URI, "uri")), new File("file:///tmp/foo").toURI().toURL()); registry.xsdFor(PluginTestUtil.bundleCtxWithHeaders(m(PluginNamespace.XSD_NAMESPACE_PREFIX, "second", PluginNamespace.XSD_NAMESPACE_URI, "uri-1")), new File("file:///tmp/foo1").toURI().toURL()); Element foo = new Element("foo"); registry.registerNamespacesInto(foo); assertThat(foo.getNamespace("something"), is(Namespace.getNamespace("something", "uri"))); assertThat(foo.getNamespace("second"), is(Namespace.getNamespace("second", "uri-1"))); }
/** * This will take the supplied <code>{@link Element}</code> and transfer its * namespaces to the global namespace storage. * * @param element * <code>Element</code> to read namespaces from. */ private void transferNamespaces(final Element element) { for (final Namespace ns : declaredNamespaces) { if (ns != element.getNamespace()) { element.addNamespaceDeclaration(ns); } } declaredNamespaces.clear(); }
/** * Check to see if the object matches a predefined set of rules. * * @param content The object to verify. * @return <code>true</code> if the objected matched a predfined * set of rules. */ @Override public Element filter(Object content) { if (content instanceof Element) { Element el = (Element) content; if (name == null) { if (namespace == null) { return el; } return namespace.equals(el.getNamespace()) ? el : null; } if (!name.equals(el.getName())) { return null; } if (namespace == null) { return el; } return namespace.equals(el.getNamespace()) ? el : null; } return null; }
final Element element) { String reason = checkNamespaceCollision(namespace, element.getNamespace()); if (reason != null) { return reason + " with the element namespace prefix";
final Namespace mns = element.getNamespace();
Namespace ns = element.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { out.writeStartElement(element.getName()); Namespace ns = element.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { out.writeEmptyElement(element.getName());
private boolean hasElementsFrom(final Element root, final Namespace namespace) { boolean hasElements = false; for (final Element child : root.getChildren()) { final Namespace childNamespace = child.getNamespace(); if (namespace.equals(childNamespace)) { hasElements = true; break; } } return hasElements; }
private boolean hasElementsFrom(final Element root, final Namespace namespace) { boolean hasElements = false; for (final Element child : root.getChildren()) { final Namespace childNamespace = child.getNamespace(); if (namespace.equals(childNamespace)) { hasElements = true; break; } } return hasElements; }
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Namespace defaultNS = rssRoot.getNamespace(); return defaultNS != null && defaultNS.equals(getAtomNamespace()); }
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Namespace defaultNS = rssRoot.getNamespace(); return defaultNS != null && defaultNS.equals(getAtomNamespace()); }
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Namespace defaultNS = rssRoot.getNamespace(); return defaultNS != null && defaultNS.equals(getAtomNamespace()); }
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Namespace defaultNS = rssRoot.getNamespace(); return defaultNS != null && defaultNS.equals(getRSSNamespace()) && super.isMyType(document); }