Source Code Cross Referenced for ExampleObj2XML.java in  » Graphic-Library » fop » embedding » 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 » Graphic Library » fop » embedding 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: ExampleObj2XML.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package embedding;
021:
022:        //Hava
023:        import java.io.File;
024:        import java.io.IOException;
025:
026:        //JAXP
027:        import javax.xml.transform.Transformer;
028:        import javax.xml.transform.TransformerFactory;
029:        import javax.xml.transform.TransformerException;
030:        import javax.xml.transform.Source;
031:        import javax.xml.transform.Result;
032:        import javax.xml.transform.stream.StreamResult;
033:
034:        import embedding.model.ProjectMember;
035:        import embedding.model.ProjectTeam;
036:
037:        /**
038:         * This class demonstrates the conversion of an arbitrary object file to an 
039:         * XML file.
040:         */
041:        public class ExampleObj2XML {
042:
043:            /**
044:             * Converts a ProjectTeam object to XML.
045:             * @param team the ProjectTeam object
046:             * @param xml the target XML file
047:             * @throws IOException In case of an I/O problem
048:             * @throws TransformerException In case of a XSL transformation problem
049:             */
050:            public void convertProjectTeam2XML(ProjectTeam team, File xml)
051:                    throws IOException, TransformerException {
052:
053:                //Setup XSLT
054:                TransformerFactory factory = TransformerFactory.newInstance();
055:                Transformer transformer = factory.newTransformer();
056:                /* Note:
057:                   We use the identity transformer, no XSL transformation is done.
058:                   The transformer is basically just used to serialize the 
059:                   generated document to XML. */
060:
061:                //Setup input
062:                Source src = team.getSourceForProjectTeam();
063:
064:                //Setup output
065:                Result res = new StreamResult(xml);
066:
067:                //Start XSLT transformation
068:                transformer.transform(src, res);
069:            }
070:
071:            /**
072:             * Creates a sample ProjectTeam instance for this demo.
073:             * @return ProjectTeam the newly created ProjectTeam instance
074:             */
075:            public static ProjectTeam createSampleProjectTeam() {
076:                ProjectTeam team = new ProjectTeam();
077:                team.setProjectName("Rule the Galaxy");
078:                team.addMember(new ProjectMember("Emperor Palpatine", "lead",
079:                        "palpatine@empire.gxy"));
080:                team.addMember(new ProjectMember("Lord Darth Vader",
081:                        "Jedi-Killer", "vader@empire.gxy"));
082:                team.addMember(new ProjectMember("Grand Moff Tarkin",
083:                        "Planet-Killer", "tarkin@empire.gxy"));
084:                team.addMember(new ProjectMember("Admiral Motti",
085:                        "Death Star operations", "motti@empire.gxy"));
086:                return team;
087:            }
088:
089:            /**
090:             * Main method.
091:             * @param args command-line arguments
092:             */
093:            public static void main(String[] args) {
094:                try {
095:                    System.out.println("FOP ExampleObj2XML\n");
096:                    System.out.println("Preparing...");
097:
098:                    //Setup directories
099:                    File baseDir = new File(".");
100:                    File outDir = new File(baseDir, "out");
101:                    outDir.mkdirs();
102:
103:                    //Setup input and output
104:                    File xmlfile = new File(outDir, "ResultObj2XML.xml");
105:
106:                    System.out.println("Input: a ProjectTeam object");
107:                    System.out.println("Output: XML (" + xmlfile + ")");
108:                    System.out.println();
109:                    System.out.println("Serializing...");
110:
111:                    ExampleObj2XML app = new ExampleObj2XML();
112:                    app.convertProjectTeam2XML(createSampleProjectTeam(),
113:                            xmlfile);
114:
115:                    System.out.println("Success!");
116:                } catch (Exception e) {
117:                    e.printStackTrace(System.err);
118:                    System.exit(-1);
119:                }
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.