Java tutorial
//package com.java2s; //License from project: Common Public License import org.w3c.dom.Element; public class Main { public static final String DITA_CLASS_ATTNAME = "class"; public static final String DITA_TOPICREF_TYPE = "map/topicref"; public static final String DITA_HREF_ATTNAME = "href"; /** * Returns true if the element is of type DITA_TOPICREF_TYPE and has * a non-empty value for its href= attribute. * @param elem * @return */ public static boolean isTopicRef(Element elem) { if (isDitaType(elem, DITA_TOPICREF_TYPE)) { String href = elem.getAttribute(DITA_HREF_ATTNAME); return (href != null && !href.equals("")); } return false; } public static boolean isDitaType(Element element, String ditaMapType) { String classValue = element.getAttribute(DITA_CLASS_ATTNAME); if (classValue != null) { // NOTE: because class values always start with "+" or "-", // index can never be 0. return (classValue.indexOf(" " + ditaMapType.trim() + " ") > 0 || classValue.endsWith(" " + ditaMapType.trim())); } return false; } }