Example usage for org.jdom2 Namespace getNamespace

List of usage examples for org.jdom2 Namespace getNamespace

Introduction

In this page you can find the example usage for org.jdom2 Namespace getNamespace.

Prototype

public static Namespace getNamespace(final String prefix, final String uri) 

Source Link

Document

This will retrieve (if in existence) or create (if not) a Namespace for the supplied prefix and uri.

Usage

From source file:XMLReader.ReadXMLFile.java

License:Open Source License

public static List<String> ReadLanguages(String xmlSource) {
    Namespace ns = Namespace.getNamespace("xs", "http://www.w3.org/2001/XMLSchema");
    SAXBuilder builder = new SAXBuilder(XMLReaders.NONVALIDATING);
    List<String> lenguajes = new ArrayList<String>();

    try {/* w ww  .  ja v  a2s . com*/
        Element rootNode = builder.build(xmlSource).getRootElement();
        Element type = rootNode.getChild("simpleType", ns);
        Element rest = type.getChild("restriction", ns);
        List<Element> lista = rest.getChildren("enumeration", ns);

        for (Element e : lista)
            lenguajes.add(e.getAttributeValue("value"));
    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }
    return lenguajes;
}

From source file:XMLReader.ReadXMLFile.java

License:Open Source License

public static List<String> ReadKeywords(String lang, String xmlSource) {
    Namespace ns = Namespace.getNamespace("nsKeywords", "http://www.w3.org/keywords");
    SAXBuilder builder = new SAXBuilder(XMLReaders.XSDVALIDATING);
    List<String> keywords = new ArrayList<String>();

    try {//from   ww w  .  ja va 2s  . c o m
        Element rootNode = builder.build(xmlSource).getRootElement();
        Element leng = rootNode.getChild(lang, ns);
        List<Element> lista = leng.getChildren("keyword", ns);

        for (Element e : lista)
            keywords.add(e.getTextNormalize());
    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }
    return keywords;
}