Source Code Cross Referenced for DOM2Model.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » rdf » arp » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.rdf.arp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        package com.hp.hpl.jena.rdf.arp;
007:
008:        import javax.xml.transform.Source;
009:        import javax.xml.transform.Transformer;
010:        import javax.xml.transform.TransformerFactory;
011:        import javax.xml.transform.dom.DOMSource;
012:        import javax.xml.transform.sax.SAXResult;
013:
014:        import org.apache.commons.logging.Log;
015:        import org.apache.commons.logging.LogFactory;
016:        import org.w3c.dom.Node;
017:        import org.xml.sax.SAXParseException;
018:
019:        import com.hp.hpl.jena.rdf.model.Model;
020:        import com.hp.hpl.jena.shared.JenaException;
021:
022:        /**
023:         * Transform DOM nodes of RDF.XML into Jena Models. Known not to work with Java
024:         * 1.4.1.
025:         * 
026:         * @author Jeremy J. Carroll
027:         * 
028:         */
029:        public class DOM2Model extends SAX2Model {
030:
031:            static Log logger = LogFactory.getLog(DOM2Model.class);
032:
033:            /**
034:             * Create a new DOM2Model.
035:             * 
036:             * @param base
037:             *            The retrieval URL, or the base URI to be used while parsing.
038:             * @param m
039:             *            A Jena Model in which to put the triples, this can be null. If
040:             *            it is null, then use {@link SAX2RDF#getHandlers}or
041:             *            {@link SAX2RDF#setHandlersWith}to provide a {@link StatementHandler},
042:             *            and usually an {@link org.xml.sax.ErrorHandler}
043:             * @throws SAXParseException 
044:             */
045:            static public DOM2Model createD2M(String base, Model m)
046:                    throws SAXParseException {
047:                return new DOM2Model(base, m, "", true);
048:            }
049:
050:            /**
051:             * Create a new DOM2Model. This is particularly intended for when parsing a
052:             * non-root element within an XML document. In which case the application
053:             * needs to find this value in the outer context. Optionally, namespace
054:             * prefixes can be passed from the outer context using
055:             * {@link SAX2RDF#startPrefixMapping}.
056:             * 
057:             * @param base
058:             *            The retrieval URL, or the base URI to be used while parsing.
059:             * @param m
060:             *            A Jena Model in which to put the triples, this can be null. If
061:             *            it is null, then use {@link SAX2RDF#getHandlers}or
062:             *            {@link SAX2RDF#setHandlersWith}to provide a {@link StatementHandler},
063:             *            and usually an {@link org.xml.sax.ErrorHandler}
064:             * @param lang
065:             *            The current value of <code>xml:lang</code> when parsing
066:             *            starts, usually "".
067:             * @throws SAXParseException 
068:             */
069:            static public DOM2Model createD2M(String base, Model m, String lang)
070:                    throws SAXParseException {
071:                return new DOM2Model(base, m, lang, true);
072:            }
073:
074:            /**
075:             * Create a new DOM2Model.
076:             * 
077:             * @param base
078:             *            The retrieval URL, or the base URI to be used while parsing.
079:             * @param m
080:             *            A Jena Model in which to put the triples, this can be null. If
081:             *            it is null, then use {@link SAX2RDF#getHandlers}or
082:             *            {@link SAX2RDF#setHandlersWith}to provide a {@link StatementHandler},
083:             *            and usually an {@link org.xml.sax.ErrorHandler}
084:             * @throws MalformedURIException 
085:             * @deprecated Use {@link #createD2M(String, Model)}
086:             */
087:            public DOM2Model(String base, Model m) throws MalformedURIException {
088:                this (base, m, "");
089:            }
090:
091:            /**
092:             * Create a new DOM2Model. This is particularly intended for when parsing a
093:             * non-root element within an XML document. In which case the application
094:             * needs to find this value in the outer context. Optionally, namespace
095:             * prefixes can be passed from the outer context using
096:             * {@link SAX2RDF#startPrefixMapping}.
097:             * 
098:             * @param base
099:             *            The retrieval URL, or the base URI to be used while parsing.
100:             * @param m
101:             *            A Jena Model in which to put the triples, this can be null. If
102:             *            it is null, then use {@link SAX2RDF#getHandlers}or
103:             *            {@link SAX2RDF#setHandlersWith}to provide a {@link StatementHandler},
104:             *            and usually an {@link org.xml.sax.ErrorHandler}
105:             * @param lang
106:             *            The current value of <code>xml:lang</code> when parsing
107:             *            starts, usually "".
108:             * @throws MalformedURIException 
109:             * @deprecated Use {@link #createD2M(String, Model, String)}
110:             */
111:            public DOM2Model(String base, Model m, String lang)
112:                    throws MalformedURIException {
113:                super (base, m, lang);
114:            }
115:
116:            DOM2Model(String base, Model m, String lang, boolean dummy)
117:                    throws SAXParseException {
118:                super (base, m, lang, 0);
119:            }
120:
121:            /**
122:             * Parse a DOM Node with the RDF/XML parser, loading the triples into the
123:             * associated Model. Known not to work with Java 1.4.1.
124:             * 
125:             * @param document
126:             */
127:            public void load(Node document) {
128:                Source input = new DOMSource(document);
129:
130:                // Make a SAXResult object using this handler
131:                SAXResult output = new SAXResult(this );
132:                output.setLexicalHandler(this );
133:
134:                // Run transform
135:                TransformerFactory xformFactory = TransformerFactory
136:                        .newInstance();
137:                try {
138:                    Transformer idTransform = xformFactory.newTransformer();
139:                    idTransform.transform(input, output);
140:                } catch (FatalParsingErrorException e) {
141:                    // Old code ignored this,
142:                    // given difficult bug report, don't be silent.
143:                    logger.error("Unexpected exception in DOM2Model", e);
144:
145:                } catch (RuntimeException rte) {
146:                    throw rte;
147:                } catch (Exception nrte) {
148:                    throw new JenaException(nrte);
149:                } finally {
150:                    close();
151:                }
152:            }
153:
154:        }
155:
156:        /*
157:         * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
158:         * reserved.
159:         * 
160:         * Redistribution and use in source and binary forms, with or without
161:         * modification, are permitted provided that the following conditions are met:
162:         * 1. Redistributions of source code must retain the above copyright notice,
163:         * this list of conditions and the following disclaimer. 2. Redistributions in
164:         * binary form must reproduce the above copyright notice, this list of
165:         * conditions and the following disclaimer in the documentation and/or other
166:         * materials provided with the distribution. 3. The name of the author may not
167:         * be used to endorse or promote products derived from this software without
168:         * specific prior written permission.
169:         * 
170:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
171:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
172:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
173:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
174:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
175:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
176:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
177:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
178:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
179:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
180:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.