public String getAttributeName(Object obj) { Attribute attr = (Attribute) obj; return attr.getName(); }
public List operate(Object node) { if (node instanceof Element) { Element element = (Element) node; return Collections.singletonList(element.getNamespace().getURI() + element.getName()); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName()); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_cname can not be applied on " + node.getClass()); } }
public QName getAttributeName(int i) { Attribute at = getAttribute(i); return new QName(at.getNamespaceURI(), at.getName(), at.getNamespacePrefix()); }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getName()); else if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getName()); else if (node instanceof EntityRef) return Collections.singletonList(((EntityRef) node).getName()); else if (node instanceof ProcessingInstruction) return Collections.singletonList(((ProcessingInstruction) node).getTarget()); else if (node instanceof DocType) return Collections.singletonList(((DocType) node).getPublicID()); else return null; // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) // throw new TemplateModelException("_name can not be applied on " + node.getClass()); } }
/** * Return index of attribute with same name and Namespace, or * -1 if one doesn't exist */ private int indexOfDuplicate(Attribute attribute) { int duplicate = -1; String name = attribute.getName(); Namespace namespace = attribute.getNamespace(); duplicate = indexOf(name, namespace); return duplicate; }
public Object exec(List arguments) { Set names = new HashSet(arguments); List list = new LinkedList(nodes); Iterator it = list.iterator(); while (it.hasNext()) { Object node = it.next(); String name = null; if (node instanceof Element) name = ((Element) node).getName(); else if (node instanceof Attribute) name = ((Attribute) node).getName(); else if (node instanceof ProcessingInstruction) name = ((ProcessingInstruction) node).getTarget(); else if (node instanceof EntityRef) name = ((EntityRef) node).getName(); else if (node instanceof DocType) name = ((DocType) node).getPublicID(); if (name == null || !names.contains(name)) it.remove(); } return createNodeListModel(list, namespaces); } }
@Override String getLocalName(Object node) { if (node instanceof Element) { return ((Element) node).getName(); } if (node instanceof Attribute) { return ((Attribute) node).getName(); } if (node instanceof EntityRef) { return ((EntityRef) node).getName(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction) node).getTarget(); } if (node instanceof DocType) { return ((DocType) node).getElementName(); } return null; }
/** * Returns the JDOM node name. */ public String getName() { if (attribute != null) { return attribute.getName(); } return element.getName(); }
@Override protected void printName(Writer out, Attribute a) throws IOException { out.write(decode(a.getName())); }
/** * @return System property name. */ public String getElementId() { return ((Attribute) getAttributes().get(0)).getName(); }
private void parseAndAddAddressType(final Map<Integer, Map<String, String>> addressTypesAttributes, final List<Element> listOfRows, final int rowNum) { Element node = listOfRows.get(rowNum); @SuppressWarnings("unchecked") List<Attribute> listOfAtributes = node.getAttributes(); Map<String, String> addressTypeAttributes = Maps.newHashMap(); for (int attributeNum = 0; attributeNum < listOfAtributes.size(); attributeNum++) { addressTypeAttributes.put(listOfAtributes.get(attributeNum).getName().toLowerCase(Locale.ENGLISH), listOfAtributes .get(attributeNum).getValue()); } addressTypesAttributes.put(rowNum, addressTypeAttributes); }
private void parseAndAddColor(final Map<Integer, Map<String, String>> colorsAttributes, final List<Element> listOfRows, final int rowNum) { Element node = listOfRows.get(rowNum); @SuppressWarnings("unchecked") List<Attribute> listOfAtributes = node.getAttributes(); Map<String, String> colorAttributes = Maps.newHashMap(); for (int attributeNum = 0; attributeNum < listOfAtributes.size(); attributeNum++) { colorAttributes.put(listOfAtributes.get(attributeNum).getName().toLowerCase(Locale.ENGLISH), listOfAtributes.get(attributeNum).getValue()); } colorsAttributes.put(rowNum, colorAttributes); }
protected java.util.Map extractAttributes (org.jdom.Element elt) { java.util.Map result = new java.util.HashMap(); java.util.Iterator it = elt.getAttributes().iterator(); while (it.hasNext()) { org.jdom.Attribute a = (org.jdom.Attribute)it.next(); result.put(a.getName(), a.getValue()); } return result; }
private void parseAndAddCountry(final Element node) { @SuppressWarnings("unchecked") List<Attribute> attributes = node.getAttributes(); Map<String, String> values = Maps.newHashMap(); for (Attribute attribute : attributes) { values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue()); } addCountry(values); }
private void parseAndAddFaultType(final Element node) { @SuppressWarnings("unchecked") List<Attribute> attributes = node.getAttributes(); Map<String, String> values = new HashMap<String, String>(); for (Attribute attribute : attributes) { values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue()); } addAction(values); }
private void parseAndAddFaultType(final Element node) { @SuppressWarnings("unchecked") List<Attribute> attributes = node.getAttributes(); Map<String, String> values = Maps.newHashMap(); for (Attribute attribute : attributes) { values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue()); } addFaultType(values); }