1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.editor.xml.support;
14
15 import org.apache.xmlbeans.SchemaTypeSystem;
16 import org.apache.xmlbeans.XmlBeans;
17 import org.apache.xmlbeans.XmlObject;
18
19 import com.eviware.soapui.SoapUI;
20
21 /***
22 * Default XmlDocument that works on an existing XmlObject
23 *
24 * @author ole.matzura
25 */
26
27 public class XmlObjectXmlDocument extends AbstractXmlDocument
28 {
29 private XmlObject xmlObject;
30
31 public XmlObjectXmlDocument( XmlObject xmlObject )
32 {
33 this.xmlObject = xmlObject;
34 }
35
36 public SchemaTypeSystem getTypeSystem()
37 {
38 return xmlObject == null ? XmlBeans.getBuiltinTypeSystem() : xmlObject.schemaType().getTypeSystem();
39 }
40
41 public String getXml()
42 {
43 return xmlObject.toString();
44 }
45
46 public void setXml( String xml )
47 {
48 try
49 {
50 String old = getXml();
51 xmlObject = XmlObject.Factory.parse( xml );
52 fireXmlChanged( old, getXml() );
53 }
54 catch( Exception e )
55 {
56 SoapUI.logError( e );
57 }
58 }
59
60 public void release()
61 {
62 xmlObject = null;
63 }
64 }