Here you can find the source of getElementLanguage(Element elemNode, String defaultLangCode)
Parameter | Description |
---|---|
elemNode | The whose language value is to be returned. |
defaultLangCode | The default language code to return if there is no explicit language code. |
public static String getElementLanguage(Element elemNode, String defaultLangCode)
//package com.java2s; /*-------------------------------------------------------------------------------- Copyright (C) 2002, 2004 ISOGEN International http://www.isogen.com/*from www . j a va 2 s . co m*/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --------------------------------------------------------------------------------*/ import org.w3c.dom.Element; public class Main { static String langAttName = "language"; /** * Returns the language code associated with the specified element. * * @param elemNode The whose language value is to be returned. * @param defaultLangCode The default language code to return if * there is no explicit language code. */ public static String getElementLanguage(Element elemNode, String defaultLangCode) { String langCode = defaultLangCode; if (elemNode.hasAttribute(langAttName)) { langCode = elemNode.getAttribute(langAttName); } else if (elemNode.hasAttributeNS("xml", "lang")) { langCode = elemNode.getAttributeNS("xml", "lang"); } return langCode; } }