Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Common Public License 

import org.w3c.dom.Element;

public class Main {
    /**
     * 
     */
    public static final String DITA_ELEM_TAGNAME = "dita";
    public static final String DITA_ARCH_NS = "http://dita.oasis-open.org/architecture/2005/";
    public static final String DITA_ARCH_VERSION_ATTNAME = "DITAArchVersion";

    /**
     * Returns true if the element's containing document 
     * @param elem
     * @return
     */
    public static boolean isInDitaDocument(Element elem) {
        Element root = elem.getOwnerDocument().getDocumentElement();
        Element cand = root;
        if (cand.getTagName().equals(DITA_ELEM_TAGNAME)) {
            // FIXME: This a little weak but unlikely to return false positives.         
            return true;
        }
        return root.hasAttributeNS(DITA_ARCH_NS, DITA_ARCH_VERSION_ATTNAME);
    }
}