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 /***
20 * Default XmlDocument that works on a standard xml string
21 *
22 * @author ole.matzura
23 */
24
25 public class DefaultXmlDocument extends AbstractXmlDocument
26 {
27 private String xml;
28 private SchemaTypeSystem typeSystem;
29
30 public DefaultXmlDocument( String xml )
31 {
32 this.xml = xml;
33 }
34
35 public DefaultXmlDocument()
36 {
37 }
38
39 public void setTypeSystem( SchemaTypeSystem typeSystem )
40 {
41 this.typeSystem = typeSystem;
42 }
43
44 public SchemaTypeSystem getTypeSystem()
45 {
46 if( typeSystem != null )
47 return typeSystem;
48
49 try
50 {
51 typeSystem = XmlObject.Factory.parse( xml ).schemaType().getTypeSystem();
52 return typeSystem;
53 }
54 catch (Exception e)
55 {
56 return XmlBeans.getBuiltinTypeSystem();
57 }
58 }
59
60 public String getXml()
61 {
62 return xml;
63 }
64
65 public void setXml(String xml)
66 {
67 String oldXml = this.xml;
68 this.xml = xml;
69
70 fireXmlChanged( oldXml, xml );
71 }
72
73 public void release()
74 {
75 typeSystem = null;
76 }
77 }