private Document createEmptyCruiseConfigDocument() { Element root = new Element("cruise"); Namespace xsiNamespace = Namespace.getNamespace("xsi", XML_NS); root.addNamespaceDeclaration(xsiNamespace); registry.registerNamespacesInto(root); root.setAttribute("noNamespaceSchemaLocation", "cruise-config.xsd", xsiNamespace); String xsds = registry.xsds(); if (!xsds.isEmpty()) { root.setAttribute("schemaLocation", xsds, xsiNamespace); } root.setAttribute("schemaVersion", Integer.toString(GoConstants.CONFIG_SCHEMA_VERSION)); return new Document(root); }
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()); }
private void writeOneEntry( InvDataset ds, OutputStream out, StringBuilder mess) throws IOException { Element rootElem = new Element("DIF", defNS); Document doc = new Document(rootElem); writeDataset( ds, rootElem, mess); rootElem.addNamespaceDeclaration(defNS); rootElem.addNamespaceDeclaration(XMLEntityResolver.xsiNS); rootElem.setAttribute("schemaLocation", defNS.getURI()+" "+schemaLocation, XMLEntityResolver.xsiNS); // Output the document, use standard formatter XMLOutputter fmt = new XMLOutputter( Format.getPrettyFormat()); fmt.output( doc, out); }
Element web_app = jdomDoc.getRootElement(); String maskEpsg = ""; Namespace gml = Namespace.getNamespace("http://www.opengis.net/gml/3.2"); Namespace eop = Namespace.getNamespace("http://www.opengis.net/eop/2.0"); List<Element> targeted = web_app.getChildren("boundedBy", gml); if(!targeted.isEmpty()) { Element aEnvelope = targeted.get(0).getChild("Envelope", gml); if(aEnvelope != null) { maskEpsg = aEnvelope.getAttribute("srsName").getValue(); if (!web_app_content.getCType().equals(CType.Text) && !web_app_content.getCType().equals(CType.Comment)) boolean withGml = (web_app_content.getNamespacesInScope().get(0).getPrefix().contains("gml")); if(withGml) boolean parentNotGml = !(web_app_content.getParentElement().getNamespace().getPrefix().contains("gml")); if(parentNotGml) if(attr != null) polygonId = attr.getValue(); if(polygonId.indexOf('.') != -1) Document newDoc = new Document(capturedElement.clone().detach());
private Transfer parseTransfer(Document document, String targetScheme) throws URISyntaxException Element root = document.getRootElement(); Namespace vosNS = root.getNamespace(); Attribute versionAttr = root.getAttribute("version"); if (VOSPACE_NS_20.equals(vosNS.getURI())) { version = VOS.VOSPACE_20; if (versionAttr != null && VOSPACE_MINOR_VERSION_21.equals(versionAttr.getValue())) { version = VOS.VOSPACE_21; throw new IllegalArgumentException("unexpected VOSpace namespace: " + vosNS.getURI()); URI target = new URI(root.getChildText("target", vosNS));
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Namespace defaultNS = rssRoot.getNamespace(); return defaultNS != null && defaultNS.equals(getAtomNamespace()); }
ch.startPrefixMapping(ns.getPrefix(), ns.getURI()); if (out.isDeclareNamespaces()) { String prefix = ns.getPrefix(); if (prefix.equals("")) { atts.addAttribute("", "", "xmlns", "CDATA", ns.getURI()); } else { atts.addAttribute("", "", "xmlns:" + ns.getPrefix(), "CDATA", ns.getURI()); if (element.hasAttributes()) { for (Attribute a : element.getAttributes()) { if (!a.isSpecified() && fstack.isSpecifiedAttributesOnly()) { continue; atts.addAttribute(a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()), ch.startElement(element.getNamespaceURI(), element.getName(), element.getQualifiedName(), atts); ch.endPrefixMapping(ns.getPrefix());
private void changeToTestDOI(Document metadata) { XPathExpression<Element> compile = XPathFactory.instance().compile( "//datacite:identifier[@identifierType='DOI']", Filters.element(), null, Namespace.getNamespace("datacite", metadata.getRootElement().getNamespace().getURI())); Element element = compile.evaluateFirst(metadata); MCRDigitalObjectIdentifier doi = new MCRDOIParser() .parse(element.getText()) .orElseThrow(() -> new MCRException("Datacite Document contains invalid DOI!")); String testDOI = doi.toTestPrefix().asString(); element.setText(testDOI); }
if (cur != null) Attribute type = cur.getAttribute("type", xsiNamespace); String tval = type.getValue(); String extype = namespace.getPrefix() + ":" + Polygon.class.getSimpleName(); if ( extype.equals(tval) ) Element ves = cur.getChild("vertices", namespace); for (Element ve : ves.getChildren()) // only vertex
try { Namespace ns = element.getNamespace(); Iterator<Attribute> ait = element.hasAttributes() ? element.getAttributes().iterator() : null; if (ns == Namespace.NO_NAMESPACE) { new AttIterator(ait, eventfactory, fstack.isSpecifiedAttributesOnly()), new NSIterator(nstack.addedForward().iterator(), eventfactory))); } else if ("".equals(ns.getPrefix())) { out.add(eventfactory.createStartElement("", ns.getURI(), element.getName(), new AttIterator(ait, eventfactory, fstack.isSpecifiedAttributesOnly()), new NSIterator(nstack.addedForward().iterator(), eventfactory))); } else { out.add(eventfactory.createStartElement(ns.getPrefix(), ns.getURI(), element.getName(), new AttIterator(ait, eventfactory, fstack.isSpecifiedAttributesOnly()), new NSIterator(nstack.addedForward().iterator(), eventfactory)));
Element root = document.getRootElement(); Namespace namespace = root.getNamespace(); log.debug("obs namespace uri: " + namespace.getURI()); log.debug("obs namespace prefix: " + namespace.getPrefix()); if ( XmlConstants.CAOM2_0_NAMESPACE.equals(namespace.getURI()) ) rc.docVersion = 20; else if ( XmlConstants.CAOM2_1_NAMESPACE.equals(namespace.getURI()) ) rc.docVersion = 21; else if ( XmlConstants.CAOM2_2_NAMESPACE.equals(namespace.getURI()) ) rc.docVersion = 22; Attribute type = root.getAttribute("type", xsiNamespace); String tval = type.getValue(); String simple = namespace.getPrefix() + ":" + SimpleObservation.class.getSimpleName(); String comp = namespace.getPrefix() + ":" + CompositeObservation.class.getSimpleName(); if ( simple.equals(tval) )
private boolean isGetCoverageWcsDoc(String url) throws JDOMException, IOException { byte[] result = TestOnLocalServer.getContent(url+baloney+"&request=GetCapabilities", 200, ContentType.xml); Reader in = new StringReader( new String(result, CDM.utf8Charset)); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(in); boolean isName = doc.getRootElement().getName().equals("WCS_Capabilities"); boolean isNamespace = doc.getRootElement().getNamespaceURI().equals(NS_WCS.getURI()); return (isName && isNamespace); }
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; }
Element eleColumn = new Element("column"); addChild(eleColumn, "name", cd.getColumnName()); addChild(eleColumn, "description", cd.description); if (eleDt != null) Attribute attType = new Attribute("type", vod.getPrefix() + ":VOTableType", xsi); eleDt.setAttribute(attType); if (tt.arraysize != null) eleDt.setAttribute("arraysize", tt.arraysize); if (tt.xtype != null) eleDt.setAttribute("extendedType", tt.xtype); if (eleDt != null) Attribute attType = new Attribute("type", vod.getPrefix() + ":TAPType", xsi); eleDt.setAttribute(attType); if (tt.arraysize != null && !tt.isVarSize()) // assume single digit
final String space = element.getAttributeValue("space", Namespace.XML_NAMESPACE); element.getNamespaceURI(), element.getQualifiedName()); continue; ret.setAttribute(getXmlnsTagFor(ns), ns.getURI());
@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"))); }
@Override public javax.xml.stream.events.Attribute next() { final Attribute att = source.next(); final Namespace ns = att.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { return fac.createAttribute(att.getName(), att.getValue()); } return fac.createAttribute(ns.getPrefix(), ns.getURI(), att.getName(), att.getValue()); }
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()); }
private Element child(Element e, ConfigTag tag) { return e.getChild(tag.value(), Namespace.getNamespace(tag.namespacePrefix(), tag.namespaceURI())); }