Author: DartPeng
Date: 2009-12-07 21:56:20 -0500 (Mon, 07 Dec 2009)
New Revision: 19090
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j-1.6.1.jar
trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j.license
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer2.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath
trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLModelAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLTagObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLTemplateEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLNodeGraphicalModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateGraphicalModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/XSLTemplateCreationWizard.java
Log:
JBIDE-5304
Remove Dom4J jar and replace all Dom4J api with org.w3c API
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath 2009-12-08 00:07:42 UTC (rev
19089)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/.classpath 2009-12-08 02:56:20 UTC (rev
19090)
@@ -1,11 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry exported="true" kind="lib"
path="libs/xstream-1.2.2.jar"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="smooks-csv"/>
- <classpathentry kind="src" path="smooks-core"/>
- <classpathentry exported="true" kind="lib"
path="libs/dom4j-1.6.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib"
path="libs/xstream-1.2.2.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="smooks-csv"/>
+ <classpathentry kind="src" path="smooks-core"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project 2009-12-08 00:07:42 UTC (rev
19089)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/.project 2009-12-08 02:56:20 UTC (rev
19090)
@@ -1,40 +1,40 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.jboss.tools.smooks.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>smooks-core</name>
- <type>2</type>
- <location>/Users/tfennelly/milyn/trunk/smooks-core/src/main/java</location>
- </link>
- <link>
- <name>smooks-csv</name>
- <type>2</type>
- <location>/Users/tfennelly/milyn/trunk/smooks-cartridges/csv/src/main/java</location>
- </link>
- </linkedResources>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.smooks.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>smooks-core</name>
+ <type>2</type>
+ <location>D:/Users/tfennelly/milyn/trunk/smooks-core/src/main/java</location>
+ </link>
+ <link>
+ <name>smooks-csv</name>
+ <type>2</type>
+ <location>D:/Users/tfennelly/milyn/trunk/smooks-cartridges/csv/src/main/java</location>
+ </link>
+ </linkedResources>
+</projectDescription>
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j.license
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j.license 2009-12-08 00:07:42
UTC (rev 19089)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/libs/dom4j.license 2009-12-08 02:56:20
UTC (rev 19090)
@@ -1,13 +0,0 @@
-BSD style license
-
-Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided that the
following conditions are met:
-
- 1. Redistributions of source code must retain copyright statements and notices.
Redistributions must also contain a copy of this document.
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
- 3. The name "DOM4J" must not be used to endorse or promote products derived
from this Software without prior written permission of MetaStuff, Ltd. For written
permission, please contact dom4j-info(a)metastuff.com.
- 4. Products derived from this Software may not be called "DOM4J" nor may
"DOM4J" appear in their names without prior written permission of MetaStuff,
Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
- 5. Due credit should be given to the DOM4J Project -
http://www.dom4j.org
-
-THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. \ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/csv/CSVDataParser.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.csv;
-import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
@@ -20,9 +19,9 @@
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
-import org.dom4j.DocumentException;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
@@ -31,7 +30,7 @@
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.milyn.Smooks;
import org.milyn.csv.CSVReaderConfigurator;
-import org.milyn.payload.StringResult;
+import org.w3c.dom.Document;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -56,12 +55,11 @@
public static final String RECORD_NAME = "recordName"; //$NON-NLS-1$
public TagList parseCSV(String filePath, SmooksResourceListType resourceList)
- throws FileNotFoundException, DocumentException, InvocationTargetException,
ParserConfigurationException {
+ throws FileNotFoundException, InvocationTargetException, ParserConfigurationException
{
return parseCSV(new FileInputStream(SmooksUIUtils.parseFilePath(filePath)),
resourceList);
}
- public TagList parseCSV(InputStream inputStream, Object readerObj) throws
ParserConfigurationException,
- DocumentException {
+ public TagList parseCSV(InputStream inputStream, Object readerObj) throws
ParserConfigurationException {
String fields = null;
String separator = null;
String quoteChar = null;
@@ -94,7 +92,7 @@
}
public TagList parseCSV(InputStream stream, SmooksResourceListType resourceList)
- throws DocumentException, ParserConfigurationException {
+ throws ParserConfigurationException {
List<AbstractReader> readers = resourceList.getAbstractReader();
int count = 0;
int index = -1;
@@ -122,13 +120,13 @@
}
public TagList parseCSV(String filePath, String fields, String rootName, String
recordName, String separator,
- String quoteChar, String skiplines, String encoding) throws DocumentException,
FileNotFoundException {
+ String quoteChar, String skiplines, String encoding) throws FileNotFoundException {
return parseCSV(new FileInputStream(filePath), fields, rootName, recordName, separator,
quoteChar, skiplines,
encoding);
}
public TagList parseCSV(InputStream stream, String fields, String rootName, String
recordName, String separator,
- String quoteChar, String skiplines, String encoding) throws DocumentException {
+ String quoteChar, String skiplines, String encoding) {
Smooks smooks = new Smooks();
@@ -171,18 +169,15 @@
smooks.setReaderConfig(readerConfigurator);
- StringResult result = new StringResult();
+ DOMResult result = new DOMResult();
smooks.filterSource(new StreamSource(stream), result);
+
+ Document document = (Document) result.getNode();
XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
- ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(result.getResult().getBytes());
- TagList tagList = analyzer.analyze(byteinputStream, null);
+ TagList tagList = analyzer.analyze(document, null);
try {
- if (byteinputStream != null) {
- byteinputStream.close();
- byteinputStream = null;
- }
if (smooks != null) {
smooks.close();
smooks = null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.edi;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -22,9 +21,9 @@
import java.util.Iterator;
import java.util.List;
+import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
-import org.dom4j.DocumentException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -38,9 +37,9 @@
import org.jboss.tools.smooks.model.smooks.AbstractReader;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.milyn.Smooks;
-import org.milyn.payload.StringResult;
import org.milyn.smooks.edi.EDIReaderConfigurator;
import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
/**
* @author Dart
@@ -56,18 +55,18 @@
public static final Object VALIDATE = "validate"; //$NON-NLS-1$
public TagList parseEDIFile(InputStream stream, SmooksResourceListType resourceList,
IProject project)
- throws IOException, DocumentException {
+ throws IOException {
List<AbstractReader> readers = resourceList.getAbstractReader();
int count = 0;
int index = -1;
for (Iterator<?> iterator2 = readers.iterator(); iterator2.hasNext();) {
AbstractReader abstractReader = (AbstractReader) iterator2.next();
-// if (abstractReader instanceof EDIReader) {
-// count++;
-// if (index == -1) {
-// index = readers.indexOf(abstractReader);
-// }
-// }
+ // if (abstractReader instanceof EDIReader) {
+ // count++;
+ // if (index == -1) {
+ // index = readers.indexOf(abstractReader);
+ // }
+ // }
if (abstractReader instanceof EDI12Reader) {
count++;
if (index == -1) {
@@ -86,8 +85,7 @@
return null;
}
- public TagList parseEDIFile(InputStream stream, SmooksResourceListType resourceList)
throws IOException,
- DocumentException {
+ public TagList parseEDIFile(InputStream stream, SmooksResourceListType resourceList)
throws IOException {
// String encoding = null;
// String mappingModel = null;
// String validate = null;
@@ -117,16 +115,15 @@
// resourceList);
}
- public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj, IProject
project) throws IOException,
- DocumentException {
+ public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj, IProject
project) throws IOException {
String encoding = null;
String mappingModel = null;
String validate = null;
-// if (readerObj instanceof EDIReader) {
-// EDIReader reader = (EDIReader) readerObj;
-// encoding = reader.getEncoding();
-// mappingModel = reader.getMappingModel();
-// }
+ // if (readerObj instanceof EDIReader) {
+ // EDIReader reader = (EDIReader) readerObj;
+ // encoding = reader.getEncoding();
+ // mappingModel = reader.getMappingModel();
+ // }
if (readerObj instanceof EDI12Reader) {
EDI12Reader reader = (EDI12Reader) readerObj;
encoding = reader.getEncoding();
@@ -135,15 +132,15 @@
return parseEDIFile(ediInputStream, mappingModel, encoding, validate, project);
}
- public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj) throws
IOException, DocumentException {
+ public TagList parseEDIFile(InputStream ediInputStream, EObject readerObj) throws
IOException {
String encoding = null;
String mappingModel = null;
-// if (readerObj instanceof EDIReader) {
-// EDIReader reader = (EDIReader) readerObj;
-// encoding = reader.getEncoding();
-// mappingModel = reader.getMappingModel();
-// }
+ // if (readerObj instanceof EDIReader) {
+ // EDIReader reader = (EDIReader) readerObj;
+ // encoding = reader.getEncoding();
+ // mappingModel = reader.getMappingModel();
+ // }
if (readerObj instanceof EDI12Reader) {
EDI12Reader reader = (EDI12Reader) readerObj;
encoding = reader.getEncoding();
@@ -153,7 +150,7 @@
}
public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding,
- String validate, EObject emodel) throws IOException, DocumentException {
+ String validate, EObject emodel) throws IOException {
IResource resource = SmooksUIUtils.getResource(emodel);
IProject project = null;
if (resource != null) {
@@ -163,14 +160,14 @@
}
public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding,
- String validate, IProject project) throws IOException, DocumentException {
+ String validate, IProject project) throws IOException {
Smooks smooks = new Smooks();
// SmooksResourceConfiguration readerConfig = new
// SmooksResourceConfiguration("org.xml.sax.driver",
// SmooksEDIReader.class.getName());
- if (mappingModel == null){
+ if (mappingModel == null) {
throw new RuntimeException("EDI Mapping file can't be empty");
}
// If the MappingModel is absolute file path :
@@ -212,7 +209,7 @@
ediFileEncoding = "UTF-8"; //$NON-NLS-1$
}
// readerConfig.
-// readerConfig.setParameter("encoding", ediFileEncoding);
+ // readerConfig.setParameter("encoding", ediFileEncoding);
smooks.setReaderConfig(readerConfig);
// SmooksUtil.registerResource(readerConfig, smooks);
@@ -225,18 +222,13 @@
// in
// the domResult instance...
// FileInputStream stream
- StringResult result = new StringResult();
+ DOMResult result = new DOMResult();
smooks.filterSource(new StreamSource(ediInputStream), result);
- String resultXMLContent = result.getResult();
+ Document resultXMLContent = (Document) result.getNode();
XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
- ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(resultXMLContent.getBytes());
- TagList tagList = analyzer.analyze(byteinputStream, null);
+ TagList tagList = analyzer.analyze(resultXMLContent, null);
try {
- if (byteinputStream != null) {
- byteinputStream.close();
- byteinputStream = null;
- }
if (smooks != null) {
smooks.close();
smooks = null;
@@ -254,7 +246,7 @@
}
public TagList parseEDIFile(String path, SmooksResourceListType smooksResourceListType)
- throws InvocationTargetException, FileNotFoundException, IOException,
DocumentException {
+ throws InvocationTargetException, FileNotFoundException, IOException {
String filePath = SmooksUIUtils.parseFilePath(path);
return parseEDIFile(new FileInputStream(filePath), smooksResourceListType);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JsonInputDataParser.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -3,7 +3,6 @@
*/
package org.jboss.tools.smooks.configuration.editors.uitls;
-import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
@@ -18,9 +17,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
-import org.dom4j.DocumentException;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
@@ -31,7 +30,7 @@
import org.milyn.Smooks;
import org.milyn.cdr.Parameter;
import org.milyn.json.JSONReaderConfigurator;
-import org.milyn.payload.StringResult;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
@@ -52,7 +51,7 @@
public static final String ROOT_NAME = "rootName"; //$NON-NLS-1$
public IXMLStructuredObject parseJsonFile(InputStream inputStream, Object readerObj)
- throws ParserConfigurationException, DocumentException {
+ throws ParserConfigurationException {
String rootName = null;
String arrayElementName = null;
String keyWhitspaceReplacement = null;
@@ -114,7 +113,7 @@
}
public IXMLStructuredObject parseJsonFile(InputStream stream, SmooksResourceListType
resourceList)
- throws FileNotFoundException, ParserConfigurationException, DocumentException,
InvocationTargetException {
+ throws FileNotFoundException, ParserConfigurationException, InvocationTargetException
{
List<AbstractReader> readers = resourceList.getAbstractReader();
int count = 0;
@@ -140,7 +139,7 @@
}
public IXMLStructuredObject parseJsonFile(String filePath, SmooksResourceListType
resourceList)
- throws FileNotFoundException, ParserConfigurationException, DocumentException,
InvocationTargetException {
+ throws FileNotFoundException, ParserConfigurationException, InvocationTargetException
{
FileInputStream stream = new FileInputStream(filePath);
return this.parseJsonFile(stream, resourceList);
}
@@ -148,7 +147,7 @@
public IXMLStructuredObject parseJsonFile(String filePath, String rootName, String
arrayElementName,
String keyWhitspaceReplacement, String keyPrefixOnNumeric, String
illegalElementNameCharReplacement,
String nullValueReplacement, Map<String, String> keyMap, String indent, String
encoding)
- throws FileNotFoundException, ParserConfigurationException, DocumentException,
InvocationTargetException {
+ throws FileNotFoundException, ParserConfigurationException, InvocationTargetException
{
return this.parseJsonFile(new FileInputStream(SmooksUIUtils.parseFilePath(filePath)),
rootName,
arrayElementName, keyWhitspaceReplacement, keyPrefixOnNumeric,
illegalElementNameCharReplacement,
nullValueReplacement, keyMap, indent, encoding);
@@ -157,7 +156,7 @@
public IXMLStructuredObject parseJsonFile(InputStream inputStream, String rootName,
String arrayElementName,
String keyWhitspaceReplacement, String keyPrefixOnNumeric, String
illegalElementNameCharReplacement,
String nullValueReplacement, Map<String, String> keyMap, String indent, String
encoding)
- throws ParserConfigurationException, DocumentException {
+ throws ParserConfigurationException {
Smooks smooks = new Smooks();
@@ -197,21 +196,18 @@
// Use a DOM result to capture the message model for the supplied CSV
// message...
- StringResult result = new StringResult();
+ DOMResult result = new DOMResult();
// Filter the message through Smooks and capture the result as a DOM in
// the domResult instance...
smooks.filterSource(new StreamSource(inputStream), result);
+ Document document = (Document) result.getNode();
+
XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
- ByteArrayInputStream byteinputStream = new
ByteArrayInputStream(result.getResult().getBytes());
- TagList tagList = analyzer.analyze(byteinputStream, null);
+ TagList tagList = analyzer.analyze(document, null);
try {
- if (byteinputStream != null) {
- byteinputStream.close();
- byteinputStream = null;
- }
if (smooks != null) {
smooks.close();
smooks = null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -15,10 +15,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.w3c.dom.Element;
/**
* @author Dart Peng
@@ -31,9 +29,9 @@
protected Element referenceElement = null;
protected boolean canEdit = false;
-
+
private String namespaceURI = null;
-
+
private String namespacePrefix = null;
public boolean isCanEdit() {
@@ -55,8 +53,7 @@
public String getNamespaceURI() {
Element element = this.getReferenceElement();
if (element != null) {
- Namespace ns = element.getNamespace();
- return ns.getURI();
+ return element.getNamespaceURI();
}
return namespaceURI;
}
@@ -64,9 +61,9 @@
public void setNamespaceURI(String namespaceURL) {
Element element = this.getReferenceElement();
if (element != null) {
- Namespace ns = element.getNamespace();
- Namespace nns = new Namespace(ns.getPrefix(), namespaceURL);
- element.setQName(new QName(name, nns));
+ // Namespace ns = element.getNamespace();
+ // Namespace nns = new Namespace(ns.getPrefix(), namespaceURL);
+ // element.setQName(new QName(name, nns));
}
this.namespaceURI = namespaceURL;
}
@@ -77,8 +74,7 @@
public String getNameSpacePrefix() {
Element element = this.getReferenceElement();
if (element != null) {
- Namespace ns = element.getNamespace();
- return ns.getPrefix();
+ return element.getPrefix();
}
return namespacePrefix;
}
@@ -90,9 +86,9 @@
public void setNameSpacePrefix(String nameSpacePrefix) {
Element element = this.getReferenceElement();
if (element != null) {
- Namespace ns = element.getNamespace();
- Namespace nns = new Namespace(nameSpacePrefix, ns.getURI());
- element.setQName(new QName(name, nns));
+ // Namespace ns = element.getNamespace();
+ // Namespace nns = new Namespace(nameSpacePrefix, ns.getURI());
+ // element.setQName(new QName(name, nns));
}
this.namespacePrefix = nameSpacePrefix;
}
@@ -111,17 +107,17 @@
this.name = name;
Element element = this.getReferenceElement();
if (element != null) {
- element.setQName(new QName(name, element.getNamespace()));
+ // element.setQName(new QName(name, element.getNamespace()));
}
}
- public void setQName(QName name) {
- this.name = name.getName();
- Element element = this.getReferenceElement();
- if (element != null) {
- element.setQName(name);
- }
- }
+ // public void setQName(QName name) {
+ // this.name = name.getName();
+ // Element element = this.getReferenceElement();
+ // if (element != null) {
+ // element.setQName(name);
+ // }
+ // }
public List<AbstractXMLObject> getXMLNodeChildren() {
return children;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -14,9 +14,9 @@
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Element;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
/**
* @author Dart Peng
@@ -37,13 +37,13 @@
this.getProperties().add(pro);
if (pro != null)
pro.setParent(this);
- Attribute attribute = pro.getReferenceAttibute();
+ Attr attribute = pro.getReferenceAttibute();
Element parentElement = getReferenceElement();
if (attribute != null && parentElement != null) {
- if (attribute.getParent() == parentElement) {
+ if (attribute.getParentNode() == parentElement) {
return;
}
- parentElement.add(attribute);
+ parentElement.appendChild(attribute);
}
}
@@ -52,10 +52,10 @@
if (pro != null)
pro.setParent(null);
- Attribute attribute = pro.getReferenceAttibute();
+ Attr attribute = pro.getReferenceAttibute();
Element parentElement = getReferenceElement();
if (attribute != null && parentElement != null) {
- parentElement.remove(attribute);
+ parentElement.removeAttributeNode(attribute);
}
}
@@ -66,10 +66,10 @@
Element childElement = tag.getReferenceElement();
Element parentElement = getReferenceElement();
if (childElement != null && parentElement != null) {
- if (childElement.getParent() == parentElement) {
+ if (childElement.getParentNode() == parentElement) {
return;
}
- parentElement.add(childElement);
+ parentElement.appendChild(childElement);
}
}
@@ -81,16 +81,16 @@
Element childElement = tag.getReferenceElement();
Element parentElement = getReferenceElement();
if (childElement != null && parentElement != null) {
- parentElement.remove(childElement);
+ parentElement.removeChild(childElement);
}
}
@Override
public List<IXMLStructuredObject> getChildren() {
- List all = new ArrayList();
- List tags = this.getXMLNodeChildren();
- List properties = this.getProperties();
+ List<IXMLStructuredObject> all = new ArrayList<IXMLStructuredObject>();
+ List<AbstractXMLObject> tags = this.getXMLNodeChildren();
+ List<TagPropertyObject> properties = this.getProperties();
all.addAll(properties);
all.addAll(tags);
return all;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -13,12 +13,9 @@
import java.util.Collections;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-import org.dom4j.dom.DOMDocumentFactory;
+import org.w3c.dom.Attr;
+
/**
* @author Dart Peng
* @Date Jul 25, 2008
@@ -29,10 +26,10 @@
protected String value = null;
- protected Attribute referenceAttibute;
+ protected Attr referenceAttibute;
public String getValue() {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
return attribute.getValue();
}
@@ -41,7 +38,7 @@
public void setValue(String value) {
this.value = value;
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
attribute.setValue(value);
}
@@ -50,7 +47,7 @@
/**
* @return the referenceAttibute
*/
- public Attribute getReferenceAttibute() {
+ public Attr getReferenceAttibute() {
return referenceAttibute;
}
@@ -63,7 +60,7 @@
*/
@Override
public String getName() {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
return attribute.getName();
} else {
@@ -79,9 +76,9 @@
*/
@Override
public String getNameSpacePrefix() {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
- return attribute.getNamespacePrefix();
+ return attribute.getPrefix();
}
return null;
}
@@ -94,7 +91,7 @@
*/
@Override
public String getNamespaceURI() {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
return attribute.getNamespaceURI();
}
@@ -114,17 +111,17 @@
return;
}
super.setName(name);
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
- String namespace = attribute.getNamespaceURI();
- String namespacePrefix = attribute.getNamespacePrefix();
- Element container = attribute.getParent();
- String value = attribute.getValue();
- container.remove(attribute);
- Attribute newAttribute = DOMDocumentFactory.getInstance().createAttribute(container,
- new QName(name, new Namespace(namespacePrefix, namespace)), value);
- container.add(newAttribute);
- this.setReferenceAttibute(newAttribute);
+// String namespace = attribute.getNamespaceURI();
+// String namespacePrefix = attribute.getNamespacePrefix();
+// Element container = attribute.getParent();
+// String value = attribute.getValue();
+// container.remove(attribute);
+// Attr newAttribute = DOMDocumentFactory.getInstance().createAttribute(container,
+// new QName(name, new Namespace(namespacePrefix, namespace)), value);
+// container.add(newAttribute);
+// this.setReferenceAttibute(newAttribute);
}
}
@@ -136,9 +133,9 @@
*/
@Override
public void setNameSpacePrefix(String nameSpacePrefix) {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
- attribute.setNamespace(new Namespace(nameSpacePrefix, attribute.getNamespaceURI()));
+ attribute.setPrefix(nameSpacePrefix);
}
}
@@ -150,9 +147,9 @@
*/
@Override
public void setNamespaceURI(String namespaceURI) {
- Attribute attribute = getReferenceAttibute();
+ Attr attribute = getReferenceAttibute();
if (attribute != null) {
- attribute.setNamespace(new Namespace(attribute.getNamespacePrefix(), namespaceURI));
+// attribute.setNamespace(new Namespace(attribute.getNamespacePrefix(),
namespaceURI));
}
}
@@ -160,7 +157,7 @@
* @param referenceAttibute
* the referenceAttibute to set
*/
- public void setReferenceAttibute(Attribute referenceAttibute) {
+ public void setReferenceAttibute(Attr referenceAttibute) {
this.referenceAttibute = referenceAttibute;
}
@@ -184,7 +181,7 @@
@Override
public List<AbstractXMLObject> getXMLNodeChildren() {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
@Override
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -11,53 +11,73 @@
package org.jboss.tools.smooks.configuration.editors.xml;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+
/**
* @author Dart Peng
* @Date Jul 25, 2008
*/
public class XMLObjectAnalyzer {
- public TagList analyze(String xmlFilePath,String[] ignoreNodeNames)
- throws FileNotFoundException, DocumentException {
+ public TagList analyze(String xmlFilePath, String[] ignoreNodeNames) throws
ParserConfigurationException, SAXException, IOException {
FileInputStream stream = new FileInputStream(xmlFilePath);
- TagList list = this.analyze(stream,ignoreNodeNames);
+ TagList list = this.analyze(stream, ignoreNodeNames);
try {
stream.close();
} catch (IOException e) {
}
return list;
}
-
- public TagList analyze(InputStream stream , String[] ignoreNodeNames) throws
DocumentException {
- SAXReader reader = new SAXReader();
- Document doc = reader.read(stream);
- Element rootElement = doc.getRootElement();
+
+ public TagList analyze(Document doc , String[] ignoreNodeNames){
+ if(doc == null) return null;
+ Element rootElement = doc.getDocumentElement();
TagList dco = new TagList();
dco.setName("Docuement"); //$NON-NLS-1$
- dco.addRootTag( parseElement(rootElement, null , ignoreNodeNames));
+ dco.addRootTag(parseElement(rootElement, null, ignoreNodeNames));
return dco;
}
-
- public TagObject analyzeFregment(InputStream stream,String[] ignoreNodeNames) throws
DocumentException {
- SAXReader reader = new SAXReader();
- Document doc = reader.read(stream);
- Element rootElement = doc.getRootElement();
- return parseElement(rootElement, null ,ignoreNodeNames);
+
+ public TagList analyze(InputStream stream, String[] ignoreNodeNames) throws
ParserConfigurationException, SAXException, IOException {
+ DocumentBuilder builder = createDocumentBuildingFactory();
+ Document doc = builder.parse(stream);
+ return analyze(doc, ignoreNodeNames);
}
- protected TagObject getChildTagByName(String name, TagObject tag , String[]
ignoreNodeNames) {
- if(isIgnoreNode(name, ignoreNodeNames)) return null;
+ public DocumentBuilder createDocumentBuildingFactory() throws
ParserConfigurationException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(true);
+
+ factory.setExpandEntityReferences(false);
+ return factory.newDocumentBuilder();
+ }
+
+ public TagObject analyzeFregment(InputStream stream, String[] ignoreNodeNames) throws
ParserConfigurationException,
+ SAXException, IOException {
+ DocumentBuilder builder = createDocumentBuildingFactory();
+ org.w3c.dom.Document doc = builder.parse(stream);
+ Element rootElement = doc.getDocumentElement();
+ return parseElement(rootElement, null, ignoreNodeNames);
+ }
+
+ protected TagObject getChildTagByName(String name, TagObject tag, String[]
ignoreNodeNames) {
+ if (isIgnoreNode(name, ignoreNodeNames))
+ return null;
if (tag == null)
return null;
List<?> list = tag.getXMLNodeChildren();
@@ -68,45 +88,51 @@
}
return null;
}
-
- private boolean isIgnoreNode(Element element , String[] ignoreNodeNames){
- return isIgnoreNode(element.getName(), ignoreNodeNames);
+
+ private boolean isIgnoreNode(Element element, String[] ignoreNodeNames) {
+ return isIgnoreNode(element.getNodeName(), ignoreNodeNames);
}
-
-// private boolean isIgnoreNode(TagObject element , String[] ignoreNodeNames){
-// return isIgnoreNode(element.getName(), ignoreNodeNames);
-// }
-
- private boolean isIgnoreNode(String name , String[] ignoreNodeNames){
- if(ignoreNodeNames == null) return false;
+
+ // private boolean isIgnoreNode(TagObject element , String[]
+ // ignoreNodeNames){
+ // return isIgnoreNode(element.getName(), ignoreNodeNames);
+ // }
+
+ private boolean isIgnoreNode(String name, String[] ignoreNodeNames) {
+ if (ignoreNodeNames == null)
+ return false;
for (int i = 0; i < ignoreNodeNames.length; i++) {
String ignore = ignoreNodeNames[i];
- if(ignore.trim().equalsIgnoreCase(name)) return true;
+ if (ignore.trim().equalsIgnoreCase(name))
+ return true;
}
return false;
}
- protected TagObject parseElement(Element element, TagObject parentTag , String[]
ignoreNodeNames) {
-
- if(isIgnoreNode(element, ignoreNodeNames))
+ protected TagObject parseElement(Element element, TagObject parentTag, String[]
ignoreNodeNames) {
+
+ if (isIgnoreNode(element, ignoreNodeNames))
return null;
boolean canAdd = false;
- TagObject tag = getChildTagByName(element.getName(), parentTag , ignoreNodeNames);
+ TagObject tag = getChildTagByName(element.getNodeName(), parentTag, ignoreNodeNames);
if (tag == null) {
tag = new TagObject();
canAdd = true;
}
tag.setReferenceElement(element);
- tag.setName(element.getName());
- fillProperties(element, tag ,ignoreNodeNames);
+ tag.setName(element.getNodeName());
+ fillProperties(element, tag, ignoreNodeNames);
tag.setNamespaceURI(element.getNamespaceURI());
- List<?> list = element.elements();
- for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
- Element childElement = (Element) iterator.next();
- TagObject t = parseElement(childElement, tag , ignoreNodeNames);
- if (t != null){
- t.setReferenceElement(childElement);
- tag.addChildTag(t);
+ NodeList nodeList = element.getChildNodes();
+ for(int i = 0 ; i < nodeList.getLength() ; i++){
+ Node node = nodeList.item(i);
+ if(node instanceof Element){
+ Element childElement = (Element)node;
+ TagObject t = parseElement(childElement, tag, ignoreNodeNames);
+ if (t != null) {
+ t.setReferenceElement(childElement);
+ tag.addChildTag(t);
+ }
}
}
if (canAdd)
@@ -125,21 +151,25 @@
return false;
}
- protected void fillProperties(Element element, TagObject tag , String[] ignoreNodeNames)
{
- Iterator<?> it = element.attributeIterator();
- for (Iterator<?> iterator = it; iterator.hasNext();) {
- Attribute attr = (Attribute) iterator.next();
- String attrName = attr.getName();
- String value = attr.getValue();
- if(isIgnoreNode(attrName, ignoreNodeNames)) continue;
- if (hasSameNameProperty(attrName, tag)) {
- continue;
+ protected void fillProperties(Element element, TagObject tag, String[] ignoreNodeNames)
{
+ NamedNodeMap attrMap = element.getAttributes();
+ for (int i = 0; i < attrMap.getLength(); i++) {
+ Node node = attrMap.item(i);
+ if(node instanceof Attr){
+ Attr attr = (Attr)node;
+ String attrName = attr.getName();
+ String value = attr.getValue();
+ if (isIgnoreNode(attrName, ignoreNodeNames))
+ continue;
+ if (hasSameNameProperty(attrName, tag)) {
+ continue;
+ }
+ TagPropertyObject pro = new TagPropertyObject();
+ pro.setName(attr.getName());
+ pro.setValue(value);
+ pro.setNamespaceURI(attr.getNamespaceURI());
+ tag.addProperty(pro);
}
- TagPropertyObject pro = new TagPropertyObject();
- pro.setName(attr.getName());
- pro.setValue(value);
- pro.setNamespaceURI(attr.getNamespaceURI());
- tag.addProperty(pro);
}
}
}
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer2.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer2.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer2.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -1,137 +0,0 @@
-/**
- *
- */
-package org.jboss.tools.smooks.configuration.editors.xml;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
-
-/**
- * @author Dart
- *
- */
-public class XMLObjectAnalyzer2 {
- public TagList analyze(String xmlFilePath, String[] ignoreNodeNames) throws
FileNotFoundException,
- DocumentException {
- FileInputStream stream = new FileInputStream(xmlFilePath);
- return this.analyze(stream, ignoreNodeNames);
- }
-
- public TagList analyze(InputStream stream, String[] ignoreNodeNames) throws
DocumentException {
- SAXReader reader = new SAXReader();
- Document doc = reader.read(stream);
- Element rootElement = doc.getRootElement();
- TagList dco = new TagList();
- dco.setName("Docuement"); //$NON-NLS-1$
- dco.addRootTag(parseElement(rootElement, null, ignoreNodeNames));
- return dco;
- }
-
- public TagObject analyzeFregment(InputStream stream, String[] ignoreNodeNames) throws
DocumentException {
- SAXReader reader = new SAXReader();
- Document doc = reader.read(stream);
- Element rootElement = doc.getRootElement();
- return parseElement(rootElement, null, ignoreNodeNames);
- }
-
- protected TagObject getChildTagByName(String name, TagObject tag, String[]
ignoreNodeNames) {
- if (isIgnoreNode(name, ignoreNodeNames))
- return null;
- if (tag == null)
- return null;
- List<?> list = tag.getXMLNodeChildren();
- for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
- TagObject tagc = (TagObject) iterator.next();
- if (tagc.getName().equals(name))
- return tagc;
- }
- return null;
- }
-
- private boolean isIgnoreNode(Element element, String[] ignoreNodeNames) {
- return isIgnoreNode(element.getName(), ignoreNodeNames);
- }
-
- // private boolean isIgnoreNode(TagObject element , String[]
- // ignoreNodeNames){
- // return isIgnoreNode(element.getName(), ignoreNodeNames);
- // }
-
- private boolean isIgnoreNode(String name, String[] ignoreNodeNames) {
- if (ignoreNodeNames == null)
- return false;
- for (int i = 0; i < ignoreNodeNames.length; i++) {
- String ignore = ignoreNodeNames[i];
- if (ignore.trim().equalsIgnoreCase(name))
- return true;
- }
- return false;
- }
-
- protected TagObject parseElement(Element element, TagObject parentTag, String[]
ignoreNodeNames) {
-
- if (isIgnoreNode(element, ignoreNodeNames))
- return null;
- boolean canAdd = false;
- TagObject tag = getChildTagByName(element.getName(), parentTag, ignoreNodeNames);
- if (tag == null) {
- tag = new TagObject();
- canAdd = true;
- }
- tag.setReferenceElement(element);
- tag.setName(element.getName());
- fillProperties(element, tag, ignoreNodeNames);
- tag.setNamespaceURI(element.getNamespaceURI());
- List<?> list = element.elements();
- for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
- Element childElement = (Element) iterator.next();
- TagObject t = parseElement(childElement, tag, ignoreNodeNames);
- if (t != null) {
- t.setReferenceElement(childElement);
- tag.addChildTag(t);
- }
- }
- if (canAdd)
- return tag;
- else
- return null;
- }
-
- protected boolean hasSameNameProperty(String proName, TagObject tag) {
- List<TagPropertyObject> pros = tag.getProperties();
- for (Iterator<TagPropertyObject> iterator = pros.iterator(); iterator.hasNext();)
{
- TagPropertyObject tp = (TagPropertyObject) iterator.next();
- if (tp.getName().equals(proName))
- return true;
- }
- return false;
- }
-
- protected void fillProperties(Element element, TagObject tag, String[] ignoreNodeNames)
{
- Iterator<?> it = element.attributeIterator();
- for (Iterator<?> iterator = it; iterator.hasNext();) {
- Attribute attr = (Attribute) iterator.next();
- String attrName = attr.getName();
- String value = attr.getValue();
- if (isIgnoreNode(attrName, ignoreNodeNames))
- continue;
- if (hasSameNameProperty(attrName, tag)) {
- continue;
- }
- TagPropertyObject pro = new TagPropertyObject();
- pro.setName(attr.getName());
- pro.setValue(value);
- pro.setNamespaceURI(attr.getNamespaceURI());
- tag.addProperty(pro);
- }
- }
-}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ls.LSSerializer;
+
+/**
+ * @author Dart
+ *
+ */
+public class XMLUtils {
+
+ public static DocumentBuilder getDOMBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ return dbf.newDocumentBuilder();
+ }
+
+ public static Transformer getTransformer() throws TransformerConfigurationException {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ return tf.newTransformer();
+ }
+
+ public static Document createDocument() throws ParserConfigurationException {
+ return XMLUtils.getDOMBuilder().newDocument();
+ }
+
+ public static Element firstChildElement(Node node) {
+ for (Node tempNode = node.getFirstChild(); tempNode != null; tempNode =
tempNode.getNextSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element nextSiblingElement(Node node) {
+ for (Node tempNode = node.getNextSibling(); tempNode != null; tempNode =
tempNode.getNextSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element lastChildElement(Node node) {
+ for (Node tempNode = node.getLastChild(); tempNode != null; tempNode =
tempNode.getPreviousSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element previousSiblingElement(Node node) {
+ for (Node tempNode = node.getPreviousSibling(); tempNode != null; tempNode =
tempNode.getPreviousSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static List<Element> getAllChildElements(Node node) {
+ List<Element> v = new ArrayList<Element>();
+ Node child = XMLUtils.firstChildElement(node);
+ while (child != null) {
+ v.add((Element) child);
+ child = XMLUtils.nextSiblingElement(child);
+ }
+ return v;
+ }
+
+ public static List<Element> getChildElementsByNS(Node node, String uri, String
localName) {
+ List<Element> childElements = XMLUtils.getAllChildElements(node);
+ List<Element> v = new ArrayList<Element>();
+ for (int i = 0; i < childElements.size(); i++) {
+ Element child = (Element) childElements.get(i);
+ String ln = child.getLocalName();
+ String u = child.getNamespaceURI();
+ if (uri == null) {
+ if (ln.equals(localName)) {
+ v.add(child);
+ }
+ } else {
+ if (ln.equals(localName) && u.equals(uri)) {
+ v.add(child);
+ }
+ }
+ }
+ return v;
+ }
+
+ public static String getLocalName(String nodeName) {
+ int index = nodeName.lastIndexOf(58);
+ if (index == -1) {
+ return nodeName;
+ } else {
+ return nodeName.substring(index + 1, nodeName.length());
+ }
+ }
+
+ public static String getPrefix(String nodeName) {
+ int index = nodeName.lastIndexOf(58);
+ if (index == -1) {
+ return null;
+ } else {
+ return nodeName.substring(0, index);
+ }
+ }
+
+ public static void outDOMNode(Node node, Writer writer) throws
TransformerConfigurationException,
+ TransformerException {
+ Transformer transformer = XMLUtils.getTransformer();
+ Source source = new DOMSource(node);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ }
+
+ public static void outDOMNode(Node node, OutputStream os) throws
TransformerConfigurationException,
+ TransformerException {
+ Transformer transformer = XMLUtils.getTransformer();
+ Source source = new DOMSource(node);
+ Result result = new StreamResult(os);
+ transformer.transform(source, result);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLModelAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLModelAnalyzer.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLModelAnalyzer.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -17,14 +17,13 @@
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.io.SAXReader;
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.xerces.util.DOMEntityResolverWrapper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -60,121 +59,121 @@
}
return false;
}
-
- public TagObject parse(IFile file) throws DocumentException, CoreException {
- return parse(file.getContents());
- }
-
- public TagObject parse(String filePath) throws FileNotFoundException, DocumentException
{
- File file = new File(filePath);
- return parse(new FileInputStream(file));
- }
-
- public TagObject parse(InputStream inputStream, String[] ignoreXSLElementnames) throws
DocumentException {
- SAXReader reader = new SAXReader();
- Document document = reader.read(inputStream);
- Element rootElement = document.getRootElement();
- Namespace namespace =
rootElement.getNamespaceForURI("http://milyn.codehaus.org/Smooks");
//$NON-NLS-1$
- TagObject tag = (TagObject) parseElement(rootElement, ignoreXSLElementnames,
namespace);
- return tag;
- }
-
- public TagObject parse(InputStream inputStream) throws DocumentException {
- return parse(inputStream, new String[] { "output", "value-of" });
//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private boolean isIgnoreXSLTag(Element element, String[] ignoreXSLElementNames) {
- if (isXSLElement(element) && ignoreXSLElementNames != null) {
- for (int i = 0; i < ignoreXSLElementNames.length; i++) {
- String name = ignoreXSLElementNames[i];
- String en = element.getName();
- if (en != null) {
- en = en.trim();
- }
- if (name.equalsIgnoreCase(en)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private TagObject createTagObject(Element element, boolean createAttributes, Namespace
namespace) {
- XSLTagObject tag = new XSLTagObject();
- tag.setNameSpacePrefix(element.getNamespacePrefix());
- tag.setName(element.getName());
- tag.setNamespaceURI(element.getNamespaceURI());
- tag.setReferenceElement(element);
- if (namespace != null) {
- tag.setSmooksPrix(namespace.getPrefix());
- }
- List<?> attributes = element.attributes();
- if (createAttributes) {
- for (Iterator<?> iterator = attributes.iterator(); iterator.hasNext();) {
- Attribute attribute = (Attribute) iterator.next();
- TagPropertyObject pro = new TagPropertyObject();
- pro.setName(attribute.getName());
- pro.setNamespaceURI(attribute.getNamespaceURI());
- pro.setNameSpacePrefix(attribute.getNamespacePrefix());
- pro.setValue(attribute.getValue());
- pro.setReferenceAttibute(attribute);
- ((TagObject) tag).addProperty(pro);
- }
- }
-
- return tag;
- }
-
- private AbstractXMLObject parseElement(Element rootElement, String[]
ignoreXSLElementNames, Namespace namespace) {
- if (rootElement != null) {
- AbstractXMLObject tag = null;
- if (isIgnoreXSLTag(rootElement, ignoreXSLElementNames)) {
- tag = new TagList();
- } else {
- tag = createTagObject(rootElement, true, namespace);
- }
-
- List<?> childrenElements = rootElement.elements();
- for (Iterator<?> iterator = childrenElements.iterator(); iterator.hasNext();) {
- Element element = (Element) iterator.next();
- TagObject xt = null;
- if (isIgnoreXSLTag(element, ignoreXSLElementNames)) {
- xt = createTagObject(element, true, namespace);
- }
- AbstractXMLObject t = parseElement(element, ignoreXSLElementNames, namespace);
- if (t != null) {
- if (tag instanceof TagList) {
- if (t instanceof XSLTagObject) {
- ((TagList) tag).addRootTag((TagObject) t);
- ((XSLTagObject) tag).addRelatedIgnoreXSLTagObject(xt);
- }
- if (t instanceof TagList) {
- List<TagObject> tagObjectList = ((TagList) t).getRootTagList();
- for (Iterator<?> iterator2 = tagObjectList.iterator(); iterator2.hasNext();)
{
- TagObject tagObject = (TagObject) iterator2.next();
- ((TagList) tag).addRootTag(tagObject);
- }
- }
- }
- if (tag instanceof XSLTagObject) {
- ((XSLTagObject) tag).addRelatedIgnoreXSLTagObject(xt);
- if (t instanceof TagObject) {
- ((TagObject) tag).addChildTag((TagObject) t);
- }
- if (t instanceof TagList) {
- List<TagObject> tagObjectList = ((TagList) t).getRootTagList();
- for (Iterator<?> iterator2 = tagObjectList.iterator(); iterator2.hasNext();)
{
- TagObject tagObject = (TagObject) iterator2.next();
- ((TagObject) tag).addChildTag(tagObject);
- }
- }
- }
- }
- }
-
- return tag;
- }
-
- return null;
- }
+//
+// public TagObject parse(IFile file) throws CoreException {
+// return parse(file.getContents());
+// }
+//
+// public TagObject parse(String filePath) throws FileNotFoundException {
+// File file = new File(filePath);
+// return parse(new FileInputStream(file));
+// }
+//
+// public TagObject parse(InputStream inputStream, String[] ignoreXSLElementnames) {
+// DocumentBuilder builder = XMLUtils.getDOMBuilder();
+// Document document = builder.parse(inputStream);//.read(inputStream);
+// Element rootElement = document.getDocumentElement();
+// Namespace namespace =
rootElement.getNamespaceForURI("http://milyn.codehaus.org/Smooks");
//$NON-NLS-1$
+// TagObject tag = (TagObject) parseElement(rootElement, ignoreXSLElementnames,
namespace);
+// return tag;
+// }
+//
+// public TagObject parse(InputStream inputStream) throws DocumentException {
+// return parse(inputStream, new String[] { "output", "value-of" });
//$NON-NLS-1$ //$NON-NLS-2$
+// }
+//
+// private boolean isIgnoreXSLTag(Element element, String[] ignoreXSLElementNames) {
+// if (isXSLElement(element) && ignoreXSLElementNames != null) {
+// for (int i = 0; i < ignoreXSLElementNames.length; i++) {
+// String name = ignoreXSLElementNames[i];
+// String en = element.getName();
+// if (en != null) {
+// en = en.trim();
+// }
+// if (name.equalsIgnoreCase(en)) {
+// return true;
+// }
+// }
+// }
+// return false;
+// }
+//
+// private TagObject createTagObject(Element element, boolean createAttributes, Namespace
namespace) {
+// XSLTagObject tag = new XSLTagObject();
+// tag.setNameSpacePrefix(element.getNamespacePrefix());
+// tag.setName(element.getName());
+// tag.setNamespaceURI(element.getNamespaceURI());
+// tag.setReferenceElement(element);
+// if (namespace != null) {
+// tag.setSmooksPrix(namespace.getPrefix());
+// }
+// List<?> attributes = element.attributes();
+// if (createAttributes) {
+// for (Iterator<?> iterator = attributes.iterator(); iterator.hasNext();) {
+// Attribute attribute = (Attribute) iterator.next();
+// TagPropertyObject pro = new TagPropertyObject();
+// pro.setName(attribute.getName());
+// pro.setNamespaceURI(attribute.getNamespaceURI());
+// pro.setNameSpacePrefix(attribute.getNamespacePrefix());
+// pro.setValue(attribute.getValue());
+// pro.setReferenceAttibute(attribute);
+// ((TagObject) tag).addProperty(pro);
+// }
+// }
+//
+// return tag;
+// }
+//
+// private AbstractXMLObject parseElement(Element rootElement, String[]
ignoreXSLElementNames) {
+// if (rootElement != null) {
+// AbstractXMLObject tag = null;
+// if (isIgnoreXSLTag(rootElement, ignoreXSLElementNames)) {
+// tag = new TagList();
+// } else {
+// tag = createTagObject(rootElement, true, namespace);
+// }
+//
+// List<?> childrenElements = rootElement.elements();
+// for (Iterator<?> iterator = childrenElements.iterator(); iterator.hasNext();)
{
+// Element element = (Element) iterator.next();
+// TagObject xt = null;
+// if (isIgnoreXSLTag(element, ignoreXSLElementNames)) {
+// xt = createTagObject(element, true, namespace);
+// }
+// AbstractXMLObject t = parseElement(element, ignoreXSLElementNames, namespace);
+// if (t != null) {
+// if (tag instanceof TagList) {
+// if (t instanceof XSLTagObject) {
+// ((TagList) tag).addRootTag((TagObject) t);
+// ((XSLTagObject) tag).addRelatedIgnoreXSLTagObject(xt);
+// }
+// if (t instanceof TagList) {
+// List<TagObject> tagObjectList = ((TagList) t).getRootTagList();
+// for (Iterator<?> iterator2 = tagObjectList.iterator();
iterator2.hasNext();) {
+// TagObject tagObject = (TagObject) iterator2.next();
+// ((TagList) tag).addRootTag(tagObject);
+// }
+// }
+// }
+// if (tag instanceof XSLTagObject) {
+// ((XSLTagObject) tag).addRelatedIgnoreXSLTagObject(xt);
+// if (t instanceof TagObject) {
+// ((TagObject) tag).addChildTag((TagObject) t);
+// }
+// if (t instanceof TagList) {
+// List<TagObject> tagObjectList = ((TagList) t).getRootTagList();
+// for (Iterator<?> iterator2 = tagObjectList.iterator();
iterator2.hasNext();) {
+// TagObject tagObject = (TagObject) iterator2.next();
+// ((TagObject) tag).addChildTag(tagObject);
+// }
+// }
+// }
+// }
+// }
+//
+// return tag;
+// }
+//
+// return null;
+// }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLTagObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLTagObject.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSLTagObject.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -14,11 +14,8 @@
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.DocumentFactory;
-import org.dom4j.Element;
-import org.dom4j.QName;
-import org.dom4j.dom.DOMDocumentFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -72,8 +69,8 @@
}
return null;
}
-
- public void removeSelectProperty(){
+
+ public void removeSelectProperty() {
TagPropertyObject tagPropertyObject = null;
List<TagPropertyObject> properties = this.getProperties();
for (Iterator<?> iterator = properties.iterator(); iterator.hasNext();) {
@@ -83,15 +80,15 @@
break;
}
}
- if(tagPropertyObject != null){
+ if (tagPropertyObject != null) {
Element parentElement = this.getReferenceElement();
- Attribute att = tagPropertyObject.getReferenceAttibute();
- parentElement.remove(att);
+ Attr att = tagPropertyObject.getReferenceAttibute();
+ parentElement.removeAttributeNode(att);
this.removeProperty(tagPropertyObject);
}
}
-
- public void removeMatchProperty(){
+
+ public void removeMatchProperty() {
TagPropertyObject tagPropertyObject = null;
List<TagPropertyObject> properties = this.getProperties();
for (Iterator<?> iterator = properties.iterator(); iterator.hasNext();) {
@@ -101,16 +98,16 @@
break;
}
}
- if(tagPropertyObject != null){
+ if (tagPropertyObject != null) {
Element parentElement = this.getReferenceElement();
- Attribute att = tagPropertyObject.getReferenceAttibute();
- parentElement.remove(att);
+ Attr att = tagPropertyObject.getReferenceAttibute();
+ parentElement.removeAttributeNode(att);
this.removeProperty(tagPropertyObject);
}
}
-
- public void setSelectValue(String value){
- if(value == null){
+
+ public void setSelectValue(String value) {
+ if (value == null) {
removeSelectProperty();
return;
}
@@ -123,20 +120,20 @@
break;
}
}
- if(tagPropertyObject == null){
+ if (tagPropertyObject == null) {
tagPropertyObject = new TagPropertyObject();
- DocumentFactory factory = DOMDocumentFactory.getInstance();
Element parentElement = this.getReferenceElement();
- Attribute attribute = factory.createAttribute(parentElement, new
QName("select"), value); //$NON-NLS-1$
+ Attr attribute =
parentElement.getOwnerDocument().createAttribute("select");//.createAttribute(parentElement,
new QName("select"), value); //$NON-NLS-1$
+ attribute.setNodeValue(value);
tagPropertyObject.setReferenceAttibute(attribute);
- parentElement.add(attribute);
+ parentElement.appendChild(attribute);
this.addProperty(tagPropertyObject);
-
+
}
tagPropertyObject.setValue(value);
}
-
- public void setMatchValue(String value){
+
+ public void setMatchValue(String value) {
TagPropertyObject tagPropertyObject = null;
List<TagPropertyObject> properties = this.getProperties();
for (Iterator<?> iterator = properties.iterator(); iterator.hasNext();) {
@@ -146,12 +143,12 @@
break;
}
}
- if(tagPropertyObject == null){
+ if (tagPropertyObject == null) {
tagPropertyObject = new TagPropertyObject();
- DocumentFactory factory = DOMDocumentFactory.getInstance();
Element parentElement = this.getReferenceElement();
- Attribute attribute = factory.createAttribute(parentElement, new
QName("match"), value); //$NON-NLS-1$
- parentElement.add(attribute);
+ Attr attribute =
parentElement.getOwnerDocument().createAttribute("match");//.createAttribute(parentElement,
new QName("select"), value); //$NON-NLS-1$
+ attribute.setNodeValue(value);
+ parentElement.appendChild(attribute);
tagPropertyObject.setReferenceAttibute(attribute);
this.addProperty(tagPropertyObject);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -17,11 +17,7 @@
import java.util.Timer;
import java.util.TimerTask;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.SAXReader;
-import org.dom4j.io.XMLWriter;
+import org.apache.xml.serialize.OutputFormat;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -67,6 +63,7 @@
import org.jboss.tools.smooks.configuration.SmooksConstants;
import org.jboss.tools.smooks.configuration.editors.SmooksXMLEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.editors.xml.XMLUtils;
import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks.configuration.validate.SmooksMarkerHelper;
import org.jboss.tools.smooks.configuration.validate.SmooksModelValidator;
@@ -98,6 +95,10 @@
import
org.jboss.tools.smooks.model.validation10.provider.Validation10ItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.xsl.provider.XslItemProviderAdapterFactory;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class AbstractSmooksFormEditor extends FormEditor implements
IEditingDomainProvider,
ISmooksModelValidateListener, ISmooksModelProvider {
@@ -232,23 +233,18 @@
}
protected ByteArrayOutputStream getFormattedXMLContentsStream(InputStream outstream)
throws IOException {
- XMLWriter writer = null;
+
try {
- SAXReader parser = new SAXReader();
- Document doc = parser.read(outstream);
+ Document doc = XMLUtils.getDOMBuilder().parse(outstream);
EObject rootModel = this.getSmooksModel();
fillComments(doc, rootModel);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- OutputFormat format = OutputFormat.createPrettyPrint();
- writer = new XMLWriter(stream, format);
- writer.write(doc);
+
+ XMLUtils.outDOMNode(doc, stream);
return stream;
} catch (Throwable t) {
} finally {
- if (writer != null) {
- writer.close();
- }
}
return null;
}
@@ -257,7 +253,7 @@
try {
if (rootModel instanceof DocumentRoot) {
EObject rootElementModel = ((DocumentRoot) rootModel).getSmooksResourceList();
- Element rootElement = document.getRootElement();
+ Element rootElement = document.getDocumentElement();
try {
fillComments(rootElementModel, rootElement);
} catch (Exception e) {
@@ -275,26 +271,28 @@
for (Iterator<?> iterator = comments.iterator(); iterator.hasNext();) {
String string = (String) iterator.next();
Integer commentIndex = ((AbstractAnyType) rootElementModel).getCommentIndex(string);
- List<?> content = rootElement.elements();
+ List<?> content = XMLUtils.getAllChildElements(rootElement);
List<Object> deletedElementList = new ArrayList<Object>();
if (commentIndex.intValue() < content.size()) {
List<Object> tempelements = new ArrayList<Object>(content);
for (int i = commentIndex.intValue(); i < content.size(); i++) {
Element deleteObj = (Element) tempelements.get(i);
- if (rootElement.remove(deleteObj)) {
- deletedElementList.add(deleteObj);
+ Node remodedObj = rootElement.removeChild(deleteObj);
+ if (remodedObj != null) {
+ deletedElementList.add(remodedObj);
}
}
}
- rootElement.addComment(string);
+ Comment comment = rootElement.getOwnerDocument().createComment(string);
+ rootElement.appendChild(comment);
for (int j = 0; j < deletedElementList.size(); j++) {
Element deleteElement = (Element) deletedElementList.get(j);
- rootElement.add(deleteElement);
+ rootElement.appendChild(deleteElement);
}
}
List<EObject> childrenModel = ((AbstractAnyType) rootElementModel).eContents();
- List<?> elements = rootElement.elements();
+ List<?> elements = XMLUtils.getAllChildElements(rootElement);
int length = Math.min(childrenModel.size(), elements.size());
for (int index = 0; index < length; index++) {
EObject child = childrenModel.get(index);
@@ -561,7 +559,7 @@
if (exception != null) {
message = exception.getMessage();
}
- if(message == null){
+ if (message == null) {
message = "Unknown error.Please check the file";
}
for (Iterator<?> iterator = this.smooksInitListener.iterator();
iterator.hasNext();) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLNodeEditPart.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLNodeEditPart.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -13,12 +13,6 @@
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-import org.dom4j.dom.DOMDocumentFactory;
-import org.dom4j.tree.DefaultElement;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -50,6 +44,8 @@
import org.jboss.tools.smooks.graphical.editors.commands.ChangeXSLNodeNameCommand;
import org.jboss.tools.smooks.graphical.editors.commands.DeleteXSLNodeCommand;
import org.jboss.tools.smooks.graphical.editors.model.xsl.XSLNodeGraphicalModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -153,31 +149,31 @@
if (model instanceof XSLTagObject) {
String name = ((XSLTagObject) model).getName();
String namespace = ((XSLTagObject) model).getNamespaceURI();
- String namespaceprefix = ((XSLTagObject) model).getNameSpacePrefix();
+// String namespaceprefix = ((XSLTagObject) model).getNameSpacePrefix();
if (XSLModelAnalyzer.isXSLTagObject((XSLTagObject) parentNode)
&& XSLModelAnalyzer.isXSLTagObject((XSLTagObject) model)) {
if (!canCreateAddCommand(name, parentNode.getName())) {
return null;
}
}
- Element element = new DefaultElement(new QName(name, new Namespace(namespaceprefix,
namespace)));
+ Element element = ((XSLTagObject)
parentNode).getReferenceElement().getOwnerDocument()
+ .createElementNS(namespace, name);
((XSLTagObject) model).setReferenceElement(element);
}
if (model instanceof TagPropertyObject) {
String name = ((TagPropertyObject) model).getName();
String namespace = ((TagPropertyObject) model).getNamespaceURI();
- String namespaceprefix = ((TagPropertyObject) model).getNameSpacePrefix();
+// String namespaceprefix = ((TagPropertyObject) model).getNameSpacePrefix();
if (XSLModelAnalyzer.isXSLTagObject((XSLTagObject) parentNode)) {
return null;
}
Element parentElement = ((XSLTagObject) parentNode).getReferenceElement();
- Attribute element =
DOMDocumentFactory.getInstance().createAttribute(parentElement,
- new QName(name, new Namespace(namespaceprefix, namespace)), "");
+ Attr element = parentElement.getOwnerDocument().createAttributeNS(namespace,
name);
((TagPropertyObject) model).setReferenceAttibute(element);
}
- AddSmooksGraphicalModelCommand command = new
AddSmooksGraphicalModelCommand((AbstractSmooksGraphicalModel) graphModel,
- childGraphModel);
+ AddSmooksGraphicalModelCommand command = new AddSmooksGraphicalModelCommand(
+ (AbstractSmooksGraphicalModel) graphModel, childGraphModel);
return command;
}
return null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLTemplateEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLTemplateEditPart.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/xsl/XSLTemplateEditPart.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -10,11 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.editparts.xsl;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-import org.dom4j.dom.DOMDocumentFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
@@ -23,6 +20,7 @@
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.configuration.editors.xml.XMLUtils;
import org.jboss.tools.smooks.configuration.editors.xml.XSLModelAnalyzer;
import org.jboss.tools.smooks.configuration.editors.xml.XSLTagObject;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
@@ -32,6 +30,8 @@
import org.jboss.tools.smooks.graphical.editors.model.AbstractResourceConfigGraphModel;
import org.jboss.tools.smooks.graphical.editors.model.xsl.XSLNodeGraphicalModel;
import org.jboss.tools.smooks.model.xsl.XslPackage;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -62,7 +62,7 @@
Object model = request.getNewObject();
Object graphModel = host.getModel();
if (graphModel instanceof AbstractResourceConfigGraphModel) {
- if(!((AbstractResourceConfigGraphModel)graphModel).getChildrenWithoutDynamic().isEmpty()){
+ if (!((AbstractResourceConfigGraphModel)
graphModel).getChildrenWithoutDynamic().isEmpty()) {
return null;
}
if (model instanceof XSLTagObject) {
@@ -70,28 +70,35 @@
ITreeContentProvider provider1 = ((AbstractResourceConfigGraphModel)
graphModel).getContentProvider();
IEditingDomainProvider provider2 = ((AbstractResourceConfigGraphModel)
graphModel).getDomainProvider();
XSLNodeGraphicalModel childGraphModel = new XSLNodeGraphicalModel(model, provider1,
provider, provider2);
-
- Document documentRoot = DOMDocumentFactory.getInstance().createDocument();
-
+
+ Document documentRoot = null;
+ try {
+ documentRoot = XMLUtils.createDocument();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+
String name = ((XSLTagObject) model).getName();
String namespace = ((XSLTagObject) model).getNamespaceURI();
String namespaceprefix = ((XSLTagObject) model).getNameSpacePrefix();
-
- if(XSLModelAnalyzer.isXSLTagObject((XSLTagObject)model)){
- if(!XSLConstants.STYLESHEET.equals(name)){
+
+ if (XSLModelAnalyzer.isXSLTagObject((XSLTagObject) model)) {
+ if (!XSLConstants.STYLESHEET.equals(name)) {
return null;
}
}
-
- Element element = DOMDocumentFactory.getInstance().createElement(
- new QName(name, new Namespace(namespaceprefix, namespace)));
-
- documentRoot.setRootElement(element);
-
- ((XSLTagObject) model).setReferenceElement(element);
- AddSmooksGraphicalModelCommand command = new
AddSmooksGraphicalModelCommand((AbstractSmooksGraphicalModel) graphModel,
- childGraphModel);
- return command;
+
+ if (documentRoot != null) {
+
+ Element element = documentRoot.createElementNS(namespace, name);
+
+ documentRoot.appendChild(element);
+
+ ((XSLTagObject) model).setReferenceElement(element);
+ AddSmooksGraphicalModelCommand command = new AddSmooksGraphicalModelCommand(
+ (AbstractSmooksGraphicalModel) graphModel, childGraphModel);
+ return command;
+ }
}
}
return null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLNodeGraphicalModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLNodeGraphicalModel.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLNodeGraphicalModel.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -15,13 +15,6 @@
import java.util.Iterator;
import java.util.List;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.XMLWriter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -34,6 +27,7 @@
import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagPropertyObject;
+import org.jboss.tools.smooks.configuration.editors.xml.XMLUtils;
import org.jboss.tools.smooks.configuration.editors.xml.XSLModelAnalyzer;
import org.jboss.tools.smooks.configuration.editors.xml.XSLTagObject;
import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
@@ -43,6 +37,8 @@
import org.jboss.tools.smooks.model.xsl.Template;
import org.jboss.tools.smooks.model.xsl.Xsl;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -174,7 +170,7 @@
if (node == xmlObject) {
Element parentElement = ((XSLTagObject) data).getReferenceElement();
Element thisElement = ((XSLTagObject) object).getReferenceElement();
- parentElement.remove(thisElement);
+ parentElement.removeChild(thisElement);
((XSLTagObject) data).removeChildTag((XSLTagObject) object);
relatedTag = (XSLTagObject) object;
break;
@@ -229,14 +225,15 @@
if (relateTag == null) {
relateTag = new XSLTagObject();
Element element = ((XSLTagObject) data).getReferenceElement();
- Document doc = element.getDocument();
- Element rootElement = doc.getRootElement();
- Namespace namespace =
rootElement.getNamespaceForURI(XSLModelAnalyzer.XSL_NAME_SPACE);
+ Document doc = element.getOwnerDocument();
+ Element rootElement = doc.getDocumentElement();
+ String namespace = rootElement.getNamespaceURI();
if (namespace == null) {
- namespace = new Namespace("xsl", XSLModelAnalyzer.XSL_NAME_SPACE);
- rootElement.addNamespace("xsl", XSLModelAnalyzer.XSL_NAME_SPACE);
+ namespace = XSLModelAnalyzer.XSL_NAME_SPACE;
}
- Element newElement = element.addElement(new QName("value-of",
namespace));
+
+ Element newElement = doc.createElementNS(namespace, "value-of");
+ element.appendChild(newElement);
relateTag.setName("value-of");
relateTag.setReferenceElement(newElement);
((XSLTagObject) data).getRelatedIgnoreXSLTagObjects().add(relateTag);
@@ -254,12 +251,9 @@
if (rootElement != null) {
ByteArrayOutputStream stream = null;
- XMLWriter writer = null;
try {
stream = new ByteArrayOutputStream();
- OutputFormat format = OutputFormat.createPrettyPrint();
- writer = new XMLWriter(stream, format);
- writer.write(rootElement);
+ XMLUtils.outDOMNode(rootElement, stream);
String string = new String(stream.toByteArray());
return string;
} catch (Exception e1) {
@@ -268,8 +262,6 @@
try {
if (stream != null)
stream.close();
- if (writer != null)
- writer.close();
} catch (Throwable t) {
}
}
@@ -332,27 +324,28 @@
AbstractXMLObject xmlNode = (AbstractXMLObject) node.getData();
AbstractXMLObject thisNode = (AbstractXMLObject) this.getData();
Element element = thisNode.getReferenceElement();
- if (xmlNode instanceof TagObject) {
- Element childElement = xmlNode.getReferenceElement();
- if (element.elements().indexOf(childElement) != -1) {
- element.elements().remove(childElement);
- int size = element.attributes().size();
- int realIndex = index;
- if (!XSLModelAnalyzer.isXSLTagObject(thisNode)) {
- realIndex = index - size;
- }
- element.elements().add(realIndex, childElement);
- }
- }
- if (xmlNode instanceof TagPropertyObject) {
- Attribute attribute = ((TagPropertyObject) xmlNode).getReferenceAttibute();
- if (element.attributes().indexOf(attribute) != -1) {
- int size = element.elements().size();
- int realIndex = index - size;
- element.attributes().remove(attribute);
- element.attributes().add(realIndex, attribute);
- }
- }
+ // if (xmlNode instanceof TagObject) {
+ // Element childElement = xmlNode.getReferenceElement();
+ // if (element..indexOf(childElement) != -1) {
+ // element.elements().remove(childElement);
+ // int size = element.attributes().size();
+ // int realIndex = index;
+ // if (!XSLModelAnalyzer.isXSLTagObject(thisNode)) {
+ // realIndex = index - size;
+ // }
+ // element.elements().add(realIndex, childElement);
+ // }
+ // }
+ // if (xmlNode instanceof TagPropertyObject) {
+ // Attribute attribute = ((TagPropertyObject)
+ // xmlNode).getReferenceAttibute();
+ // if (element.attributes().indexOf(attribute) != -1) {
+ // int size = element.elements().size();
+ // int realIndex = index - size;
+ // element.attributes().remove(attribute);
+ // element.attributes().add(realIndex, attribute);
+ // }
+ // }
} catch (Exception e) {
e.printStackTrace();
}
@@ -365,14 +358,14 @@
Element rootElement = null;
Element parentElement = null;
if (data instanceof TagPropertyObject) {
- parentElement = ((TagPropertyObject) data).getReferenceAttibute().getParent();
+ parentElement = ((TagPropertyObject) data).getReferenceAttibute().getOwnerElement();
}
if (data instanceof XSLTagObject) {
parentElement = ((XSLTagObject) data).getReferenceElement();
}
if (parentElement != null) {
- Document d = parentElement.getDocument();
- rootElement = d.getRootElement();
+ Document d = parentElement.getOwnerDocument();
+ rootElement = d.getDocumentElement();
}
return getXSLContents(rootElement);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateContentProvider.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateContentProvider.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -10,13 +10,10 @@
******************************************************************************/
package org.jboss.tools.smooks.graphical.editors.model.xsl;
-import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
-import org.dom4j.DocumentException;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.wst.xsl.core.XSLCore;
@@ -69,26 +66,23 @@
IFile file = SmooksUIUtils.getFile(filePath,
SmooksUIUtils.getResource(template).getProject());
if (file != null && XSLCore.isXSLFile(file)) {
XSLModelAnalyzer analyzer = new XSLModelAnalyzer();
- try {
- obj = analyzer.parse(file.getContents());
- } catch (DocumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// try {
+// obj = analyzer.parse(file.getContents());
+// } catch (CoreException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
}
}else{
String contents = SmooksModelUtils.getAnyTypeCDATA(template);
if(contents != null){
XSLModelAnalyzer analyzer = new XSLModelAnalyzer();
- try {
- obj = analyzer.parse(new ByteArrayInputStream(contents.getBytes()));
- } catch (DocumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// try {
+// obj = analyzer.parse(new ByteArrayInputStream(contents.getBytes()));
+// } catch (DocumentException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateGraphicalModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateGraphicalModel.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/xsl/XSLTemplateGraphicalModel.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -13,7 +13,6 @@
import java.io.ByteArrayInputStream;
import java.util.List;
-import org.dom4j.Element;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -29,6 +28,7 @@
import org.jboss.tools.smooks.model.xsl.Template;
import org.jboss.tools.smooks.model.xsl.Xsl;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+import org.w3c.dom.Element;
/**
* @author Dart
@@ -52,7 +52,7 @@
@Override
protected TreeNodeModel createChildModel(Object model, ITreeContentProvider
contentProvider,
ILabelProvider labelProvider) {
- return new XSLNodeGraphicalModel(model, contentProvider,
labelProvider,domainProvider);
+ return new XSLNodeGraphicalModel(model, contentProvider, labelProvider,
domainProvider);
}
/*
@@ -77,8 +77,8 @@
if (node instanceof XSLNodeGraphicalModel) {
Object data = node.getData();
if (data instanceof XSLTagObject) {
- Element element = ((XSLTagObject)data).getReferenceElement();
- Element rootElement = element.getDocument().getRootElement();
+ Element element = ((XSLTagObject) data).getReferenceElement();
+ Element rootElement = element.getOwnerDocument().getDocumentElement();
String contents = XSLNodeGraphicalModel.getXSLContents(rootElement);
Template template = ((Xsl) getData()).getTemplate();
String filePath = SmooksModelUtils.getAnyTypeText(template);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/XSLTemplateCreationWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/XSLTemplateCreationWizard.java 2009-12-08
00:07:42 UTC (rev 19089)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/wizards/XSLTemplateCreationWizard.java 2009-12-08
02:56:20 UTC (rev 19090)
@@ -14,7 +14,8 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import org.dom4j.DocumentException;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
@@ -25,6 +26,7 @@
import org.jboss.tools.smooks.model.xsl.Xsl;
import org.jboss.tools.smooks.model.xsl.XslFactory;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+import org.xml.sax.SAXException;
/**
* @author Dart
@@ -114,10 +116,14 @@
}
} catch (FileNotFoundException e) {
e.printStackTrace();
- } catch (DocumentException e) {
- e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
}