Statistics
| Revision:

ccc / projets / CMC2ELAN / src / PersonalNamespaceContext.groovy @ 2

History | View | Annotate | Download (3.1 kB)

1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28

    
29

    
30
import java.util.Iterator;
31
import javax.xml.*;
32
import javax.xml.namespace.NamespaceContext;
33

    
34
// TODO: Auto-generated Javadoc
35
/**
36
 * Instantiates a new personal namespace context.
37
 *
38
 * @author ayepdieu
39
 * do correpondances between namespace and uri
40
 */
41
 public class PersonalNamespaceContext implements NamespaceContext {
42
                public PersonalNamespaceContext() {
43
                        super();
44
                }
45
            
46
            /* (non-Javadoc)
47
             * @see javax.xml.namespace.NamespaceContext#getNamespaceURI(java.lang.String)
48
             */
49
            public String getNamespaceURI(String prefix) {
50
                if (prefix == null) throw new NullPointerException("Null prefix");
51
                else if ("tei".equals(prefix)) return "http://www.tei-c.org/ns/1.0";
52
                else if ("me".equals(prefix)) return "http://www.menota.org/ns/1.0";
53
                else if ("bfm".equals(prefix)) return "http://bfm.ens-lsh.fr/ns/1.0";
54
                else if ("txm".equals(prefix)) return "http://textometrie.org/1.0";
55
                else if ("xi".equals(prefix)) return "http://www.w3.org/2001/XInclude";
56
                else if ("xml".equals(prefix)) return XMLConstants.XML_NS_URI;
57
                return XMLConstants.NULL_NS_URI;
58
            }
59

    
60
            /**
61
             * 
62
             * @param uri the uri
63
             * @return the prefix
64
             */
65
            public String getPrefix(String uri) {
66
                    if (uri == null) throw new NullPointerException("Null prefix");
67
                else if ("http://www.tei-c.org/ns/1.0".equals(uri)) return "tei";
68
                else if ("http://www.menota.org/ns/1.0".equals(uri)) return "me";
69
                else if ("http://bfm.ens-lsh.fr/ns/1.0".equals(uri)) return "bfm";
70
                else if ("http://textometrie.org/1.0".equals(uri)) return "txm";
71
                else if ("http://www.w3.org/2001/XInclude".equals(uri)) return "xi";
72
                else if("http://www.w3.org/XML/1998/namespace") return "xml"
73
                else if (XMLConstants.XML_NS_URI.equals(uri)) return "xml";
74
                else XMLConstants.NULL_NS_URI;
75
            }
76

    
77
            /**
78
             * This method isn't necessary for XPath processing either.
79
             *
80
             * @param uri the uri
81
             * @return the prefixes
82
             */
83
            public Iterator getPrefixes(String uri) {
84
                throw new UnsupportedOperationException();
85
            }
86
        }