Source Code Cross Referenced for BaseSaxBuilder.java in  » XML » activexml » org » xdev » base » core » 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 » activexml » org.xdev.base.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Jan 5, 2004
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package org.xdev.base.core;
008:
009:        import java.util.ArrayList;
010:        import java.util.List;
011:
012:        import org.xdev.base.core.compiler.AXCompiler;
013:        import org.xdev.base.core.compiler.type.AbstractType;
014:        import org.xdev.base.core.object.Configuration;
015:        import org.xdev.base.log.LoggerWriter;
016:
017:        import org.apache.log4j.Level;
018:        import org.jdom.input.SAXBuilder;
019:        import org.jdom.Document;
020:        import org.jdom.Namespace;
021:
022:        import java.io.StringReader;
023:        import java.io.StringWriter;
024:
025:        import javax.xml.transform.Transformer;
026:        import javax.xml.transform.TransformerFactory;
027:        import javax.xml.transform.stream.StreamResult;
028:        import javax.xml.transform.stream.StreamSource;
029:
030:        /**
031:         * @author AYegorov
032:         *
033:         * To change the template for this generated type comment go to
034:         * Window>Preferences>Java>Code Generation>Code and Comments
035:         */
036:        public class BaseSaxBuilder extends SAXBuilder {
037:
038:            private static StringBuffer defaultNamespaces = new StringBuffer();
039:
040:            /**
041:             * 
042:             */
043:            public BaseSaxBuilder() {
044:                super ();
045:            }
046:
047:            /**
048:             * @param arg0
049:             */
050:            public BaseSaxBuilder(String arg0) {
051:                super (arg0);
052:                // XXX Auto-generated constructor stub
053:            }
054:
055:            /**
056:             * @param arg0
057:             * @param arg1
058:             */
059:            public BaseSaxBuilder(String arg0, boolean arg1) {
060:                super (arg0, arg1);
061:                // XXX Auto-generated constructor stub
062:            }
063:
064:            /**
065:             * @param arg0
066:             */
067:            public BaseSaxBuilder(boolean arg0) {
068:                super (arg0);
069:                // XXX Auto-generated constructor stub
070:            }
071:
072:            public static void addNamespace(String name, String uri) {
073:                defaultNamespaces.append(" xmlns:").append(name).append("=\"")
074:                        .append(uri).append("\" ");
075:            }
076:
077:            public Document build(String xml, String qualifierXml,
078:                    Configuration types) throws Exception {
079:
080:                Document doc = null;
081:
082:                if (qualifierXml != null && !"".equals(qualifierXml)) {
083:                    LoggerWriter.log("Qualifying xml document: " + xml,
084:                            Level.INFO_INT, this .getClass());
085:
086:                    xml = this .build(xml, types, true);
087:
088:                    TransformerFactory transformerFactory = org.apache.xalan.processor.TransformerFactoryImpl
089:                            .newInstance();
090:                    Transformer transformer = transformerFactory
091:                            .newTransformer(new StreamSource(new StringReader(
092:                                    xml)));
093:
094:                    StringWriter writer = new StringWriter();
095:
096:                    transformer.transform(new StreamSource(new StringReader(
097:                            qualifierXml)), new StreamResult(writer));
098:
099:                    xml = writer.toString();
100:
101:                    LoggerWriter.log("Qualified xml document: " + xml,
102:                            Level.INFO_INT, this .getClass());
103:
104:                    doc = super .build(new StringReader(xml));
105:                } else {
106:                    doc = this .build(xml, types);
107:                }
108:
109:                return doc;
110:            }
111:
112:            public String build(String xml, Configuration types, boolean append) {
113:                int index = xml.indexOf(">");
114:
115:                StringBuffer buffer = new StringBuffer(xml);
116:
117:                if (append) {
118:                    StringBuffer namespaces = new StringBuffer(
119:                            defaultNamespaces.toString());
120:
121:                    namespaces.append(" xmlns:").append(
122:                            AXCompiler.GLOBAL_IDENTIFIER).append("=\"").append(
123:                            AXCompiler.PREFIX_URI).append("\"");
124:
125:                    ArrayList typeList = new ArrayList(types.getKeys());
126:
127:                    int size = typeList.size();
128:
129:                    for (int i = 0; i < size; i++) {
130:                        if (xml.indexOf("<" + (String) typeList.get(i) + ":") != -1
131:                                && xml.indexOf("xmlns:"
132:                                        + (String) typeList.get(i)) == -1) {
133:                            LoggerWriter.log("Adding Namespace prefix: "
134:                                    + (String) typeList.get(i)
135:                                    + " bound by following URI: "
136:                                    + AXCompiler.PREFIX_URI, Level.DEBUG_INT,
137:                                    this .getClass());
138:                            namespaces
139:                                    .append(" xmlns:")
140:                                    .append((String) typeList.get(i))
141:                                    .append("=\"")
142:                                    .append(
143:                                            ((AbstractType) types
144:                                                    .getPropertyAsObject(typeList
145:                                                            .get(i).toString()))
146:                                                    .getType().getName())
147:                                    .append("\"");
148:                        }
149:                    }
150:
151:                    if (namespaces.length() > 0) {
152:
153:                        LoggerWriter.log("Adding namespaces: "
154:                                + namespaces.toString() + " to the document.",
155:                                Level.DEBUG_INT, this .getClass());
156:
157:                        buffer.insert(index, namespaces);
158:
159:                        LoggerWriter.log(
160:                                "Document has been prepared with namespaces: "
161:                                        + buffer.toString(), Level.DEBUG_INT,
162:                                this .getClass());
163:                    }
164:                }
165:
166:                return buffer.toString();
167:            }
168:
169:            public Document build(String xml, Configuration types)
170:                    throws Exception {
171:
172:                LoggerWriter.log(xml, Level.DEBUG_INT, this .getClass());
173:
174:                return super .build(new StringReader(this 
175:                        .build(xml, types, true)));
176:            }
177:
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.