Source Code Cross Referenced for NamespaceContextImpl.java in  » XML » XPath-Saxon » net » sf » saxon » xpath » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » XPath Saxon » net.sf.saxon.xpath 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.xpath;
002:
003:        import net.sf.saxon.om.NamespaceResolver;
004:
005:        import javax.xml.namespace.NamespaceContext;
006:        import java.util.ArrayList;
007:        import java.util.Iterator;
008:        import java.util.List;
009:
010:        /**
011:         * This class bridges between the JAXP 1.3 NamespaceContext interface and Saxon's
012:         * equivalent NamespaceResolver interface. It allows any implementation of the Saxon
013:         * NamespaceResolver to be wrapped as a JAXP NamespaceContext.
014:         */
015:
016:        public class NamespaceContextImpl implements  NamespaceContext,
017:                NamespaceResolver {
018:
019:            NamespaceResolver resolver;
020:
021:            /**
022:             * Constructor: wrap a Saxon NamespaceResolver as a JAXP NamespaceContext
023:             * @param resolver the Saxon NamespaceResolver
024:             */
025:
026:            public NamespaceContextImpl(NamespaceResolver resolver) {
027:                this .resolver = resolver;
028:            }
029:
030:            /**
031:             * Get the namespace URI corresponding to a given prefix. Return null
032:             * if the prefix is not in scope.
033:             * @param prefix the namespace prefix
034:             * @param useDefault true if the default namespace is to be used when the
035:             * prefix is ""
036:             * @return the uri for the namespace, or null if the prefix is not in scope
037:             */
038:
039:            public String getURIForPrefix(String prefix, boolean useDefault) {
040:                return resolver.getURIForPrefix(prefix, useDefault);
041:            }
042:
043:            /**
044:             * Get an iterator over all the prefixes declared in this namespace context. This will include
045:             * the default namespace (prefix="") and the XML namespace where appropriate
046:             */
047:
048:            public Iterator iteratePrefixes() {
049:                return resolver.iteratePrefixes();
050:            }
051:
052:            /**
053:             * Implement the JAXP getNamespaceURI() method in terms of the Saxon-specific methods
054:             * @param prefix a namespace prefix
055:             * @return the corresponding URI, if the prefix is bound, or "" otherwise
056:             */
057:
058:            public String getNamespaceURI(String prefix) {
059:                if (prefix.equals("xmlns")) {
060:                    return "http://www.w3.org/2000/xmlns/";
061:                }
062:                return resolver.getURIForPrefix(prefix, true);
063:            }
064:
065:            /**
066:             * Get the prefix bound to a particular namespace URI, if there is one, or null if not (JAXP method)
067:             * @param uri the namespace URI
068:             * @return the prefix bound to the URI if there is one, or null if not
069:             */
070:
071:            public String getPrefix(String uri) {
072:                Iterator prefixes = iteratePrefixes();
073:                while (prefixes.hasNext()) {
074:                    String p = (String) prefixes.next();
075:                    String u = resolver.getURIForPrefix(p, true);
076:                    if (u.equals(uri)) {
077:                        return p;
078:                    }
079:                }
080:                return null;
081:            }
082:
083:            /**
084:             * Get all the prefixes mapped to a given namespace URI (JAXP method)
085:             * @param uri the namespace URI
086:             * @return an iterator over all the prefixes bound to this namespace URI
087:             */
088:            public Iterator getPrefixes(String uri) {
089:                List list = new ArrayList(4);
090:                Iterator prefixes = iteratePrefixes();
091:                while (prefixes.hasNext()) {
092:                    String p = (String) prefixes.next();
093:                    String u = resolver.getURIForPrefix(p, true);
094:                    if (u.equals(uri)) {
095:                        list.add(p);
096:                    }
097:                }
098:                return list.iterator();
099:            }
100:        }
101:
102:        //
103:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
104:        // you may not use this file except in compliance with the License. You may obtain a copy of the
105:        // License at http://www.mozilla.org/MPL/
106:        //
107:        // Software distributed under the License is distributed on an "AS IS" basis,
108:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
109:        // See the License for the specific language governing rights and limitations under the License.
110:        //
111:        // The Original Code is: all this file.
112:        //
113:        // The Initial Developer of the Original Code is Michael H. Kay
114:        //
115:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
116:        //
117:        // Contributor(s): none
118:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.