01: /* Copyright 2004 The Apache Software Foundation
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.apache.xmlbeans.samples.cursor;
17:
18: import org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument;
19:
20: /**
21: * A class with which to test the MixedContent sample.
22: */
23: public class MixedContentTest {
24: /**
25: * Tests the MixedContent sample.
26: *
27: * @param args An array in which the first item is a path to an XML file
28: * based on the schema in inventory.xsd.
29: */
30: public static void main(String[] args) {
31: // Create an instance of this sample to work with.
32: MixedContent sample = new MixedContent();
33:
34: // Create an schema type instance from the XML indicated by the path.
35: InventoryDocument inventoryDoc = sample.parseXml(args[0]);
36:
37: // Validate the XML.
38: boolean exampleIsValid = sample.validateXml(inventoryDoc);
39: assert exampleIsValid;
40:
41: // Edit the XML, adding <link> elements to associate related items.
42: InventoryDocument linkedResultDoc = sample
43: .linkItems(inventoryDoc);
44:
45: // Validate the XML.
46: boolean newXmlIsValid = sample.validateXml(linkedResultDoc);
47: assert newXmlIsValid;
48: }
49: }
|