summaryrefslogtreecommitdiffstats
path: root/sdo-java/branches/emf-2.5/sdo-api/src/main/java/commonj/sdo/helper/XMLDocument.java
blob: a89ff7bd9d99ad304ea8d30ea607ed96f6b648c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
 * <copyright>
 *
 * Service Data Objects
 * Version 2.1.0
 * Licensed Materials
 *
 * (c) Copyright BEA Systems, Inc., International Business Machines Corporation, 
 * Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG., 
 * Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies, 
 * 2005, 2006. All rights reserved.
 *
 * </copyright>
 * 
 */

package commonj.sdo.helper;

import commonj.sdo.DataObject;

/**
 * Represents an XML Document containing a tree of DataObjects.
 * 
 * An example XMLDocument fragment is:
 * <?xml version="1.0"?>
 * <purchaseOrder orderDate="1999-10-20">
 * 
 * created from this XML Schema fragment:
 * <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 *   <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
 *   <xsd:complexType name="PurchaseOrderType">
 *
 * Upon loading this XMLDocument:
 *   DataObject is an instance of Type PurchaseOrderType.
 *   RootElementURI is null because the XSD has no targetNamespace URI.
 *   RootElementName is purchaseOrder.
 *   Encoding is null because the document did not specify an encoding.
 *   XMLDeclaration is true because the document contained an XML declaration.
 *   XMLVersion is 1.0
 *   SchemaLocation and noNamespaceSchemaLocation are null because they are
 *     not specified in the document.
 * 
 * When saving the root element, if the type of the root dataObject is not the
 *   type of global element specified by rootElementURI and rootElementName, 
 *   or if a global element does not exist for rootElementURI and rootElementName,
 *   then an xsi:type declaration is written to record the root DataObject's Type.
 * 
 * When loading the root element and an xsi:type declaration is found
 *   it is used as the type of the root DataObject.  In this case,
 *   if validation is not being performed, it is not an error if the
 *   rootElementName is not a global element.
 */
public interface XMLDocument
{
  /**
   * Return the root DataObject for the XMLDocument.
   * @return root DataObject for the XMLDocument.
   */
  DataObject getRootObject();
  
  /**
   * Return the targetNamespace URI for the root element.
   * If there is no targetNamespace URI, the value is null.
   * The root element is a global element of the XML Schema
   *   with a type compatible to the DataObject.
   * @return the targetNamespace URI for the root element.
   */
  String getRootElementURI();
  
  /**
   * Return the name of the root element.
   * The root element is a global element of the XML Schema
   *   with a type compatible to the DataObject.
   * @return the name of the root element.
   */
  String getRootElementName();
  
  /**
   * Return the XML encoding of the document, or null if not specified.
   * The default value is "UTF-8".
   * Specification of other values is implementation-dependent.
   * @return the XML encoding of the document, or null if not specified.
   */
  String getEncoding();
  
  /**
   * Set the XML encoding of the document, or null if not specified.
   * @param encoding
   */
  void setEncoding(String encoding);

  /**
   * Return the XML declaration of the document.  If true,
   *   XMLHelper save() will produce a declaration of the form:
   * <?xml version="1.0" encoding="UTF-8"?>
   *   Encoding will be suppressed if getEncoding() is null.
   * The default value is true.
   * @return the XML declaration of the document.
   */
  boolean isXMLDeclaration();
  
  /**
   * Set the XML declaration version of the document.
   * @param xmlDeclaration the XML declaration version of the document.
   */
  void setXMLDeclaration(boolean xmlDeclaration);
  
  /**
   * Return the XML version of the document, or null if not specified. 
   * The default value is "1.0".
   * Specification of other values is implementation-dependent.
   * @return the XML version of the document, or null if not specified.
   */
  String getXMLVersion();
  
  /**
   * Set the XML version of the document, or null if not specified.
   * @param xmlVersion the XML version of the document, or null if not specified.
   */
  void setXMLVersion(String xmlVersion);

  /**
   * Return the value of the schemaLocation declaration
   * for the http://www.w3.org/2001/XMLSchema-instance namespace in the
   * root element, or null if not present.
   * @return the value of the schemaLocation declaration,
   * or null if not present.
   */
  String getSchemaLocation();
  
  /**
   * Sets the value of the schemaLocation declaration
   * for the http://www.w3.org/2001/XMLSchema-instance namespace in the
   * root element, or null if it should not be present.
   * @param schemaLocation the value of the schemaLocation declaration, or null.
   */
  void setSchemaLocation(String schemaLocation);

  /**
   * Return the value of the noNamespaceSchemaLocation declaration
   * for the http://www.w3.org/2001/XMLSchema-instance namespace in the
   * root element, or null if not present.
   * @return the value of the noNamespaceSchemaLocation declaration,
   * or null if not present.
   */
  String getNoNamespaceSchemaLocation();
  
  /**
   * Sets the value of the noNamespaceSchemaLocation declaration
   * for the http://www.w3.org/2001/XMLSchema-instance namespace in the
   * root element, or null if it should not be present.
   * @param schemaLocation the value of the noNamespaceSchemaLocation declaration, or null.
   */
  void setNoNamespaceSchemaLocation(String schemaLocation);
}