public String getAttribute(int index) { return ((Attr) currentElement.getAttributes().item(index)).getValue(); }
protected void parseRule(Node root) throws Exception { if(root.getNodeType() != Node.ELEMENT_NODE) return; NamedNodeMap attrs=root.getAttributes(); if(attrs == null || attrs.getLength() == 0) return; Attr name_attr=(Attr)attrs.getNamedItem(NAME), classname_attr=(Attr)attrs.getNamedItem(CLASS), interval_attr=(Attr)attrs.getNamedItem(INTERVAL); Class<Rule> clazz=Util.loadClass(classname_attr.getValue(), getClass()); Rule rule=clazz.newInstance(); long interval=Long.parseLong(interval_attr.getValue()); installRule(name_attr.getValue(), interval, rule); }
/** * Loads the given attribute in the current sequence. * * @param attr The W3C DOM attribute node to load. */ private void load(Attr attr) { handlePrefixMapping(attr.getNamespaceURI(), attr.getPrefix()); load(this.efactory.makeAttribute(attr.getNamespaceURI(), attr.getLocalName(), attr.getNodeName(), attr.getValue())); }
protected Attribute createAttribute(org.w3c.dom.Attr newAttr) { QName qname = null; String name = newAttr.getLocalName(); if (name != null) { String prefix = newAttr.getPrefix(); String uri = newAttr.getNamespaceURI(); qname = getDocumentFactory().createQName(name, prefix, uri); } else { name = newAttr.getName(); qname = getDocumentFactory().createQName(name); } return new DOMAttribute(qname, newAttr.getValue()); }
while (it.hasNext() && successiveOmitted) { Attr n = it.next(); if (n.getLocalName().equals("base") && !e.rendered) { baseAttrs.add(n); } else if (!loa.containsKey(n.getName())) { loa.put(n.getName(), n); while (it.hasNext()) { Attr n = it.next(); if (n.getLocalName().equals("base")) { base = n.getValue(); baseAttr = n; break; Attr n = it.next(); if (base == null) { base = n.getValue(); baseAttr = n; } else { try { base = joinURI(n.getValue(), base); } catch (URISyntaxException ue) { if (log.isDebugEnabled()) {
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
public static String attr(Element el, String... attr) { NamedNodeMap nnm = el.getAttributes(); for(int i = 0; i != nnm.getLength(); ++i) { Node node = nnm.item(i); if (node instanceof Attr) { Attr a = (Attr) node; for(String at: attr) { if (a.getName().equalsIgnoreCase(at)) { return a.getValue(); } } } } return null; } }
protected static void parseBridges(SiteConfig site_config, Node root) throws Exception { NodeList children=root.getChildNodes(); if(children == null || children.getLength() == 0) return; for(int i=0; i < children.getLength(); i++) { Node node=children.item(i); if(node.getNodeType() != Node.ELEMENT_NODE) continue; String node_name=node.getNodeName(); match(BRIDGE, node_name, true); NamedNodeMap attrs=node.getAttributes(); if(attrs == null || attrs.getLength() == 0) continue; Attr name_attr=(Attr)attrs.getNamedItem("name"); Attr config_attr=(Attr)attrs.getNamedItem("config"); String name=name_attr != null? name_attr.getValue() : null; String config=config_attr.getValue(); BridgeConfig bridge_config=new PropertiesBridgeConfig(name, config); site_config.addBridge(bridge_config); } }
public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr) throws DOMException { Attribute attribute = attribute(newAttr.getNamespaceURI(), newAttr .getLocalName()); if (attribute != null) { attribute.setValue(newAttr.getValue()); } else { attribute = createAttribute(newAttr); add(attribute); } return DOMNodeHelper.asDOMAttr(attribute); }
final String urlValue = urlAttribute.getValue(); try { connectionUri = new URI(urlValue); throw new XmlConfigurationException( String.format("Value of %s attribute on XML configuration element <%s> in <%s> is not a valid URI - '%s'", urlAttribute.getName(), item.getNodeName(), fragment.getTagName(), connectionUri), e); for (int j = 0; j < serverNodes.getLength(); j++) { final Node serverNode = serverNodes.item(j); final String host = ((Element)serverNode).getAttributeNode("host").getValue(); final Attr port = ((Element)serverNode).getAttributeNode("port"); InetSocketAddress address; address = InetSocketAddress.createUnresolved(host, 0); } else { String portString = port.getValue(); address = InetSocketAddress.createUnresolved(host, Integer.parseInt(portString));
public void parseAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute)) { String propertyName = attribute.getLocalName().endsWith(REF_SUFFIX) ? attribute.getLocalName() .substring(0, attribute.getLocalName() .length() - REF_SUFFIX.length()) : attribute.getLocalName(); propertyName = Conventions .attributeNameToPropertyName(propertyName); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from" + " 'extractPropertyName(String)': cannot be" + " null or empty."); if (attribute.getLocalName().endsWith(REF_SUFFIX)) { builder.addPropertyReference(propertyName, attribute.getValue()); } else { builder.addPropertyValue(propertyName, attribute.getValue()); } } } }
protected static void parseForwards(SiteConfig site_config, Node root) throws Exception { NodeList children=root.getChildNodes(); if(children == null || children.getLength() == 0) return; for(int i=0; i < children.getLength(); i++) { Node node=children.item(i); if(node.getNodeType() != Node.ELEMENT_NODE) continue; String node_name=node.getNodeName(); match(FORWARD, node_name, true); NamedNodeMap attrs=node.getAttributes(); if(attrs == null || attrs.getLength() == 0) continue; Attr to_attr=(Attr)attrs.getNamedItem("to"); Attr gw_attr=(Attr)attrs.getNamedItem("gateway"); String to=to_attr.getValue(); String gateway=gw_attr.getValue(); ForwardConfig forward_config=new ForwardConfig(to, gateway); site_config.addForward(forward_config); } }
private void parseDescriptionRootAttr(XMPMetadata xmp, Element description, Attr attr, TypeMapping tm) throws XmpSchemaException, XmpParsingException String namespace = attr.getNamespaceURI(); XMPSchema schema = xmp.getSchema(namespace); if (schema == null && tm.getSchemaFactory(namespace) != null) new QName(attr.getNamespaceURI(), attr.getLocalName())); attr.getLocalName(), attr.getValue(), type.type()); container.addProperty(sp); e.getMessage() + " in " + schema.getPrefix() + ":" + attr.getLocalName(), e);
/** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. * <p>This implementation maps any attributes present on the * supplied element to {@link org.springframework.beans.PropertyValue} * instances, and * {@link BeanDefinitionBuilder#addPropertyValue(String, Object) adds them} * to the * {@link org.springframework.beans.factory.config.BeanDefinition builder}. * <p>The {@link #extractPropertyName(String)} method is used to * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed * @param builder used to define the {@code BeanDefinition} * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute, parserContext)) { String propertyName = extractPropertyName(attribute.getLocalName()); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.addPropertyValue(propertyName, attribute.getValue()); } } postProcess(builder, element); }