List of usage examples for org.w3c.dom Element getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
/** * Creates a <tt>StyledLayerDescriptor</tt> -instance according to the contents of the DOM-subtree starting at the * given 'StyledLayerDescriptor'- <tt>Element</tt>. * <p>// www . j ava2s .c o m * * @param element * the 'StyledLayerDescriptor'- <tt>Element</tt> * @throws XMLParsingException * if a syntactic or semantic error in the DOM-subtree is encountered * @return the constructed <tt>StyledLayerDescriptor</tt> -instance */ public static StyledLayerDescriptor createStyledLayerDescriptor(final IUrlResolver2 urlResolver, final Element element) throws XMLParsingException { // optional: <Name> final String name = XMLTools.getStringValue("Name", NS.SLD, element, null);//$NON-NLS-1$ // optional: <Title> final String title = XMLTools.getStringValue("Title", NS.SLD, element, null);//$NON-NLS-1$ // optional: <Abstract> final String description = XMLTools.getStringValue("Abstract", NS.SLD, element, null);//$NON-NLS-1$ // required: version-Attribute // final String version = XMLTools.getRequiredAttrValue( "version", element ); // TODO: check for correct version here...; must be "1.0.0", but i have seen many wrong .sld's // optional: <NamedLayer>(s) / <UserLayer>(s) final NodeList nodelist = element.getChildNodes(); final List<Layer> layerList = new ArrayList<>(100); for (int i = 0; i < nodelist.getLength(); i++) { if (nodelist.item(i) instanceof Element) { final Element child = (Element) nodelist.item(i); final String namespace = child.getNamespaceURI(); if (!NS.SLD.equals(namespace)) { continue; } final String childName = child.getLocalName(); if ("NamedLayer".equals(childName))//$NON-NLS-1$ { layerList.add(SLDFactory.createNamedLayer(urlResolver, child)); } else if ("UserLayer".equals(childName))//$NON-NLS-1$ { layerList.add(SLDFactory.createUserLayer(urlResolver, child)); } } } final Layer[] layers = layerList.toArray(new Layer[layerList.size()]); return new StyledLayerDescriptor_Impl(name, title, description, layers); }
From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
/** * Creates a <tt>NamedLayer</tt> -instance according to the contents of the DOM-subtree starting at the given * 'UserLayer'- <tt>Element</tt>. * <p>//from w w w .j a v a2 s .co m * * @param element * the 'NamedLayer'- <tt>Element</tt> * @throws XMLParsingException * if a syntactic or semantic error in the DOM-subtree is encountered * @return the constructed <tt>NamedLayer</tt> -instance */ private static NamedLayer createNamedLayer(final IUrlResolver2 urlResolver, final Element element) throws XMLParsingException { // required: <Name> final String name = XMLTools.getRequiredStringValue("Name", NS.SLD, element);//$NON-NLS-1$ // optional: <LayerFeatureConstraints> LayerFeatureConstraints lfc = null; final Element lfcElement = XMLTools.getChildByName("LayerFeatureConstraints", NS.SLD, element);//$NON-NLS-1$ if (lfcElement != null) { lfc = SLDFactory.createLayerFeatureConstraints(lfcElement); } // optional: <NamedStyle>(s) / <UserStyle>(s) final NodeList nodelist = element.getChildNodes(); final List<Style> styleList = new ArrayList<>(); for (int i = 0; i < nodelist.getLength(); i++) if (nodelist.item(i) instanceof Element) { final Element child = (Element) nodelist.item(i); final String namespace = child.getNamespaceURI(); if (!NS.SLD.equals(namespace)) { continue; } final String childName = child.getLocalName(); if ("NamedStyle".equals(childName)) { styleList.add(SLDFactory.createNamedStyle(child)); } else if ("UserStyle".equals(childName)) { styleList.add(SLDFactory.createUserStyle(urlResolver, child)); } } final Style[] styles = styleList.toArray(new Style[styleList.size()]); return new NamedLayer_Impl(name, lfc, styles); }
From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
private static void parseRuleOrSemanticTypeIdentifier(final IUrlResolver2 urlResolver, final List<Rule> ruleList, final List<String> typeIdentifierList, final List<Filter> filters, final List<Rule> elseRules, final Node item) throws XMLParsingException { if (item instanceof Element) { final Element child = (Element) item; final String namespace = child.getNamespaceURI(); if (!NS.SLD.equals(namespace)) { return; }/*w w w.j ava 2s . co m*/ final String childName = child.getLocalName(); if ("Rule".equals(childName)) { final Rule rule = SLDFactory.createRule(urlResolver, child); if (rule.hasElseFilter()) { elseRules.add(rule); } else if (rule.getFilter() == null || rule.getFilter() instanceof ComplexFilter) { filters.add(rule.getFilter()); } ruleList.add(rule); } else if ("SemanticTypeIdentifier".equals(childName))//$NON-NLS-1$ { typeIdentifierList.add(XMLTools.getStringValue(child)); } } }
From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
public static Symbolizer createSymbolizer(final IUrlResolver2 urlResolver, final Element symbolizerElement) throws XMLParsingException { final String namespace = symbolizerElement.getNamespaceURI(); if (!(NS.SLD.equals(namespace) || SLDNS_EXT.equals(namespace))) return null; final UOM uom = readUOM(symbolizerElement); final String symbolizerName = symbolizerElement.getLocalName(); if ("LineSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createLineSymbolizer(urlResolver, symbolizerElement, uom); if ("PointSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createPointSymbolizer(urlResolver, symbolizerElement, uom); if ("PolygonSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createPolygonSymbolizer(urlResolver, symbolizerElement, uom); if ("TextSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createTextSymbolizer(urlResolver, symbolizerElement, uom); if ("RasterSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createRasterSymbolizer(urlResolver, symbolizerElement, uom); if ("SurfaceLineSymbolizer".equals(symbolizerName))//$NON-NLS-1$ return SLDFactory.createSurfaceLineSymbolizer(urlResolver, symbolizerElement, uom); if ("SurfacePolygonSymbolizer".equals(symbolizerName)) //$NON-NLS-1$ return SLDFactory.createSurfacePolygonSymbolizer(urlResolver, symbolizerElement, uom); return null;/*from ww w . java 2s. co m*/ }
From source file:org.kalypsodeegree_impl.graphics.sld.SLDFactory.java
/** * Creates a <tt>Graphic</tt> -instance according to the contents of the DOM-subtree starting at the given * 'Graphic'-element.//from w w w . j av a 2 s .co m * <p> * * @param element * the 'Graphic'- <tt>Element</tt> * @throws XMLParsingException * if a syntactic or semantic error in the DOM-subtree is encountered * @return the constructed <tt>Graphic</tt> -instance */ private static Graphic createGraphic(final IUrlResolver2 urlResolver, final Element element) throws XMLParsingException { // optional: <Opacity> ParameterValueType opacity = null; // optional: <Size> ParameterValueType size = null; // optional: <Rotation> ParameterValueType rotation = null; // optional: <ExternalGraphic>s / <Mark>s final NodeList nodelist = element.getChildNodes(); final List<Object> marksAndExtGraphicsList = new ArrayList<>(); for (int i = 0; i < nodelist.getLength(); i++) { if (nodelist.item(i) instanceof Element) { final Element child = (Element) nodelist.item(i); final String namespace = child.getNamespaceURI(); if (!NS.SLD.equals(namespace)) continue; final String childName = child.getLocalName(); if ("ExternalGraphic".equals(childName)) marksAndExtGraphicsList.add(SLDFactory.createExternalGraphic(urlResolver, child)); else if ("Mark".equals(childName)) marksAndExtGraphicsList.add(SLDFactory.createMark(urlResolver, child)); else if ("Opacity".equals(childName)) opacity = SLDFactory.createParameterValueType(child); else if ("Size".equals(childName)) size = SLDFactory.createParameterValueType(child); else if ("Rotation".equals(childName)) rotation = SLDFactory.createParameterValueType(child); } } final Object[] marksAndExtGraphics = marksAndExtGraphicsList .toArray(new Object[marksAndExtGraphicsList.size()]); return new Graphic_Impl(marksAndExtGraphics, opacity, size, rotation); }
From source file:org.kuali.rice.ken.service.impl.NotificationMessageContentServiceImpl.java
/** * This method validates the content of a notification message by matching up the namespace of the expected content type * to the actual namespace that is passed in as part of the XML message. * * This is possibly redundant because we are using qualified XPath expressions to obtain content under the correct namespace. * * @param notification//from w ww . j av a 2 s .co m * @param contentType * @param contentElement * @param content * @throws IOException * @throws XmlException */ private void validateContent(NotificationBo notification, String contentType, Element contentElement, String content) throws IOException, XmlException { // this debugging relies on a DOM 3 API that is only available with Xerces 2.7.1+ (TypeInfo) // commented out for now /*LOG.debug(contentElement.getSchemaTypeInfo()); LOG.debug(contentElement.getSchemaTypeInfo().getTypeName()); LOG.debug(contentElement.getSchemaTypeInfo().getTypeNamespace()); LOG.debug(contentElement.getNamespaceURI()); LOG.debug(contentElement.getLocalName()); LOG.debug(contentElement.getNodeName());*/ String contentTypeTitleCase = Character.toTitleCase(contentType.charAt(0)) + contentType.substring(1); String expectedNamespaceURI = CONTENT_TYPE_NAMESPACE_PREFIX + contentTypeTitleCase; String actualNamespaceURI = contentElement.getNamespaceURI(); if (!actualNamespaceURI.equals(expectedNamespaceURI)) { throw new XmlException("Namespace URI of 'content' node, '" + actualNamespaceURI + "', does not match expected namespace URI, '" + expectedNamespaceURI + "', for content type '" + contentType + "'"); } }
From source file:org.kuali.rice.krad.datadictionary.parse.CustomSchemaParser.java
/** * Parses a bean based on the namespace of the bean. * * @param tag - The Element to be parsed. * @param parent - The parent bean that the tag is nested in. * @param parserContext - Provided information and functionality regarding current bean set. * @return The parsed bean.// ww w . j a v a2 s . c o m */ protected Object parseBean(Element tag, BeanDefinitionBuilder parent, ParserContext parserContext) { if (tag.getNamespaceURI().compareTo("http://www.springframework.org/schema/beans") == 0 || tag.getLocalName().equals("bean")) { return parseSpringBean(tag, parserContext); } else { return parseCustomBean(tag, parent, parserContext); } }
From source file:org.lilyproject.runtime.classloading.XmlClassLoaderBuilder.java
private ClassLoadingConfig build() throws Exception { List<ClasspathEntry> classpath = new ArrayList<ClasspathEntry>(); // First add module self ArtifactSharingMode selfSharingMode = ArtifactSharingMode.PROHIBITED; String selfShareModeName = element.getAttribute("share-self"); if (selfShareModeName.length() > 0) { selfSharingMode = ArtifactSharingMode.fromString(selfShareModeName); }//from w ww . j av a 2 s . c o m ClasspathEntry selfEntry = new ClasspathEntry(new FileArtifactRef(moduleSource.getClassPathEntry()), selfSharingMode, moduleSource); classpath.add(selfEntry); Element classPathElement = DocumentHelper.getElementChild(element, "classpath", false); if (classPathElement != null) { Element[] classPathEls = DocumentHelper.getElementChildren(classPathElement); classpath: for (Element classPathEl : classPathEls) { if (classPathEl.getLocalName().equals("artifact") && classPathEl.getNamespaceURI() == null) { // Create ArtifactRef String groupId = DocumentHelper.getAttribute(classPathEl, "groupId", true); String artifactId = DocumentHelper.getAttribute(classPathEl, "artifactId", true); String classifier = DocumentHelper.getAttribute(classPathEl, "classifier", false); String version = DocumentHelper.getAttribute(classPathEl, "version", false); String preferredVersion = versionManager.getPreferredVersion(groupId, artifactId); version = version == null ? preferredVersion : version; if (version == null) { String message = String.format( "Version for artifact %s:%s (%s) not specified, and no preference found in runtime configuration.", groupId, artifactId, classifier); throw new RuntimeException(message); } ArtifactRef artifactRef = new RepoArtifactRef(groupId, artifactId, classifier, version); // Check for double artifacts for (ClasspathEntry entry : classpath) { if (entry.getArtifactRef().equals(artifactRef)) { log.error( "Classloader specification contains second reference to same artifact, will skip second reference. Artifact = " + artifactRef); continue classpath; } else if (entry.getArtifactRef().getId().equals(artifactRef.getId())) { log.warn( "Classloader specification contains second reference to same artifact but different version. Artifact = " + artifactRef); } } // Creating SharingMode String sharingModeParam = classPathEl.getAttribute("share"); ArtifactSharingMode sharingMode; if (sharingModeParam == null || sharingModeParam.equals("")) { sharingMode = ArtifactSharingMode.ALLOWED; } else { sharingMode = ArtifactSharingMode.fromString(sharingModeParam); } classpath.add(new ClasspathEntry(artifactRef, sharingMode, null)); } } } return new ClassLoadingConfigImpl(classpath, repository); }
From source file:org.milyn.smooks.mule.core.MuleDispatcher.java
/** * Processes the static message properties. * Because these are static it is only done the first time. From that point on * a cached result is used.//from w w w.j a v a 2s .c o m * * @param executionContext * @return */ private List<MessageProperty> getStaticMessageProperties(ExecutionContext executionContext) { if (staticMessageProperties == null) { List<MessageProperty> lMessageProperties = new ArrayList<MessageProperty>(); Parameter messagePropertiesParam = config.getParameter(PARAMETER_MESSAGE_PROPERTIES); if (messagePropertiesParam != null) { Element messagePropertiesParamElement = messagePropertiesParam.getXml(); if (messagePropertiesParamElement != null) { boolean extendedConfig = messagePropertiesParamElement.getNamespaceURI() .equals(Constants.MULE_SMOOKS_NAMESPACE); if (extendedConfig) { resolvePropertiesExtendedConfig(executionContext, lMessageProperties, messagePropertiesParamElement); } else { resolvePropertiesNormalConfig(executionContext, lMessageProperties, messagePropertiesParamElement); } } else { log.error( "Sorry, the Javabean populator bindings must be available as XML DOM. Please configure using XML."); } } staticMessageProperties = lMessageProperties; } return staticMessageProperties; }
From source file:org.milyn.xml.DomUtils.java
/** * Get the child elements having the supplied localname and namespace. * <p/>/*from ww w.j a v a2s .c o m*/ * Can be used instead of XPath. * @param nodeList List of DOM nodes on which to perform the search. * @param localname Localname of the element required. Supports "*" wildcards. * @param namespaceURI Namespace URI of the required element, or null * if a namespace comparison is not to be performed. * @return A list of W3C DOM {@link Element}s. An empty list if no such * child elements exist on the parent element. */ public static List getElements(NodeList nodeList, String localname, String namespaceURI) { AssertArgument.isNotNull(nodeList, "nodeList"); AssertArgument.isNotNullAndNotEmpty(localname, "localname"); AssertArgument.isNotEmpty(namespaceURI, "namespaceURI"); int count = nodeList.getLength(); Vector elements = new Vector(); for (int i = 0; i < count; i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (localname.equals("*") || getName(element).equals(localname)) { // The local name matches the element we're after... if (namespaceURI == null || namespaceURI.equals(element.getNamespaceURI())) { elements.add(element); } } } } return elements; }