[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-dev
Subject: RE: Experimental XBeans Partial SOM Testing
From: "Rajiv Balachandran" <rbalacha () bea ! com>
Date: 2005-01-31 20:59:27
Message-ID: 4B2B4C417991364996F035E1EE39E2E1026AA47C () uskiex01 ! amer ! bea ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
Found an issue with the patch I sent earlier. Attaching an updated
version.
-rajiv
_____
From: Rajiv Balachandran
Sent: Sunday, January 30, 2005 5:15 PM
To: dev@xmlbeans.apache.org
Subject: Experimental XBeans Partial SOM Testing
Hi,
I have been looking into the partial SOM creation feature of Xbeans and
creating test cases for it. I am including the patch from svn for these
test cases here for review.
Thanks,
Rajiv
[Attachment #5 (text/html)]
<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"
downloadurl="http://www.microsoft.com"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:Arial;
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:1856380867;
mso-list-type:hybrid;
mso-list-template-ids:1014284556 -1187200024 67698691 67698693 67698689 67698691 \
67698693 67698689 67698691 67698693;} @list l0:level1
{mso-level-start-at:4;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Arial;
mso-fareast-font-family:"Times New Roman";}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Found an issue with the patch I sent
earlier. Attaching an updated version.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> -rajiv<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">Rajiv Balachandran</st1:PersonName> <br>
<b><span style='font-weight:bold'>Sent:</span></b> Sunday, January 30, 2005
5:15 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">dev@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Subject:</span></b> Experimental XBeans Partial SOM \
Testing</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hi,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I have been looking into the partial SOM creation feature of
Xbeans and creating test cases for it. I am including the patch from svn for
these test cases here for review. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Thanks,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Rajiv<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>
["xbeans_testcases_updated.diff" (application/octet-stream)]
Index: test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java
===================================================================
--- test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java (revision 0)
+++ test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java (revision 0)
@@ -0,0 +1,1428 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package compile.scomp.som.checkin;
+
+import compile.scomp.common.CompileCommon;
+import compile.scomp.som.common.SomTestBase;
+import junit.framework.Assert;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlOptions;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author: rbalacha
+ * January 29th, 2005
+ */
+
+public class PartialSOMCheckinTest extends SomTestBase
+{
+
+ public PartialSOMCheckinTest(String name)
+ {
+ super(name);
+ }
+
+
+ public void setUp()
+ {
+ // initialize the built in schema type
+ builtin = XmlBeans.getBuiltinTypeSystem();
+
+ // populate the XmlOptions
+ if (errors == null)
+ {
+ errors = new ArrayList();
+ }
+ if (options == null)
+ {
+ options = (new XmlOptions()).setErrorListener(errors);
+ options.setCompileDownloadUrls();
+ options.put("COMPILE_PARTIAL_TYPESYSTEM");
+ options.setLoadLineNumbers();
+ }
+
+ // initialize the runid to be used for generating output files for the PSOM \
walk thro's + runid = new Date().getTime();
+
+ // clean the output from the previous run
+ // delete directories created by checkPSOMSave() and output text file \
created by inspectPSOM() + deleteDirRecursive(new File(somOutputRootDir));
+
+ }
+
+ public void tearDown()
+ {
+ errors.clear();
+ }
+
+
+ public void testAddAttributeAndElements() throws Exception
+ {
+ System.out.println("Inside test case testAddAttributeAndElements()");
+
+ // Step 1 : create a Schema Type System with the base 'bad' xsd and create \
the Schema Type System (STS) for it + String sBaseSourceName = \
"testsourcename"; + SchemaTypeSystem baseSTS = createNewSTS("elemattr.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.",
+ baseSTS);
+
+ // the tests - Walk thro the SOM, save, validate against an xml instance
+ inspectSOM(baseSTS, 1, 1, 1, 0);
+
+ // test for recoverable errors
+ Assert.assertTrue("No Recovered Errors for Invalid Schema",
+ printRecoveredErrors());
+
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - \
should fail!", + checkPSOMSave(baseSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance Success - should fail ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
baseSTS)); +
+ // additional validation
+ Assert.assertFalse("Attribute found but not expected - \
'testAttributeComplex'", + lookForAttributeInSTS(baseSTS,
+ "testAttributeComplex"));
+ Assert.assertFalse("Element found but not expected 'ComplexTypeElem'",
+ lookForElemInSTS(baseSTS,
+ "ComplexTypeElem"));
+ Assert.assertFalse("Element found but not expected 'SimpleTypeElem'",
+ lookForElemInSTS(baseSTS, "SimpleTypeElem"));
+
+
+ // Step 2: create a Schema Type System with the new xsd file that has \
additions to this schema + SchemaTypeSystem modifiedSTS = \
createNewSTS("elemattr_added.xsd", + baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.",
+ modifiedSTS);
+
+ // Recovered Errors, Test for saving of the PSOM - should not be able to \
save + Assert.assertTrue("Valid SOM " + modifiedSTS.getName() + "Save failed \
!", + checkPSOMSave(modifiedSTS));
+
+ // test the PSOM created : walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(modifiedSTS, 3, 2, \
1, 0); +
+ // Test for successful saving of the PSOM
+ Assert.assertTrue("Valid Partial SOM " + modifiedSTS.getName() + "Save \
failed", + checkPSOMSave(modifiedSTS));
+
+ // Look for a added attribute(s)/Element(s) by name in the STS
+ Assert.assertTrue("Attribute expected, not found 'testAttributeComplex'",
+ lookForAttributeInSTS(modifiedSTS,
+ "testAttributeComplex"));
+ Assert.assertTrue("Element expected, not found 'ComplexTypeElem'",
+ lookForElemInSTS(modifiedSTS,
+ "ComplexTypeElem"));
+ Assert.assertTrue("Element expected, not found 'SimpleTypeElem'",
+ lookForElemInSTS(modifiedSTS,
+ "SimpleTypeElem"));
+
+ // validate against an xml instance
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
modifiedSTS); +
+ // Step 3: now creat the Schema Type System with the original XSD again
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ //walk the SOM
+ inspectSOM(finalSTS, 1, 1, 1, 0);
+
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Partial SOM " + finalSTS.getName() + "Save successful - \
should fail!", + checkPSOMSave(finalSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance Success - should fail ",
+ validateInstance(getTestCaseFile("instance_elemattr.xml"), \
finalSTS)); +
+ }
+
+ public void testModifyAttributeAndElements() throws Exception
+ {
+ System.out.println("Inside test case testModifyAttributeAndElements()");
+
+ // Step 1 : create a Schema Type System with the base 'good' xsd and create \
the Schema Type System (STS) for it + String sBaseSourceName = \
"testsourcename"; + SchemaTypeSystem baseSTS = \
createNewSTS("elemattr_added.xsd", + null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // the tests - Walk thro the SOM, save, validate against an xml instance
+ inspectSOM(baseSTS, 3, 2, 1, 0);
+
+ // validate successful save
+ Assert.assertTrue("Valid SOM " + baseSTS.getName() + "Save failed ",
+ checkPSOMSave(baseSTS));
+
+ // validate against instance successfully
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
baseSTS)); +
+ // Step 2: create a Schema Type System with the new xsd file that \
modifications to existing schema : modified + SchemaTypeSystem modifiedSTS = \
createNewSTS("elemattr_modified.xsd", + baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // test for recoverable errors
+ Assert.assertTrue("No Recovered Errors for Invalid Schema",
+ printRecoveredErrors());
+
+ // test the PSOM created
+ inspectSOM(modifiedSTS, 2, 2, 1, 0); // walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups +
+ // Look for a modified attribute(s)/elements by name in the STS
+ Assert.assertTrue("Attribute expected, not found 'testAttributeComplex'",
+ lookForAttributeInSTS(modifiedSTS, "testAttributeComplex"));
+ Assert.assertTrue("Element expected, not found 'ComplexTypeElem'",
+ lookForElemInSTS(modifiedSTS, "ComplexTypeElem"));
+ Assert.assertFalse("Element expected, not found 'SimpleTypeElem'",
+ lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
+
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Partial SOM " + modifiedSTS.getName() + " Save \
successful- should fail", + checkPSOMSave(modifiedSTS));
+
+ // validate against an xml instance - should fail
+ Assert.assertFalse("Validation against instance Success - should Fail",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
modifiedSTS)); +
+ // Step 3: now creat the Schema Type System with the original XSD again
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // walk the PSOM
+ inspectSOM(finalSTS, 3, 2, 1, 0);
+
+ // should be able to save as its a valid SOM
+ Assert.assertTrue("Partial SOM " + finalSTS.getName() + "Save failed for \
complete SOM", + checkPSOMSave(finalSTS));
+
+ // validate against instance successfully
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
finalSTS)); +
+ // TODO compare this to the original schema here
+ }
+
+ public void testDeleteAttributeAndElements() throws Exception
+ {
+ System.out.println("Inside test case testDeleteAttributeAndElements()");
+
+ // Step 1 : create a Schema Type System with the base 'good' xsd and create \
the Schema Type System (STS) for it + String sBaseSourceName = \
"testsourcename"; + SchemaTypeSystem baseSTS = \
createNewSTS("elemattr_added.xsd", + null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // the tests - Walk thro the SOM, save, validate against an xml instance
+ inspectSOM(baseSTS, 3, 2, 1, 0);
+
+ // validate successful save
+ Assert.assertTrue("Valid SOM " + baseSTS.getName() + "Save failed ",
+ checkPSOMSave(baseSTS));
+
+ // validate against instance successfully
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
baseSTS)); +
+ // Step 2: create a Schema Type System with the new xsd file that has \
deletions + SchemaTypeSystem modifiedSTS = createNewSTS("elemattr.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // test for recoverable errors
+ Assert.assertTrue("No Recovered Errors for Invalid Schema",
+ printRecoveredErrors());
+
+ // test the PSOM created
+ inspectSOM(modifiedSTS, 1, 1, 1, 0); // walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups +
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Invalid PSOM " + modifiedSTS.getName() + " Save \
successful - Should fail", + checkPSOMSave(modifiedSTS));
+
+ // verify types
+ Assert.assertFalse("Attribute found but not expected - \
'testAttributeComplex'", + lookForAttributeInSTS(modifiedSTS, \
"testAttributeComplex")); + Assert.assertFalse("Element found but not expected \
'ComplexTypeElem'", + lookForElemInSTS(modifiedSTS, \
"ComplexTypeElem")); + Assert.assertFalse("Element found but not expected \
'SimpleTypeElem'", + lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
+
+ // validate against an xml instance - should fail
+ Assert.assertFalse("Validation against success - should Fail ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
modifiedSTS)); +
+ // Step 3: now creat the Schema Type System with the original XSD again
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd",
+ modifiedSTS,
+ "BaseSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // walk the SOM
+ inspectSOM(finalSTS, 3, 2, 1, 0);
+
+ // should be able to save as its a valid SOM
+ Assert.assertTrue("Partial SOM " + finalSTS.getName() + "Save failed for \
complete SOM", + checkPSOMSave(finalSTS));
+
+ // validate against instance
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), \
finalSTS)); +
+ //TODO compare the STSs
+ }
+
+ public void testAddDataTypes() throws Exception
+ {
+ System.out.println("Inside test case testAddDataTypes()");
+ // Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) \
with unresolved references to various types + String sBaseSourceName = \
"testsourcename"; + SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // recovearble errors should exist
+ Assert.assertTrue("No Recovered Errors for Invalid Schema",
+ printRecoveredErrors());
+
+ // Walk thro the SOM (pass #Elems, #Attr, #Types, #AttrGroups)
+ inspectSOM(baseSTS, 12, 1, 4, 1);
+
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - \
should fail!", + checkPSOMSave(baseSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance Success - should fail ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
baseSTS)); +
+ // additional validation - check to see if the unresolved references to \
types are 'anyType' + // validate unresolved types
+ Assert.assertEquals("Unresolved Simple Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testUnionTypeElem"));
+
+ // moved to detailed PSOMDetailedTest class
+ //Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", \
anySimpleType, getElementType(baseSTS, "testListTypeElem")); + \
Assert.assertEquals("Unresolved Complex Type should be 'anyType'", + \
anyType, + getElementType(baseSTS, \
"testComplexTypeSimpleContentElem")); + Assert.assertEquals("Unresolved \
Complex Type should be 'anyType'", + anyType,
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testChoiceGroupElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "testAllGroupElem"));
+
+ // Step 2 : create an incremental PSOM that is valid by loading \
datatypes_added.xsd + SchemaTypeSystem modifiedSTS = \
createNewSTS("datatypes_added.xsd", baseSTS, "ModifiedSchemaTS", sBaseSourceName); + \
Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS); +
+ // no errors expected to be recovered - should be a valid SOM
+ Assert.assertFalse("Valid Schema Type System, Errors recovered",
+ printRecoveredErrors());
+
+ // test the PSOM created : walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(modifiedSTS, 13, 1, \
15, 1); +
+ // test successful save
+ Assert.assertTrue("Valid SOM " + modifiedSTS.getName() + " Save failed",
+ checkPSOMSave(modifiedSTS));
+
+ // validate against an xml valid instance - should succeed
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
modifiedSTS)); +
+ // validate against an xml invalid instance - should fail
+ Assert.assertFalse("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_simple_types_invalid.xml"), \
modifiedSTS)); +
+ // additional validation - check to see if all types are resolved to their \
respective types + Assert.assertEquals("Unresolved Simple Type should be \
'attachmentTypes'", + "attachmentTypes",
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType'", + "union.attachmentUnionType",
+ getElementType(modifiedSTS, "testUnionTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(modifiedSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'headerType'",
+ "headerType",
+ getElementType(modifiedSTS, "testComplexTypeSimpleContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'mailsType'",
+ "mailsType",
+ getElementType(modifiedSTS, \
"testComplexTypeElementOnlyContentElem")); + Assert.assertEquals("Unresolved \
Complex Type should be 'mixedContentType'", + "mixedContentType",
+ getElementType(modifiedSTS, "testComplexTypeMixedElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'emptyContentType'",
+ "emptyContentType",
+ getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
+ "choiceGroupType",
+ getElementType(modifiedSTS, "testChoiceGroupElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'allGroupType'",
+ "allGroupType",
+ getElementType(modifiedSTS, "testAllGroupElem"));
+
+
+ // Step 3 : create an incremental STS with the file in step 1
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // test the PSOM created : walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(finalSTS, 12, 1, 4, \
1); +
+ // test save failure
+ Assert.assertFalse("Partial SOM " + finalSTS.getName() + "Save Success ",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance Success - should fail ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
finalSTS)); +
+ // TODO compare this to the original schema here
+ }
+
+ public void testDeleteDataTypes() throws Exception
+ {
+ System.out.println("Inside test case testDeleteDataTypes()");
+
+ // Step 1: read a clean XSD file to get a valid SOM
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ null,
+ "BaseSchema",
+ sBaseSourceName);
+
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertEquals("Recovered Errors for Valid Schema", false, \
printRecoveredErrors()); +
+ // the tests - Walk thro the SOM, save, validate against an xml instance
+ inspectSOM(baseSTS, 13, 1, 15, 1);
+
+ // Recovered Errors, Test for saving of the PSOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
baseSTS)); +
+ // additional validation - check to see if all types are resolved to their \
respective types + Assert.assertEquals("Unresolved Simple Type should be \
'attachmentTypes'", + "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType'", + "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'headerType'",
+ "headerType",
+ getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'mailsType'",
+ "mailsType",
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'mixedContentType'",
+ "mixedContentType",
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'emptyContentType'",
+ "emptyContentType",
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
+ "choiceGroupType",
+ getElementType(baseSTS, "testChoiceGroupElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'allGroupType'",
+ "allGroupType",
+ getElementType(baseSTS, "testAllGroupElem"));
+
+
+ //Step 2 : delete/remove types from the schema - should result in STS with \
unresolved refs + SchemaTypeSystem modifiedSTS = createNewSTS("datatypes.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // PSOM - recovered errors are expected
+ Assert.assertEquals("Valid Schema Type System, Errors recovered", true, \
printRecoveredErrors()); +
+ // test the PSOM created : walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(modifiedSTS, 12, 1, \
4, 1); +
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail",
+ checkPSOMSave(modifiedSTS));
+
+ // validate unresolved types
+ Assert.assertEquals("Unresolved Simple Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testUnionTypeElem"));
+ // moved to detailed PSOMDetailedTest class
+ // Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", \
anySimpleType, getElementType(modifiedSTS, "testListTypeElem")); + \
Assert.assertEquals("Unresolved Complex Type should be 'anyType'", + \
anyType, + getElementType(modifiedSTS, \
"testComplexTypeSimpleContentElem")); + Assert.assertEquals("Unresolved \
Complex Type should be 'anyType'", + anyType,
+ getElementType(modifiedSTS, \
"testComplexTypeElementOnlyContentElem")); + Assert.assertEquals("Unresolved \
Complex Type should be 'anyType'", + anyType,
+ getElementType(modifiedSTS, "testComplexTypeMixedElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testChoiceGroupElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testAllGroupElem"));
+
+ // validate against an xml valid instance - should fail
+ Assert.assertEquals("Validation against instance should Failed ", false, \
validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS)); +
+ // Step 3 : reaload the xsd in Step 1
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+
+ // should be able to save as its a valid SOM
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // walk the PSOM
+ inspectSOM(finalSTS, 13, 1, 15, 1);
+
+ // should be able to save as its a valid SOM
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be fine
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
finalSTS)); +
+ // TODO compare this to the original schema here
+
+ // additional validation - check to see if all types are resolved to their \
respective types + Assert.assertEquals("Unresolved Simple Type should be \
'attachmentTypes'", + "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType'", + "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'headerType'",
+ "headerType",
+ getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'mailsType'",
+ "mailsType",
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'mixedContentType'",
+ "mixedContentType",
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'emptyContentType'",
+ "emptyContentType",
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
+ "choiceGroupType",
+ getElementType(baseSTS, "testChoiceGroupElem"));
+ Assert.assertEquals("Unresolved Complex Type should be 'allGroupType'",
+ "allGroupType",
+ getElementType(baseSTS, "testAllGroupElem"));
+
+ }
+
+ public void testModifyDataTypes() throws Exception
+ {
+ System.out.println("Inside test case testModifyDataTypes()");
+
+ // 1. remove one of the constituent types for the union and test to see if \
union is anySimpleType +
+ // Step 1: read in a clean XSD datatypes_added.xsd, to create a base schema \
with no unresolved components + String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 1, 15, 1);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
baseSTS)); +
+ // check types before modify
+ Assert.assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
+ "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType", + "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
+
+
+ //Step 2 : modify types from the schema - should result in STS with \
unresolved refs + SchemaTypeSystem modifiedSTS = \
createNewSTS("datatypes_modified.xsd", + baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // test the PSOM created :walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(modifiedSTS, 13, 1, \
13, 1); +
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail",
+ checkPSOMSave(modifiedSTS));
+
+ // validate unresolved types
+ Assert.assertEquals("Unresolved Simple Type - Atomic should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
+
+ // moved to detailed PSOMDetailedTest class
+ //Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", \
anySimpleType, getElementType(modifiedSTS, "testListTypeElem")); + \
//Assert.assertEquals("Unresolved Simple Type - Union should be 'anySimpleType'", \
anySimpleType, getElementType(modifiedSTS, "testUnionTypeElem")); +
+ // validate against an xml valid instance - should fail
+ Assert.assertFalse("Validation against instance should Failed ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
modifiedSTS)); +
+ // step 3: reload the original STS
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // walk the SOM
+ inspectSOM(finalSTS, 13, 1, 15, 1);
+
+ // validate successful save
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed",
+ checkPSOMSave(finalSTS)); // should be able to save as its a valid \
SOM +
+ // validate instance - should validate
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
finalSTS)); +
+ // check types after modify
+ Assert.assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
+ "attachmentTypes",
+ getElementType(finalSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(finalSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType", + "union.attachmentUnionType",
+ getElementType(finalSTS, "testUnionTypeElem"));
+
+ // TODO compare this to the original schema here
+
+ }
+
+ public void testDeleteDerivedTypes() throws Exception
+ {
+ System.out.println("Inside test case testDeleteDerivedTypes()");
+
+ // Step 1: read in a clean XSD derived_types_added.xsd with base and derived \
types to create a base schema with no unresolved components + String \
sBaseSourceName = "testsourcename"; + SchemaTypeSystem baseSTS = \
createNewSTS("derived_types_added.xsd", + null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 0, 14, 0);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
baseSTS)); +
+ // check types before deletion of base types
+ Assert.assertEquals("Elem Type should be 'ExtensionBaseType' (base)",
+ "ExtensionBaseType",
+ getElementType(baseSTS, "ExtensionBaseTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedComplexContentType", + getElementType(baseSTS, \
"ExtensionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'ExtensionBaseMixedContentType' \
(base)", + "ExtensionBaseMixedContentType",
+ getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
+ Assert.assertEquals("Elem Type should be 'ExtensionDerivedMixedContentType' \
(derived)", + "ExtensionDerivedMixedContentType",
+ getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
+
+ Assert.assertEquals("Elem Type should be \
'RestrictionSimpleContentBaseType'", + \
"RestrictionSimpleContentBaseType", getElementType(baseSTS, \
"RestrictionSimpleContentBaseTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionSimpleContentDerivedType'", + \
"RestrictionSimpleContentDerivedType", getElementType(baseSTS, \
"RestrictionSimpleContentDerivedTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseComplexContentType'", + \
"RestrictionBaseComplexContentType", + getElementType(baseSTS, \
"RestrictionBaseComplexContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedComplexContentType'", + \
"RestrictionDerivedComplexContentType", + getElementType(baseSTS, \
"RestrictionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseMixedContentType'", + \
"RestrictionBaseMixedContentType", getElementType(baseSTS, \
"RestrictionBaseMixedContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedMixedContentType'", + \
"RestrictionDerivedMixedContentType", getElementType(baseSTS, \
"RestrictionDerivedMixedContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseEmptyContentType'", + \
"RestrictionBaseEmptyContentType", getElementType(baseSTS, \
"RestrictionBaseEmptyContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedEmptyContentType'", + \
"RestrictionDerivedEmptyContentType", getElementType(baseSTS, \
"RestrictionDerivedEmptyContentTypeElem")); +
+ // Step 2: create invalid PSOM with base type removed
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // recovearble errors
+ Assert.assertTrue("No Recovered Errors for Invalid PSOM",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 13, 0, 9, 0);
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertEquals("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + false, checkPSOMSave(modifiedSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
modifiedSTS)); +
+ // check types - base should be 'anyType'
+ Assert.assertEquals("Elem Type should be 'anyType' (base)",
+ anyType,
+ getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedComplexContentType", + getElementType(modifiedSTS, \
"ExtensionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'anyType' (base)",
+ anyType,
+ getElementType(modifiedSTS, "ExtensionBaseMixedContentTypElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedMixedContentType", + getElementType(modifiedSTS, \
"ExtensionDerivedMixedContentTypeElem")); +
+ // Restriction Simple Content Base type commented does not result in \
recoverable SOM + // moved to Detailed Test
+ //Assert.assertEquals("Elem Type should be 'anyType'",
+ // anyType,
+ // getElementType(modifiedSTS, \
"RestrictionSimpleContentBaseTypeElem")); + //
+
+ Assert.assertEquals("Elem Type should be \
'RestrictionSimpleContentDerivedType'", + \
"RestrictionSimpleContentDerivedType", + getElementType(modifiedSTS, \
"RestrictionSimpleContentDerivedTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, \
"RestrictionBaseComplexContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedComplexContentType'", + \
"RestrictionDerivedComplexContentType", + getElementType(modifiedSTS, \
"RestrictionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "RestrictionBaseMixedContentTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'RestrictionDerivedMixedContentType'", + \
"RestrictionDerivedMixedContentType", + getElementType(modifiedSTS, \
"RestrictionDerivedMixedContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'anyType'", anyType,
+ getElementType(modifiedSTS, "RestrictionBaseEmptyContentTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'RestrictionDerivedEmptyContentType'", + \
"RestrictionDerivedEmptyContentType", getElementType(modifiedSTS, \
"RestrictionDerivedEmptyContentTypeElem")); +
+
+ // step 3: reload the original STS
+ SchemaTypeSystem finalSTS = createNewSTS("derived_types_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(finalSTS, 13, 0, 14, 0);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed!",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
finalSTS)); +
+ // TODO compare this to the original schema here
+
+ }
+
+
+ public void testAddDerivedTypes() throws Exception
+ {
+ System.out.println("Inside test case testAddDerivedTypes()");
+
+ // Step 1: start with invalid SOM - one that has derived types but the base \
types are not defined + String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ Assert.assertEquals("No Recovered Errors for Invalid PSOM",
+ true,
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 0, 9, 0);
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertFalse("SOM " + baseSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(baseSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
baseSTS)); +
+ // check types - base should be 'anyType'
+ Assert.assertEquals("Elem Type should be 'anyType' (base)",
+ anyType,
+ getElementType(baseSTS, "ExtensionBaseTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedComplexContentType", + getElementType(baseSTS, \
"ExtensionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'anyType' (base)",
+ anyType,
+ getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedMixedContentType", + getElementType(baseSTS, \
"ExtensionDerivedMixedContentTypeElem")); +
+ // Step 2: create valid PSOM now from xsd with base types defined
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_added.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 13, 0, 14, 0);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
+ checkPSOMSave(modifiedSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
modifiedSTS)); +
+ // check types before deletion of base types
+ Assert.assertEquals("Elem Type should be 'ExtensionBaseType' (base)",
+ "ExtensionBaseType",
+ getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedComplexContentType", + getElementType(modifiedSTS, \
"ExtensionDerivedComplexContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'ExtensionBaseMixedContentType' (base)", + \
"ExtensionBaseMixedContentType", + getElementType(modifiedSTS, \
"ExtensionBaseMixedContentTypElem")); + Assert.assertEquals("Elem Type should \
be 'ExtensionDerivedMixedContentType' (derived)", + \
"ExtensionDerivedMixedContentType", + getElementType(modifiedSTS, \
"ExtensionDerivedMixedContentTypeElem")); +
+ }
+
+ // moved to PSOMDetaiedTest
+ //public void testDeleteReusableGroups() throws Exception
+ //{}
+ //public void testModifyReusableGroups() throws Exception
+
+ public void testAddReusableGroups() throws Exception
+ {
+ System.out.println("Inside test case testAddReusableGroups()");
+
+ // Step 1: read in incomplete XSD derived_types_added.xsd with base and \
derived types to create a base schema with no unresolved components + String \
sBaseSourceName = "testsourcename"; + SchemaTypeSystem baseSTS = \
createNewSTS("groups.xsd", + null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // recovearble errors
+ Assert.assertTrue("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 4, 1);
+
+ // Recovered Errors, Test for saving of the SOM - should fail
+ Assert.assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - \
should failed!", + checkPSOMSave(baseSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
baseSTS)); +
+ // verify types
+ // named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(baseSTS, "AttributeGroup"));
+
+ // Step 2: create a SOM with valid xsd
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd",
+ baseSTS,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
+ checkPSOMSave(modifiedSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // verify named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
+
+
+ }
+
+
+ public void testAddSubstitutionGroups() throws Exception
+ {
+ System.out.println("Inside test case testAddSubstitutionGroups()");
+
+ // step1: load an invalid PSOM by with incomplete/missing Subst Grp head \
elem definition + String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("groups.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // errors recovered
+ Assert.assertTrue("No Recovered Errors for recovered PSOM",
+ printRecoveredErrors());
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertFalse("SOM " + baseSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(baseSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 4, 1);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
baseSTS)); +
+ // verify types
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(baseSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'anyType' (Member of Sub. Group)",
+ anyType,
+ getElementType(baseSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
+
+ // named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(baseSTS, "AttributeGroup"));
+
+ // Step 2: create a valid SOM and add to these
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
+ checkPSOMSave(modifiedSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // verify types - substitution groups
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
+ "SubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
+ "SubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
+
+ // named model groups - moved to check in test
+ //Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", \
getElementType(baseSTS, "ModelGrpTypeElem")); + //Assert.assertEquals("Elem \
Type should be 'AttributeGroup'", "AttributeGroup", \
getAttributeGroup(baseSTS,"AttributeGroup")); + }
+
+
+
+ public void testDeleteSubstitutionGroups() throws Exception
+ {
+ System.out.println("Inside test case testDeleteSubstitutionGroups()");
+
+ // Step 1: read in a clean XSD groups_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
baseSTS)); +
+ // verify types - substitution groups
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
+
+ // named model groups
+ //Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", \
getElementType(baseSTS, "ModelGrpTypeElem")); + //Assert.assertEquals("Elem \
Type should be 'AttributeGroup'", "AttributeGroup", \
getAttributeGroup(baseSTS,"AttributeGroup")); +
+ // step2: load an invalid PSOM by deleting the Subst Grp head elem \
definition + SchemaTypeSystem modifiedSTS = createNewSTS("groups.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ Assert.assertTrue("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(modifiedSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 7, 0, 4, 1);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // verify types
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'anyType' (Member of Sub. Group)",
+ anyType,
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
+
+ // named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
+
+ // step 3: create a PSOM with the original xsd
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertEquals("SOM " + finalSTS.getName() + "Save failed!",
+ true,
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
finalSTS)); +
+ // verify types
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem2"));
+
+ // named model groups
+ //Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", \
getElementType(baseSTS, "ModelGrpTypeElem")); + //Assert.assertEquals("Elem \
Type should be 'AttributeGroup'", "AttributeGroup", \
getAttributeGroup(baseSTS,"AttributeGroup")); +
+ //TODO compare soms
+ }
+
+ public void testModifySubstitutionGroups() throws Exception
+ {
+ System.out.println("Inside test case testModifySubstitutionGroups()");
+
+ // Step 1: read in a clean XSD groups_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
baseSTS)); +
+ // verify types
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
+
+ // step2: load a modified xsd with type of head elem in subs grp changed
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_modified.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // Recovered Errors, Test for saving of the SOM - still a valid PSOM
+ Assert.assertTrue("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(modifiedSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 5, 0, 3, 0);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // verify types
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType2'",
+ "SubGrpHeadElemType2",
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType2' (derived)",
+ "SubGrpHeadElemType2",
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
+
+ // step3 : reload the original xsd
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed!",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
finalSTS)); +
+ // the tests - Walk thro the valid SOM
+ inspectSOM(finalSTS, 7, 0, 5, 2);
+
+ // verify types
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpHeadElem"));
+ Assert.assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem1"));
+ Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' \
(base)", + "ExtensionSubGrpHeadElemType", getElementType(finalSTS, \
"SubGrpMemberElem2")); +
+ //TODO compare soms
+
+ }
+
+ public void testModifyIdConstraints() throws Exception
+ {
+ System.out.println("Inside test case testModifyIdConstraints()");
+
+ // Step 1: read in a clean XSD groups_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("constraints_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 5, 0, 2, 0);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation against valid instance- should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), \
baseSTS)); +
+ // validation against instance which violates the Constraints - should fail
+ Assert.assertFalse("Validation against invalid should fail",
+ validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), \
baseSTS)); +
+ // Step 2: create an incremental PSOM with the constraint commented out
+ // Note: Partial SOMs cannot be created for Unique/Key constraints. They \
generate valid complete SOMs. + // The xsd includes these but the invalid SOM \
in this case is from a keyref definition referring to a + // non existant key
+
+ SchemaTypeSystem modifiedSTS = createNewSTS("constraints.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // recovearble errors
+ Assert.assertTrue("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertFalse("valid PSOM " + modifiedSTS.getName() + "Save failed !",
+ checkPSOMSave(modifiedSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 5, 0, 2, 0);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), \
modifiedSTS)); +
+ // Invalid instance validation - should fail bcos of Unique constraint \
definition missing + Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), \
modifiedSTS)); +
+ // TODO a way around QName
+ Assert.assertFalse("KeyRef 'KeyRefConstraint' should not be resolved",
+ lookForIdentityConstraint(modifiedSTS, "KeyRefConstraint"));
+
+ // Step 3 : recreate SOM in first step and compare it
+ SchemaTypeSystem finalSTS = createNewSTS("constraints_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(finalSTS, 5, 0, 2, 0);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed!",
+ checkPSOMSave(finalSTS));
+
+ // instance validation against valid instance- should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), \
finalSTS)); +
+ // TODO compare the STSs here
+ }
+
+
+}
+
+
+
+
Index: test/src/compile/scomp/som/common/SomTestBase.java
===================================================================
--- test/src/compile/scomp/som/common/SomTestBase.java (revision 0)
+++ test/src/compile/scomp/som/common/SomTestBase.java (revision 0)
@@ -0,0 +1,498 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package compile.scomp.som.common;
+
+import compile.scomp.common.CompileCommon;
+import compile.scomp.common.CompileTestBase;
+import junit.framework.Assert;
+import org.apache.xmlbeans.*;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author rbalacha
+ */
+public class SomTestBase extends CompileTestBase
+{
+ public static String P = File.separator;
+ public static String casesRootDir = CompileCommon.caseroot + P + "xbean" + P + \
"compile" + P + "som"; + public static String somOutputRootDir = \
CompileCommon.outputroot + P + "som"; + public static long runid;
+ public static PrintWriter outlog = null;
+
+ public SchemaTypeSystem builtin;
+ public List errors;
+ public XmlOptions options;
+
+ public static final String anySimpleType = "anySimpleType";
+ public static final String anyType = "anyType";
+
+ public SomTestBase(String name)
+ {
+ super(name);
+ }
+
+ public static void inspectSOM(SchemaTypeSystem schematypesys,
+ int expectedGlobalElems,
+ int expectedGlobalAttrs,
+ int expectedGlobalTypes,
+ int expectedAttrGroups)
+ {
+ // System.outs written to a log file in the build\test\output\som directory, \
one file per run + // ex. SOM_INSPECTION_RESULT_1107129259405.txt
+
+ // check if file exists already
+ File outfile = new File(somOutputRootDir + P + "SOM_INSPECTION_RESULT_" + \
runid + ".txt"); + PrintWriter out = null;
+
+ try
+ {
+ // if file exists for this run, append to it
+ if (outfile.exists())
+ {
+ out = new PrintWriter(new FileWriter(outfile, true));
+ }
+ else
+ {
+ out = new PrintWriter(outfile);
+ //out = new PrintWriter(new FileWriter(outfile));
+ }
+
+ out.println("\n Call to inspectPSOM .. .. .. ..");
+ out.println("\n\n \
======================================================="); + \
out.println("Now Inspecting SOM for STS : " + schematypesys.getName()); + \
out.println("======================================================="); + \
out.println("Input Params : #elems (" + expectedGlobalElems + "), #attr (" + \
expectedGlobalAttrs + + "), #types (" + expectedGlobalTypes + "), \
#attr groups (" + expectedAttrGroups + ")"); + \
out.println("-------------------------------------------------------"); +
+ // walk thro the SOM here
+ out.println("----- Loader Name :" + schematypesys.getName());
+
+ // # of global attributes
+ out.println("----- # Global Attributes :" + \
schematypesys.globalAttributes().length); + Assert.assertEquals("Incorrect \
Number of Global Attributes in STS " + schematypesys.getName(), expectedGlobalAttrs, \
schematypesys.globalAttributes().length); + for (int i = 0; i < \
schematypesys.globalAttributes().length; i++) + {
+ out.println("\t------> Attr Name :" + \
schematypesys.globalAttributes()[i].getName()); + \
out.println("\t------> Attr Type :" + \
schematypesys.globalAttributes()[i].getType()); + }
+
+ // # of global elements
+ out.println("----- # Global Elements :" + \
schematypesys.globalElements().length); + Assert.assertEquals("Incorrect \
Number of Global Elements in STS " + schematypesys.getName(), expectedGlobalElems, \
schematypesys.globalElements().length); + for (int i = 0; i < \
schematypesys.globalElements().length; i++) + {
+ out.println("\t------> Elem Name :" + \
schematypesys.globalElements()[i].getName()); + out.println("\t------> \
Elem Type :" + schematypesys.globalElements()[i].getType()); + }
+
+ // # of global Types
+ out.println("----- # Global Types :" + \
schematypesys.globalTypes().length); + Assert.assertEquals("Incorrect \
Number of Global Types in STS " + schematypesys.getName(), expectedGlobalTypes, \
schematypesys.globalTypes().length); + for (int i = 0; i < \
schematypesys.globalTypes().length; i++) + {
+ out.println("\t------> TypeName:" + \
schematypesys.globalTypes()[i].getName()); + }
+
+ // # of attribute Groups
+ out.println("----- # of Attribute Groups :" + \
schematypesys.attributeGroups().length); + Assert.assertEquals("Incorrect \
Number of Attribute Groups in STS " + schematypesys.getName(), expectedAttrGroups, \
schematypesys.attributeGroups().length); + for (int i = 0; i < \
schematypesys.attributeGroups().length; i++) + {
+ out.println("\t------> Attr Group Name :" + \
schematypesys.attributeGroups()[i].getName()); + \
out.println("\t------> Attr STS :" + \
schematypesys.attributeGroups()[i].getTypeSystem()); + }
+
+ out.println("----- # of Model Groups :" + \
schematypesys.modelGroups().length); + Assert.assertNotNull("Invalid Model \
Groups Collection returned in STS " + schematypesys.documentTypes()); + \
for (int i = 0; i < schematypesys.modelGroups().length; i++) + {
+ out.println("\t------> Model Group Name:" + \
schematypesys.modelGroups()[i].getName()); + out.println("\t------> \
Model Group STS :" + schematypesys.modelGroups()[i].getTypeSystem()); + }
+
+ out.println("----- # of Schema Annotations :" + \
schematypesys.annotations().length); + Assert.assertNotNull("Invalid \
Annotations Collection returned in STS " + schematypesys.annotations()); +
+ out.println("----- # of Attribute Types :" + \
schematypesys.attributeTypes().length); + Assert.assertNotNull("Invalid \
Attribute Types Collection returned in STS " + schematypesys.attributeTypes()); +
+ for (int i = 0; i < schematypesys.attributeTypes().length; i++)
+ {
+ out.println("\t------> Attr Type Name :" + \
schematypesys.attributeTypes()[i].getName()); + out.println("\t------> \
Attr STS :" + schematypesys.attributeTypes()[i].getTypeSystem()); + }
+
+ out.println("----- # of Document Types :" + \
schematypesys.documentTypes().length); + Assert.assertNotNull("Invalid \
Document Types Collection returned in STS " + schematypesys.documentTypes()); + \
for (int i = 0; i < schematypesys.documentTypes().length; i++) + {
+ out.println("\t------> Doc Type Name :" + \
schematypesys.documentTypes()[i].getName()); + out.println("\t------> \
Doc Type STS :" + schematypesys.documentTypes()[i].getTypeSystem()); + }
+
+ // walk through the Schema Types of this STS in detail
+ out.println("\t=======================================================");
+ out.println("\tWalking thro Global Schema TYpes for STS : " + \
schematypesys.getName()); + \
out.println("\t======================================================="); + \
SchemaType[] schematypes = schematypesys.globalTypes(); + for (int i = 0; \
i < schematypes.length; i++) + {
+ SchemaType schema = schematypes[i];
+
+ out.println("\n\t Schema Type :" + schema.getName());
+ out.println("\t=======================================================");
+
+ out.println("\t----Acessing New Schema Type ......");
+ if (schema.isCompiled())
+ {
+ out.println("\t----This Schema has been successfully compiled");
+ }
+ else
+ {
+ out.println("\t----This Schema has NOT compiled successfully \
yet"); + }
+
+ out.println("\t----Content Type: " + schema.getContentType());
+ out.println("\t----Name: " + schema.getName());
+ out.println("\t----Doc Elem Name : " + \
schema.getDocumentElementName()); + out.println("\t----Annotation \
(class) : " + schema.getAnnotation()); + out.println("\t----Java Name \
: " + schema.getFullJavaName()); + out.println("\t----Java Imp Name : \
" + schema.getFullJavaImplName()); + out.println("\t----Java Class \
Name : " + schema.getJavaClass()); + out.println("\t----XSD src File \
Name : " + schema.getSourceName()); +
+
+ // get Elements and Attributes
+ out.println("\t Elements & Attributes for Schema Type :" + \
schema.getName()); + \
out.println("\t======================================================="); + \
SchemaProperty[] spropsArr = schema.getProperties(); + for (int j = 0; \
j < spropsArr.length; j++) + {
+ SchemaProperty schemaProperty = spropsArr[j];
+ out.println("\t:::-> Each prop name : " + \
schemaProperty.getName()); + }
+ out.println("\t=======================================================");
+
+ // other api's to look for
+ SchemaProperty[] sderviedpropArr = schema.getDerivedProperties();
+ for (int j = 0; j < sderviedpropArr.length; j++)
+ {
+ SchemaProperty schemaProperty = sderviedpropArr[j];
+ out.println("\t+++-> Each derived prop name : " + \
schemaProperty.getName()); + }
+
+ // TODO anonymus types - complete this
+ //schema.getAnonymousTypes();
+
+ }
+ out.println("-------------------------------------------------------");
+
+ out.println("Output for SchemaTypeSystem " + schematypesys.getName());
+ out.close();
+
+ } // end of try
+ catch (IOException ioe)
+ {
+ System.out.println(ioe.getMessage());
+ ioe.printStackTrace();
+ }
+
+
+ }
+
+ public boolean lookForAttributeInSTS(SchemaTypeSystem tgtSTS,
+ String sAttrLocalName)
+ {
+ for (int i = 0; i < tgtSTS.globalAttributes().length; i++)
+ {
+ if (tgtSTS.globalAttributes()[i].getName().getLocalPart().equals(sAttrLocalName))
+ {
+ return true;
+ }
+ }
+ return false;
+
+ //SchemaGlobalAttribute schGblAttr = tgtSTS.findAttribute(new \
QName(sAttrLocalName)); + //Assert.assertNotNull("Invalid \
SchemaGlobalAttribute in STS, Attribute " + sAttrName + " not found in STS " + \
tgtSTS.getName(), schGblAttr); + //Assert.assertTrue("Attribute Name Mismatch \
in STS " + tgtSTS.getName(), \
sAttrName.equalsIgnoreCase(schGblAttr.getName().toString())); + }
+
+ public boolean lookForElemInSTS(SchemaTypeSystem tgtSTS,
+ String sElemLocalName)
+ {
+ for (int i = 0; i < tgtSTS.globalElements().length; i++)
+ {
+ if (tgtSTS.globalElements()[i].getName().getLocalPart().equals(sElemLocalName))
+ {
+ return true;
+ }
+ }
+ return false;
+
+ //SchemaGlobalElement schGblElem = tgtSTS.findElement(new QName(sElemName));
+ //Assert.assertNotNull("Invalid SchemaGlobalElement in STS, Element " + \
sElemName + " not found in STS " + tgtSTS.getName(), schGblElem); + \
//Assert.assertTrue("Element Name Mismatch in STS " + tgtSTS.getName(), \
sElemName.equalsIgnoreCase(schGblElem.getName().toString())); + }
+
+ public boolean lookForIdentityConstraint(SchemaTypeSystem sts,
+ String ConstraintLocalName)
+ {
+
+ SchemaIdentityConstraint.Ref ref = sts.findIdentityConstraintRef(new \
QName(ConstraintLocalName)); + Assert.assertNotNull(ref);
+
+ return false;
+ }
+
+ public boolean checkPSOMSave(SchemaTypeSystem tgtSTS)
+ {
+ String outDirName = tgtSTS.getName().split("schema.system.")[1];
+ String outDirNameWithPath = somOutputRootDir + P + runid + P + outDirName;
+
+ // call the save
+ tgtSTS.saveToDirectory(new File(outDirNameWithPath));
+
+ // check if directories were created
+ File dirToTest = new File(outDirNameWithPath + P + "schema" + P + "system" + \
P + outDirName); + System.out.println("checkPSOMSave() -> Dir to Test : " + \
outDirNameWithPath + P + "schema" + P + "system" + P + outDirName); + if \
(dirToTest.exists()) + {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public boolean printRecoveredErrors()
+ {
+ // check list of errors and print them
+ if (!errors.isEmpty())
+ {
+ System.out.println("Schema invalid: partial schema type system \
recovered"); + for (Iterator i = errors.iterator(); i.hasNext();)
+ {
+ System.out.println("Err Msg (s): " + i.next());
+ }
+ errors.clear();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean validateInstance(File instancefile,
+ SchemaTypeSystem sts)
+ {
+ try
+ {
+ XmlObject instancedoc = sts.parse(instancefile, null, null);
+
+ XmlOptions instanceValOptions = new XmlOptions();
+ ArrayList errList = new ArrayList();
+ instanceValOptions.setErrorListener(errList);
+
+ if (!instancedoc.validate(instanceValOptions))
+ {
+ if (!errList.isEmpty())
+ {
+ for (Iterator it = errList.iterator(); it.hasNext();)
+ {
+ System.out.println("Instance Validation Error(s) : " + \
it.next()); + }
+ }
+ //Assert.fail("Validation against instance failed");
+ return false;
+ }
+ }
+ catch (IOException ioe)
+ {
+ ioe.getMessage();
+ ioe.printStackTrace();
+ Assert.fail("IOException throw when accessing instance xml file " + \
instancefile.getAbsoluteFile()); + }
+ catch (XmlException xme)
+ {
+ System.out.println("Instance Validation Errors .. .. ..");
+ if (xme.getErrors().isEmpty())
+ {
+ System.out.println(xme.getMessage());
+ }
+ else
+ {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();)
+ {
+ System.out.println(itr.next());
+ }
+ }
+ System.out.println("END Instance Validation Errors .. .. ..");
+ Assert.fail("Instance Validation - Xml Exception caught");
+ }
+
+ // validation successful
+ return true;
+
+ }
+
+ public File getTestCaseFile(String sFileName)
+ {
+ String sFileWithPath = casesRootDir + P + sFileName;
+ System.out.println("getTestCaseFile() Opening File : " + sFileWithPath);
+ File schemaFile = new File(sFileWithPath);
+ Assert.assertNotNull("Schema File " + sFileWithPath + " Loading failed", \
schemaFile); + return (schemaFile);
+ }
+
+ // returns the Local Part of the type QName for the specified Elem
+ public String getElementType(SchemaTypeSystem sts,
+ String sElementLocalName)
+ {
+
+ for (int i = 0; i < sts.globalElements().length; i++)
+ {
+ //System.out.println("comparing getname, input-> " + \
sts.globalElements()[i].getName().getLocalPart() + ":" + sElementLocalName); + \
if (sts.globalElements()[i].getName().getLocalPart().equals(sElementLocalName)) + \
{ + System.out.println("getElementType() returning " + \
sts.globalElements()[i].getType().getName().getLocalPart()); + return \
sts.globalElements()[i].getType().getName().getLocalPart(); + }
+ }
+ return "ElemNotFound";
+ //TODO : change this to findElement
+ }
+
+ public String getAttributeGroup(SchemaTypeSystem sts,
+ String sAttrGrpLocalName)
+ {
+ for (int i = 0; i < sts.attributeGroups().length; i++)
+ {
+ //System.out.println("comparing getname, input-> " + \
sts.attributeGroups()[i].getName().getLocalPart() + ":" + sAttrGrpLocalName); + \
if (sts.attributeGroups()[i].getName().getLocalPart().equals(sAttrGrpLocalName)) + \
{ + System.out.println("getElementType() returning " + \
sts.attributeGroups()[i].getName().getLocalPart()); + return \
sts.attributeGroups()[i].getName().getLocalPart(); + }
+ }
+ return "AttributeGrpNotFound";
+ //TODO : change this to findAttributeGroup
+ }
+
+
+ public SchemaTypeSystem createNewSTS(String xsdFileName,
+ SchemaTypeSystem baseSchema,
+ String sSTSName, String sBaseSourceName)
+ {
+ SchemaTypeSystem returnSTS = null;
+ try
+ {
+ File xsdModified = getTestCaseFile(xsdFileName);
+ XmlObject xsdModifiedObj = XmlObject.Factory.parse(xsdModified);
+ xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName);
+ Assert.assertNotNull("Xml Object creation failed", xsdModifiedObj);
+ XmlObject[] xobjArr = new XmlObject[]{xsdModifiedObj};
+
+ returnSTS = XmlBeans.compileXmlBeans(sSTSName, baseSchema, xobjArr, \
null, builtin, null, options); + Assert.assertNotNull("Schema Type System \
created is Null.", returnSTS); +
+ // validate the XmlObject created
+ Assert.assertTrue("Return Value for Validate()", \
xsdModifiedObj.validate()); + }
+ catch (XmlException xme)
+ {
+ // even if using "COMPILE_PARTIAL_TYPESYSTEM", compilation will fail if
+ // there are any non-recoverable errors and an XmlException will be \
thrown + System.out.println("Schema invalid, XML Exception thrown : \
couldn't recover from errors"); + if (errors.isEmpty())
+ {
+ System.out.println(xme.getMessage());
+ }
+ else
+ {
+ for (Iterator i = errors.iterator(); i.hasNext();)
+ {
+ System.out.println(i.next());
+ }
+ }
+ fail("Schema invalid, XML Exception thrown : couldn't recover from \
errors"); + }
+ catch (IOException ioe)
+ {
+ ioe.getMessage();
+ ioe.printStackTrace();
+ }
+ finally
+ {
+ //printRecoveredErrors();
+ return returnSTS;
+ }
+ }
+
+ // deletes contents of specified directory, does not delete the specified \
directory + public void deleteDirRecursive(File dirToClean)
+ {
+ if (dirToClean.exists() && dirToClean.isDirectory())
+ {
+ File filesFound [] = dirToClean.listFiles();
+ for (int i = 0; i < filesFound.length; i++)
+ {
+ if (filesFound[i].isDirectory())
+ {
+ deleteDirRecursive(filesFound[i]);
+ Assert.assertTrue("Output Directory " + filesFound[i] + " \
Deletion Failed ", filesFound[i].delete()); + }
+ else if (filesFound[i].isFile())
+ {
+ Assert.assertTrue("Output File " + filesFound[i] + " Deletion \
Failed ", filesFound[i].delete()); + }
+ }
+ }
+
+ }
+
+ public void createRunLogFile()
+ {
+ File logfile = new File(somOutputRootDir + P + "PartialSOMCheckinTest_Run_" \
+ runid + ".log"); +
+
+ try
+ {
+ // if file exists for this run, append to it
+ if (logfile.exists())
+ {
+ outlog = new PrintWriter(new FileWriter(logfile, true));
+ }
+ else
+ {
+ outlog = new PrintWriter(new FileWriter(logfile));
+ }
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+
+}
Index: test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java
===================================================================
--- test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java (revision 0)
+++ test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java (revision 0)
@@ -0,0 +1,543 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package compile.scomp.som.detailed;
+
+import compile.scomp.som.common.SomTestBase;
+import junit.framework.Assert;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlOptions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * @author: rbalacha
+ */
+public class PartialSOMDetailedTest extends SomTestBase
+{
+
+ public PartialSOMDetailedTest(String name)
+ {
+ super(name);
+ }
+
+ // inherited methods
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ // initialize the built in schema type
+ builtin = XmlBeans.getBuiltinTypeSystem();
+
+ // populate the XmlOptions
+ if (errors== null) {
+ errors = new ArrayList();
+ }
+ if (options == null) {
+ options = (new XmlOptions()).setErrorListener(errors);
+ options.setCompileDownloadUrls();
+ options.put("COMPILE_PARTIAL_TYPESYSTEM");
+ options.setLoadLineNumbers();
+ }
+
+ // initialize the runid to be used for generating output files for the PSOM \
walk thro's + runid = new Date().getTime();
+
+ // clean the output from the previous run
+ // delete directories created by checkPSOMSave() and output text file \
created by inspectPSOM() + deleteDirRecursive(new File(somOutputRootDir));
+ }
+
+ public void tearDown() throws Exception
+ {
+ errors.clear();
+ super.tearDown();
+ }
+
+ // TODO: all of add/del/modify
+ public void testAddDataTypesList() throws Exception
+ {
+ System.out.println("Inside test case testAddDataTypesList()");
+
+ // Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) \
with unresolved references to various types + String sBaseSourceName = \
"testsourcename"; + SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // recovearble errors should exist
+ Assert.assertTrue("No Recovered Errors for Invalid Schema",
+ printRecoveredErrors());
+
+ // Walk thro the SOM (pass #Elems, #Attr, #Types, #AttrGroups)
+ inspectSOM(baseSTS, 12, 1, 4, 1);
+
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - \
should fail!", + checkPSOMSave(baseSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance Success - should fail ",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
baseSTS)); +
+ // validate unresolved types - the ListType should resolve to \
'anySimpleType' + Assert.assertEquals("Unresolved List Type should be \
'anySimpleType'", + anySimpleType,
+ getElementType(baseSTS, "testListTypeElem"));
+ }
+
+ public void testDeleteReusableGroups() throws Exception
+ {
+ System.out.println("Inside test case testDeleteSubstitutionGroups()");
+
+ // Step 1: read in a clean XSD groups_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
baseSTS)); +
+ // verify named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(baseSTS, "AttributeGroup"));
+
+ // step2: load an invalid PSOM by deleting the ModelGroup and AttributeGroup \
definitions commented + SchemaTypeSystem modifiedSTS = \
createNewSTS("reusable_grps.xsd", + baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(modifiedSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 7, 0, 4, 1);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // named model groups
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
+
+ // step 3: create a PSOM with the original xsd
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS", sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed!",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
finalSTS)); +
+ // verify named model groups types
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(baseSTS, "AttributeGroup"));
+
+ //TODO compare soms
+ }
+
+ public void testModifyDataTypesList() throws Exception
+ {
+ System.out.println("Inside test case testModifyDataTypes()");
+
+ // 1. remove one of the constituent types for the union and test to see if \
union is anySimpleType +
+ // Step 1: read in a clean XSD datatypes_added.xsd, to create a base schema \
with no unresolved components + String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 1, 15, 1);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), \
baseSTS)); +
+ // check types before modify
+ Assert.assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
+ "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType", + "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
+
+
+ //Step 2 : modify types from the schema - should result in STS with \
unresolved refs + SchemaTypeSystem modifiedSTS = \
createNewSTS("datatypes_modified.xsd", + baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // test the PSOM created :walk thro the PSOM, look for # of \
elements,attributes,types & attribute groups + inspectSOM(modifiedSTS, 13, 1, \
13, 1); +
+ // Test for saving of the PSOM - should not be able to save
+ Assert.assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail",
+ checkPSOMSave(modifiedSTS));
+
+ // validate unresolved types
+ Assert.assertEquals("Unresolved Simple Type - Atomic should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be 'anySimpleType'",
+ anySimpleType,
+ getElementType(modifiedSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type - Union should be \
'anySimpleType'", + anySimpleType,
+ getElementType(modifiedSTS, "testUnionTypeElem"));
+
+ // validate against an xml valid instance - should fail
+ Assert.assertFalse("Validation against instance should Failed ",
+ validateInstance(getTestCaseFile("instance_simple_types_valid.xml"), \
modifiedSTS)); +
+ // step 3: reload the original STS
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // walk the SOM
+ inspectSOM(finalSTS, 13, 1, 15, 1);
+
+ // validate successful save
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed",
+ checkPSOMSave(finalSTS)); // should be able to save as its a valid \
SOM +
+ // validate instance - should validate
+ Assert.assertTrue("Validation against instance Failed ",
+ validateInstance(getTestCaseFile("instance_simple_types_valid.xml"), \
finalSTS)); +
+ // check types after modify
+ Assert.assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
+ "attachmentTypes",
+ getElementType(finalSTS, "testAtomicTypeElem"));
+ Assert.assertEquals("Unresolved List Type should be \
'attchmentExtensionListTypes'", + "attchmentExtensionListTypes",
+ getElementType(finalSTS, "testListTypeElem"));
+ Assert.assertEquals("Unresolved Simple Type should be \
'union.attachmentUnionType", + "union.attachmentUnionType",
+ getElementType(finalSTS, "testUnionTypeElem"));
+
+ // TODO compare this to the original schema here
+ }
+
+ public void testDeleteDerivedTypes() throws Exception
+ {
+ System.out.println("Inside test case testDeleteDerivedTypes()");
+
+ // Step 1: read in a clean XSD derived_types_added.xsd with base and derived \
types to create a base schema with no unresolved components + String \
sBaseSourceName = "testsourcename"; + SchemaTypeSystem baseSTS = \
createNewSTS("derived_types_added.xsd", + null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 0, 14, 0);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
baseSTS)); +
+ // check types before deletion of base types
+ Assert.assertEquals("Elem Type should be \
'RestrictionSimpleContentBaseType'", + \
"RestrictionSimpleContentBaseType", getElementType(baseSTS, \
"RestrictionSimpleContentBaseTypeElem")); +
+ // Step 2: create invalid PSOM with base type removed
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // recovearble errors
+ Assert.assertTrue("No Recovered Errors for Invalid PSOM",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 13, 0, 9, 0);
+
+ // Recovered Errors, Test for saving of the SOM
+ Assert.assertEquals("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + false, checkPSOMSave(modifiedSTS));
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
modifiedSTS)); +
+ // check types - base should be 'anyType'
+ // Restriction Simple Content Base type commented does not result in \
recoverable SOM + Assert.assertEquals("Elem Type should be 'anyType'",
+ anyType,
+ getElementType(modifiedSTS, \
"RestrictionSimpleContentBaseTypeElem")); +
+
+ }
+
+ public void testModifyReusableGroups() throws Exception
+ {
+ System.out.println("Inside test case testModifyReusableGroups()");
+
+ // Step 1: read in a clean XSD groups_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 7, 0, 5, 2);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertEquals("SOM " + baseSTS.getName() + "Save failed!", true, \
checkPSOMSave(baseSTS)); +
+ // instance validation - should be ok
+ Assert.assertEquals("Validation against instance failed", true, \
validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS)); +
+ // verify named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'", \
"AttributeGroup", + getAttributeGroup(baseSTS, "AttributeGroup"));
+
+ // step2: load a modified xsd with type of head elem in subs grp changed
+ SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps_modified.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // Recovered Errors, Test for saving of the SOM - still a valid PSOM
+ Assert.assertTrue("SOM " + modifiedSTS.getName() + "Save Success - should \
fail!", + checkPSOMSave(modifiedSTS));
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 7, 0, 5, 2);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
modifiedSTS)); +
+ // verify named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'",
+ "AttributeGroup",
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
+
+ // step3 : reload the original xsd
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
+
+ // Test for saving of the SOM - should go thro
+ Assert.assertTrue("SOM " + finalSTS.getName() + "Save failed!",
+ checkPSOMSave(finalSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), \
finalSTS)); +
+ // the tests - Walk thro the valid SOM
+ inspectSOM(finalSTS, 7, 0, 5, 2);
+
+ // verify named model groups
+ Assert.assertEquals("Elem Type should be 'ModelGrpType'",
+ "ModelGrpType",
+ getElementType(finalSTS, "ModelGrpTypeElem"));
+ Assert.assertEquals("Elem Type should be 'AttributeGroup'", \
"AttributeGroup", + getAttributeGroup(finalSTS, "AttributeGroup"));
+
+ //TODO compare soms
+
+ }
+
+ public void testModifyDerivedTypes() throws Exception
+ {
+ System.out.println("Inside test case testModifyDerivedTypes()");
+
+ // Step 1: read in a clean XSD derived_types_added.xsd
+ String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd",
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
+
+ // there should be NO recovearble errors
+ Assert.assertFalse("Recovered Errors for Valid Schema",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(baseSTS, 13, 0, 14, 0);
+
+ // Recovered Errors, Test for saving of the SOM - should go thro
+ Assert.assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
+
+ // instance validation - should be ok
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
baseSTS)); +
+ // check types before deletion of base types
+ Assert.assertEquals("Elem Type should be 'ExtensionBaseType' (base)",
+ "ExtensionBaseType",
+ getElementType(baseSTS, "ExtensionBaseTypeElem"));
+ Assert.assertEquals("Elem Type should be \
'ExtensionDerivedComplexContentType' (derived)", + \
"ExtensionDerivedComplexContentType", + getElementType(baseSTS, \
"ExtensionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be 'ExtensionBaseMixedContentType' \
(base)", + "ExtensionBaseMixedContentType",
+ getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
+ Assert.assertEquals("Elem Type should be 'ExtensionDerivedMixedContentType' \
(derived)", + "ExtensionDerivedMixedContentType",
+ getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
+
+ Assert.assertEquals("Elem Type should be \
'RestrictionSimpleContentBaseType'", + \
"RestrictionSimpleContentBaseType", + getElementType(baseSTS, \
"RestrictionSimpleContentBaseTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionSimpleContentDerivedType'", + \
"RestrictionSimpleContentDerivedType", + getElementType(baseSTS, \
"RestrictionSimpleContentDerivedTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseComplexContentType'", + \
"RestrictionBaseComplexContentType", + getElementType(baseSTS, \
"RestrictionBaseComplexContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedComplexContentType'", + \
"RestrictionDerivedComplexContentType", + getElementType(baseSTS, \
"RestrictionDerivedComplexContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseMixedContentType'", + \
"RestrictionBaseMixedContentType", + getElementType(baseSTS, \
"RestrictionBaseMixedContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedMixedContentType'", + \
"RestrictionDerivedMixedContentType", + getElementType(baseSTS, \
"RestrictionDerivedMixedContentTypeElem")); +
+ Assert.assertEquals("Elem Type should be \
'RestrictionBaseEmptyContentType'", + \
"RestrictionBaseEmptyContentType", + getElementType(baseSTS, \
"RestrictionBaseEmptyContentTypeElem")); + Assert.assertEquals("Elem Type \
should be 'RestrictionDerivedEmptyContentType'", + \
"RestrictionDerivedEmptyContentType", + getElementType(baseSTS, \
"RestrictionDerivedEmptyContentTypeElem")); +
+
+ // step 2 : change the base types now : derived_types_modified.xsd
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_modifed.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // no recovearble errors just added another type
+ Assert.assertFalse("valid PSOM",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ //inspectSOM(modifiedSTS, 13, 0, 14, 0);
+ inspectSOM(modifiedSTS, 13, 0, 15, 0);
+
+ // instance validation - should fail
+ Assert.assertFalse("Validation against instance success - should fail",
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), \
modifiedSTS)); +
+ // now validate instance with new base type - this should go thro
+ // TODO resolve this validation
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_derived_types_modify.xml"), \
modifiedSTS)); +
+ //TODO ignoring step3
+ }
+
+}
+
+
+
+
Index: test/cases/xbean/compile/som/instance_elemattr_valid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_elemattr_valid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_elemattr_valid.xml (revision 0)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+
+<TestRoot testAttributeComplex="12">
+ <SimpleTypeElem>This is a string type element </SimpleTypeElem>
+ <ComplexTypeElem testAttrSimple="required attr">
+ <testComplexTypeSubElem1>This is a string elem</testComplexTypeSubElem1>
+ <testComplexTypeSubElem2>22</testComplexTypeSubElem2>
+ </ComplexTypeElem>
+
+</TestRoot>
+
+<!--
+<mails>
+ <mail id="0">
+ <envelope From="bill@microsoft.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>I desperately need XML Schema support in CDuce</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ <body>
+ As subject says, is it possible to implement it?
+ </body>
+ <attachment name="signature.doc">
+ <mimetype type="application" subtype="msword"/>
+ <content>
+ ### removed by spamoracle ###
+ </content>
+ </attachment>
+ </mail>
+ <mail id="1">
+ <envelope From="zack@cs.unibo.it">
+ <From>zack@di.ens.fr</From>
+ <To>bill@microsoft.com</To>
+ <Date>2003-10-15T16:17:39Z</Date>
+ <Subject>Re: I desperately need XML Schema support in CDuce</Subject>
+ </envelope>
+ <body>
+ user@unknown.domain.org wrote:
+ > As subject says, is possible to implement it?
+
+ Sure, I'm working on it, in a few years^Wdays it will be finished
+ </body>
+ </mail>
+</mails>
+-->
\ No newline at end of file
Index: test/cases/xbean/compile/som/instance_elemattr_added.xml
===================================================================
--- test/cases/xbean/compile/som/instance_elemattr_added.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_elemattr_added.xml (revision 0)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+<mails>
+ <testElem>This is a test </testElem>
+ <testElemComplex>
+ <testComplexTypeSubElem1> Sub Element of testElemComplex \
</testComplexTypeSubElem1> + <testComplexTypeSubElem2> Sub Element of \
testElemComplex </testComplexTypeSubElem2> + </testElemComplex>
+
+ <mail id="0">
+ <envelope From="bill@microsoft.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>I desperately need XML Schema support in CDuce</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ <body>
+ As subject says, is it possible to implement it?
+ </body>
+ <attachment name="signature.doc">
+ <mimetype type="application" subtype="msword"/>
+ <content>
+ ### removed by spamoracle ###
+ </content>
+ </attachment>
+ </mail>
+ <mail id="1">
+ <envelope From="zack@cs.unibo.it">
+ <From>zack@di.ens.fr</From>
+ <To>bill@microsoft.com</To>
+ <Date>2003-10-15T16:17:39Z</Date>
+ <Subject>Re: I desperately need XML Schema support in CDuce</Subject>
+ </envelope>
+ <body>
+ user@unknown.domain.org wrote:
+ > As subject says, is possible to implement it?
+
+ Sure, I'm working on it, in a few years^Wdays it will be finished
+ </body>
+ </mail>
+
+
+</mails>
+
Index: test/cases/xbean/compile/som/derived_types_added.xsd
===================================================================
--- test/cases/xbean/compile/som/derived_types_added.xsd (revision 0)
+++ test/cases/xbean/compile/som/derived_types_added.xsd (revision 0)
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="DerivedTypesTestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="ExtensionBaseTypeElem"/>
+ <xsd:element ref="ExtensionDerivedComplexContentTypeElem"/>
+
+ <xsd:element ref="ExtensionBaseMixedContentTypElem"/>
+ <xsd:element ref="ExtensionDerivedMixedContentTypeElem"/>
+
+ <xsd:element ref="RestrictionSimpleContentBaseTypeElem"/>
+ <xsd:element ref="RestrictionSimpleContentDerivedTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseComplexContentTypeElem"/>
+ <xsd:element ref="RestrictionDerivedComplexContentTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseMixedContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedMixedContentTypeElem" />
+
+ <xsd:element ref="RestrictionBaseEmptyContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedEmptyContentTypeElem" />
+
+ </xsd:sequence>
+
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="ExtensionBaseTypeElem" type="ExtensionBaseType"/>
+ <xsd:element name="ExtensionDerivedComplexContentTypeElem" \
type="ExtensionDerivedComplexContentType"/> +
+ <xsd:element name="ExtensionBaseMixedContentTypElem" \
type="ExtensionBaseMixedContentType"/> + <xsd:element \
name="ExtensionDerivedMixedContentTypeElem" type="ExtensionDerivedMixedContentType"/> \
+ + <xsd:element name="RestrictionSimpleContentBaseTypeElem" \
type="RestrictionSimpleContentBaseType"/> + <xsd:element \
name="RestrictionSimpleContentDerivedTypeElem" \
type="RestrictionSimpleContentDerivedType"/> +
+ <xsd:element name="RestrictionBaseComplexContentTypeElem" \
type="RestrictionBaseComplexContentType"/> + <xsd:element \
name="RestrictionDerivedComplexContentTypeElem" \
type="RestrictionDerivedComplexContentType"/> +
+ <xsd:element name="RestrictionBaseMixedContentTypeElem" \
type="RestrictionBaseMixedContentType"/> + <xsd:element \
name="RestrictionDerivedMixedContentTypeElem" \
type="RestrictionDerivedMixedContentType"/> +
+ <xsd:element name="RestrictionBaseEmptyContentTypeElem" \
type="RestrictionBaseEmptyContentType"/> + <xsd:element \
name="RestrictionDerivedEmptyContentTypeElem" \
type="RestrictionDerivedEmptyContentType"/> +
+ <!-- derived types extension testing...-->
+ <!-- 1. complex type, simple content : headerType from mails_types_added.xsd -->
+
+ <!-- complex type, complex content -->
+ <xsd:complexType name="ExtensionBaseType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem1" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="ExtensionDerivedComplexContentType">
+ <xsd:complexContent>
+ <xsd:extension base="ExtensionBaseType">
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="ExtDerivedTypeElem1" type="CarEngineType"/>
+ <xsd:element name="ExtDerivedTypeElem2" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- 2. complex type, mixed content -->
+
+ <xsd:complexType name="ExtensionDerivedMixedContentType" mixed="true">
+ <xsd:complexContent>
+ <xsd:extension base="ExtensionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ExtDerivedMixedElem1" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute name="ExtDerivedMixedAttr" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionBaseMixedContentType" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string"/>
+ <xsd:element name="ExtBaseMixedElem2" type="CarEngineType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="ExtensionBaseType2">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem3" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem4" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="CarEngineType">
+ <xsd:choice>
+ <xsd:element name="Valves" type="xsd:integer"/>
+ <xsd:element name="Capacity" type="xsd:decimal"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+
+
+ <!-- derived types restriction testing -->
+ <!-- 1. complex types : simple content -->
+ <xsd:complexType name="RestrictionSimpleContentBaseType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:integer">
+ <xsd:attribute name="RestrictionSimpleContentBaseAttr1" \
type="xsd:string" /> + </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- restricts the base with range and making the attribute required -->
+ <xsd:complexType name="RestrictionSimpleContentDerivedType">
+ <xsd:simpleContent>
+ <xsd:restriction base="RestrictionSimpleContentBaseType">
+ <xsd:minInclusive value="2" />
+ <xsd:maxExclusive value="6" />
+ <xsd:attribute name= "RestrictionSimpleContentBaseAttr1" \
type="xsd:string" use="required" /> + </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- 2. complex content -->
+ <xsd:complexType name="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string" />
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer" />
+ <xsd:element name="RestrictionBaseElem3" type="xsd:integer" \
minOccurs="0"/> + <xsd:element name="RestrictionBaseElem4" \
type="xsd:string" minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="RestrictionDerivedComplexContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string"/>
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- 3. mixed content -->
+ <xsd:complexType name="RestrictionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ResBaseMixedElem1" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ResBaseMixedElem2" type="CarEngineType" \
minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="RestrictionDerivedMixedContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ResBaseMixedElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- empty content -->
+ <xsd:complexType name="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" type="xsd:integer" />
+ </xsd:complexType>
+
+ <xsd:complexType name="RestrictionDerivedEmptyContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" \
type="xsd:short" /> + </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/constraints_added.xsd
===================================================================
--- test/cases/xbean/compile/som/constraints_added.xsd (revision 0)
+++ test/cases/xbean/compile/som/constraints_added.xsd (revision 0)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="root">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="TestRootElemUniqueConstraint" />
+ <xsd:element ref="TestRootElemKeyConstraint" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- unique Constraint - specifies that the child elem for the \
UniqueConstraintSubElem1 has to be unique --> + <xsd:element \
name="TestRootElemUniqueConstraint" type="UniqueConstraintElemType"> + \
<xsd:unique name="uniqueConstraint"> + <xsd:selector \
xpath="*/UniqueConstraintSubElem1"/> + <xsd:field \
xpath="UniqueConstraintSubElem1Child"/> + </xsd:unique>
+ </xsd:element>
+
+ <!-- key Constraint - specifies the child elem for the KeyConstraintSubElem1 \
must exist --> + <xsd:element name="TestRootElemKeyConstraint" \
type="KeyConstraintElemType"> + <xsd:key name="keyConstraint">
+ <xsd:selector xpath="*/KeyConstraintSubElem1"/>
+ <xsd:field xpath="KeyConstraintSubElem1Child"/>
+ </xsd:key>
+ <xsd:keyref name="KeyRefConstraint" refer="keyConstraint">
+ <xsd:selector xpath="*/KeyConstraintSubElem1" />
+ <xsd:field xpath="KeyConstraintSubElem1Child2" />
+ </xsd:keyref>
+ </xsd:element>
+
+ <xsd:complexType name="UniqueConstraintElemType">
+ <xsd:sequence>
+ <xsd:element name="UniqueConstraintElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="UniqueConstraintSubElem1" \
maxOccurs="unbounded"/> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="KeyConstraintElemType">
+ <xsd:sequence>
+ <xsd:element name="KeyConstraintElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="KeyConstraintSubElem1" \
maxOccurs="unbounded"/> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- the Unique constraint Sub Elem which has a child elem -->
+ <xsd:element name="UniqueConstraintSubElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="UniqueConstraintSubElem1Child" type="xsd:integer" \
maxOccurs="25"></xsd:element> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- the Key constraint Sub Elem which has a child elem -->
+ <xsd:element name="KeyConstraintSubElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="KeyConstraintSubElem1Child" \
type="xsd:string"></xsd:element> + <xsd:element \
name="KeyConstraintSubElem1Child2" type="xsd:string"></xsd:element> + \
</xsd:sequence> + </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/reusable_grps_modified.xsd
===================================================================
--- test/cases/xbean/compile/som/reusable_grps_modified.xsd (revision 0)
+++ test/cases/xbean/compile/som/reusable_grps_modified.xsd (revision 0)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+
+ <!-- elements -->
+ <xsd:element name="TestRootElem">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SubGrpHeadElem" maxOccurs="unbounded" />
+ <xsd:element ref="ModelGrpTypeElem" minOccurs="1"/>
+ <xsd:element ref="AttrGrpTypeElem" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType" />
+ <xsd:element name="SubGrpHeadElem2" type="SubGrpHeadElemType2" />
+ <xsd:element name="SubGrpMemberElem1" substitutionGroup="SubGrpHeadElem" />
+ <xsd:element name="SubGrpMemberElem2" type="ExtensionSubGrpHeadElemType" \
substitutionGroup="SubGrpHeadElem"/> +
+ <xsd:element name="ModelGrpTypeElem" type="ModelGrpType" />
+ <xsd:element name="AttrGrpTypeElem" type="AttrGrpType" />
+
+
+ <!-- types -->
+
+ <xsd:complexType name="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem1" type="xsd:string" />
+ <xsd:element name="SubGrpInnerElem2" type="xsd:integer" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionSubGrpHeadElemType">
+ <xsd:complexContent>
+ <xsd:extension base="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:token" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+
+ <!-- reusable group definitions here -->
+ <!-- Named Model Groups -->
+ <xsd:group name="NamedModelGroup">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem1" type="xsd:string" />
+ <xsd:element name="ModelGrpElem2" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+
+ <!-- comment this - the modified elem now refers to this
+ <xsd:group name="NamedModelGroup2">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem3" type="xsd:string" />
+ <xsd:element name="ModelGrpElem4" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+ -->
+
+ <xsd:complexType name="ModelGrpType">
+ <xsd:sequence>
+ <!-- change ModelGroup to NamedModelGroup2 for testing ..
+ <xsd:group ref="NamedModelGroup" minOccurs="1" />
+ -->
+ <xsd:group ref="NamedModelGroup2" minOccurs="1" />
+ <xsd:element name="ModelGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- attribute groups -->
+ <xsd:attributeGroup name="AttributeGroup">
+ <xsd:attribute name="AttrGrpAttribute1" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute2" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <!-- comment out for testing - modified ref now looks for this attribute group
+ <xsd:attributeGroup name="AttributeGroup2">
+ <xsd:attribute name="AttrGrpAttribute3" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute4" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+ -->
+
+ <xsd:complexType name="AttrGrpType">
+ <xsd:sequence>
+ <xsd:element name="AttrGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ <!-- change Attribute group ref to AttributeGroup2 for testing ..
+ <xsd:attributeGroup ref="AttributeGroup"/>
+ -->
+ <xsd:attributeGroup ref="AttributeGroup2"/>
+ <xsd:attribute name="AttrGrpTypeAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/reusable_grps.xsd
===================================================================
--- test/cases/xbean/compile/som/reusable_grps.xsd (revision 0)
+++ test/cases/xbean/compile/som/reusable_grps.xsd (revision 0)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- elements -->
+ <xsd:element name="TestRootElem">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SubGrpHeadElem" maxOccurs="unbounded" />
+ <xsd:element ref="ModelGrpTypeElem" minOccurs="1"/>
+ <xsd:element ref="AttrGrpTypeElem" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType" />
+ <xsd:element name="SubGrpHeadElem2" type="SubGrpHeadElemType2" />
+ <xsd:element name="SubGrpMemberElem1" substitutionGroup="SubGrpHeadElem" />
+ <xsd:element name="SubGrpMemberElem2" type="ExtensionSubGrpHeadElemType" \
substitutionGroup="SubGrpHeadElem"/> +
+ <xsd:element name="ModelGrpTypeElem" type="ModelGrpType" />
+ <xsd:element name="AttrGrpTypeElem" type="AttrGrpType" />
+
+
+ <!-- types -->
+
+ <xsd:complexType name="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem1" type="xsd:string" />
+ <xsd:element name="SubGrpInnerElem2" type="xsd:integer" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionSubGrpHeadElemType">
+ <xsd:complexContent>
+ <xsd:extension base="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:token" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <!-- reusable group definitions here -->
+ <!-- Named Model Groups -->
+ <!-- commented for testing ..
+ <xsd:group name="NamedModelGroup">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem1" type="xsd:string" />
+ <xsd:element name="ModelGrpElem2" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+ -->
+
+ <xsd:complexType name="ModelGrpType">
+ <xsd:sequence>
+ <xsd:group ref="NamedModelGroup" minOccurs="1" />
+ <xsd:element name="ModelGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- attribute groups -->
+ <!-- commented for testing ..
+ <xsd:attributeGroup name="AttributeGroup">
+ <xsd:attribute name="AttrGrpAttribute1" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute2" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+ -->
+
+ <xsd:complexType name="AttrGrpType">
+ <xsd:sequence>
+ <xsd:element name="AttrGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attributeGroup ref="AttributeGroup"/>
+ <xsd:attribute name="AttrGrpTypeAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/derived_types_modifed.xsd
===================================================================
--- test/cases/xbean/compile/som/derived_types_modifed.xsd (revision 0)
+++ test/cases/xbean/compile/som/derived_types_modifed.xsd (revision 0)
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="DerivedTypesTestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+<!-- <xsd:element ref="ExtensionBaseTypeElem"/> -->
+ <xsd:element ref="ExtensionDerivedComplexContentTypeElem"/>
+
+<!-- <xsd:element ref="ExtensionBaseMixedContentTypElem"/> -->
+ <xsd:element ref="ExtensionDerivedMixedContentTypeElem"/>
+
+<!-- <xsd:element ref="RestrictionSimpleContentBaseTypeElem"/> -->
+ <xsd:element ref="RestrictionSimpleContentDerivedTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseComplexContentTypeElem"/>
+ <xsd:element ref="RestrictionDerivedComplexContentTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseMixedContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedMixedContentTypeElem" />
+
+ <xsd:element ref="RestrictionBaseEmptyContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedEmptyContentTypeElem" />
+
+ </xsd:sequence>
+
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="ExtensionBaseTypeElem" type="ExtensionBaseType"/>
+ <xsd:element name="ExtensionDerivedComplexContentTypeElem" \
type="ExtensionDerivedComplexContentType"/> +
+ <xsd:element name="ExtensionBaseMixedContentTypElem" \
type="ExtensionBaseMixedContentType"/> + <xsd:element \
name="ExtensionDerivedMixedContentTypeElem" type="ExtensionDerivedMixedContentType"/> \
+ + <xsd:element name="RestrictionSimpleContentBaseTypeElem" \
type="RestrictionSimpleContentBaseType"/> + <xsd:element \
name="RestrictionSimpleContentDerivedTypeElem" \
type="RestrictionSimpleContentDerivedType"/> +
+ <xsd:element name="RestrictionBaseComplexContentTypeElem" \
type="RestrictionBaseComplexContentType"/> + <xsd:element \
name="RestrictionDerivedComplexContentTypeElem" \
type="RestrictionDerivedComplexContentType"/> +
+ <xsd:element name="RestrictionBaseMixedContentTypeElem" \
type="RestrictionBaseMixedContentType"/> + <xsd:element \
name="RestrictionDerivedMixedContentTypeElem" \
type="RestrictionDerivedMixedContentType"/> +
+ <xsd:element name="RestrictionBaseEmptyContentTypeElem" \
type="RestrictionBaseEmptyContentType"/> + <xsd:element \
name="RestrictionDerivedEmptyContentTypeElem" \
type="RestrictionDerivedEmptyContentType"/> +
+ <!-- restriction testing...-->
+ <!-- complex type, simple content : headerType from mails_types_added.xsd -->
+
+ <!-- complex type, complex content -->
+ <xsd:complexType name="ExtensionBaseType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem1" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionBaseType2">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem3" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem4" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="ExtensionDerivedComplexContentType">
+ <xsd:complexContent>
+ <!-- change the base type ...
+ <xsd:extension base="ExtensionBaseType">
+ -->
+ <xsd:extension base="ExtensionBaseType2">
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="ExtDerivedTypeElem1" type="CarEngineType"/>
+ <xsd:element name="ExtDerivedTypeElem2" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- complex type, mixed content -->
+
+ <xsd:complexType name="ExtensionDerivedMixedContentType" mixed="true">
+ <xsd:complexContent>
+ <!-- change base type
+ <xsd:extension base="ExtensionBaseMixedContentType">
+ -->
+ <xsd:extension base="ExtensionBaseMixedContentType2">
+ <xsd:sequence>
+ <xsd:element name="ExtDerivedMixedElem1" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attribute name="ExtDerivedMixedAttr" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionBaseMixedContentType" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
+ <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionBaseMixedContentType2" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem3" type="xsd:string" />
+ <xsd:element name="ExtBaseMixedElem4" type="CarEngineType" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+
+ <xsd:complexType name="CarEngineType">
+ <xsd:choice>
+ <xsd:element name="Valves" type="xsd:integer"/>
+ <xsd:element name="Capacity" type="xsd:decimal"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <!-- derived types restriction testing -->
+ <!-- 1. complex types : simple content -->
+ <xsd:complexType name="RestrictionSimpleContentBaseType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:integer">
+ <xsd:attribute name="RestrictionSimpleContentBaseAttr1" \
type="xsd:string" /> + </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- restricts the base with range and making the attribute required -->
+ <xsd:complexType name="RestrictionSimpleContentDerivedType">
+ <xsd:simpleContent>
+ <xsd:restriction base="RestrictionSimpleContentBaseType">
+ <xsd:minInclusive value="2" />
+ <xsd:maxExclusive value="6" />
+ <xsd:attribute name= "RestrictionSimpleContentBaseAttr1" \
type="xsd:string" use="required" /> + </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- 2. complex content -->
+ <xsd:complexType name="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string" />
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer" />
+ <xsd:element name="RestrictionBaseElem3" type="xsd:integer" \
minOccurs="0"/> + <xsd:element name="RestrictionBaseElem4" \
type="xsd:string" minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="RestrictionBaseComplexContentType2">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem5" type="xsd:string" />
+ <xsd:element name="RestrictionBaseElem6" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+
+ <xsd:complexType name="RestrictionDerivedComplexContentType">
+ <xsd:complexContent>
+ <!-- modify base
+ <xsd:restriction base="RestrictionBaseComplexContentType2">
+ -->
+ <xsd:restriction base="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string"/>
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- 3. mixed content -->
+ <xsd:complexType name="RestrictionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" \
minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="RestrictionBaseMixedContentType2">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem3" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ExtBaseMixedElem4" type="CarEngineType" \
minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="RestrictionDerivedMixedContentType">
+ <xsd:complexContent>
+ <!-- change base type
+ <xsd:restriction base="RestrictionBaseMixedContentType">
+ -->
+ <xsd:restriction base="RestrictionBaseMixedContentType2">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- empty content -->
+ <xsd:complexType name="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" type="xsd:integer" />
+ </xsd:complexType>
+
+ <xsd:complexType name="RestrictionDerivedEmptyContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" \
type="xsd:short" /> + </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/datatypes.xsd
===================================================================
--- test/cases/xbean/compile/som/datatypes.xsd (revision 0)
+++ test/cases/xbean/compile/som/datatypes.xsd (revision 0)
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- global elems -->
+ <xsd:element name="testroot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" \
type="attchmentExtensionListTypes"/> + <xsd:element \
name="testUnionTypeElem" type="union.attachmentUnionType" maxOccurs="unbounded"/> + \
<xsd:element name="testComplexTypeSimpleContentElem"/> <!-- simple content test --> + \
<xsd:element name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + \
<xsd:element name="testComplexTypeMixedElem" type="mixedContentType"/> + \
<xsd:element name="testComplexTypeEmptyElem" type="emptyContentType"/> + \
<xsd:element name="testChoiceGroupElem" type="choiceGroupType"/> + \
<xsd:element name="testAllGroupElem" type="allGroupType"/> + \
</xsd:sequence> + </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" type="attchmentExtensionListTypes"/>
+ <xsd:element name="testUnionTypeElem" type="union.attachmentUnionType"/>
+ <xsd:element name="testComplexTypeSimpleContentElem" type="headerType"/> <!-- \
simple content test --> + <xsd:element \
name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + <xsd:element \
name="testComplexTypeMixedElem" type="mixedContentType"/> + <xsd:element \
name="testComplexTypeEmptyElem" type="emptyContentType"/> + <xsd:element \
name="testChoiceGroupElem" type="choiceGroupType"/> + <xsd:element \
name="testAllGroupElem" type="allGroupType"/> +
+
+ <!-- global types -->
+ <!-- atomic type -->
+ <!--
+ <xsd:simpleType name="attachmentTypes" >
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="MS Word" />
+ <xsd:enumeration value="Adobe Acrobat" />
+ <xsd:enumeration value="Ascii Text" />
+ <xsd:enumeration value="Web Page" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ -->
+ <!-- list type -->
+ <!--
+ <xsd:simpleType name="attachmentNums">
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value ="1" /> <xsd:maxInclusive value="4" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="attchmentExtensionListTypes">
+ <xsd:list itemType="attachmentNums" />
+ </xsd:simpleType>
+ -->
+ <!-- union type -->
+ <!--
+ <xsd:simpleType name="union.attachmentUnionType">
+ <xsd:union memberTypes="attachmentTypes attchmentExtensionListTypes">
+ </xsd:union>
+ </xsd:simpleType>
+ -->
+ <!-- End of Simple Types added for testing -->
+
+ <!-- complex types adding testing -->
+ <!-- complex type :simple content : refers to element header-->
+ <!--
+ <xsd:complexType name="headerType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute ref="name" use="required" />
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ -->
+ <!-- complex type :element only content : refers to element header-->
+ <!--
+ <xsd:complexType name="mailsType">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ -->
+ <!-- complex type :mixed only content -->
+ <!--
+ <xsd:complexType name="mixedContentType" mixed="true">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ -->
+ <!-- complex type : empty content -->
+ <!--
+ <xsd:complexType name="emptyContentType">
+ <xsd:attribute name="value" type="xsd:integer" />
+ </xsd:complexType>
+ -->
+ <!-- complex types - choice model grouping -->
+ <!--<xsd:complexType name="choiceGroupType">
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="Lang" type="xsd:string" />
+ <xsd:element name="Font" type="xsd:string"/>
+ <xsd:element name="Fontcolor" type="xsd:string" />
+ </xsd:choice>
+ </xsd:complexType>
+ -->
+
+ <!-- complex types - choice 'all' grouping -->
+ <!--<xsd:complexType name="allGroupType">
+ <xsd:all>
+ <xsd:element name="Greetings" type="xsd:string" />
+ <xsd:element name="Signature" type="xsd:string"/>
+ <xsd:element name="ContactNumber" type="xsd:string" />
+ </xsd:all>
+ </xsd:complexType>
+ -->
+
+ <xsd:element name="mails" type="mailsType"/>
+ <xsd:element name="Date" type="xsd:dateTime"/>
+
+ <!--
+ <xsd:element name="header" type="headerType" />
+ -->
+
+ <xsd:attribute name="name" type="xsd:string"/>
+
+ <xsd:attributeGroup name="mimeTypeAttributes">
+ <xsd:attribute name="type" type="mimeTopLevelType" use="required"/>
+ <xsd:attribute name="subtype" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <!--
+ <xsd:complexType name="mailType">
+ <xsd:sequence>
+ <xsd:element name="envelope" type="envelopeType" />
+ <xsd:element name="body" type="bodyType" />
+ <xsd:element name="attachment" type="attachmentType"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute use="required" name="id" type="xsd:integer" />
+ </xsd:complexType>
+ -->
+
+ <xsd:complexType name="envelopeType">
+ <xsd:sequence>
+ <xsd:element name="From" type="xsd:string"/>
+ <xsd:element name="To" type="xsd:string"/>
+ <xsd:element ref="Date"/>
+ <xsd:element name="Subject" type="xsd:string"/>
+ <xsd:element ref="header" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="From" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="bodyType">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+ <xsd:complexType name="attachmentType">
+ <xsd:group ref="attachmentContent"/>
+ <xsd:attribute ref="name" use="required"/>
+ </xsd:complexType>
+
+ <xsd:group name="attachmentContent">
+ <xsd:sequence>
+ <xsd:element name="mimetype">
+ <xsd:complexType>
+ <xsd:attributeGroup ref="mimeTypeAttributes"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="content" type="xsd:string" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:group>
+
+
+ <xsd:simpleType name="mimeTopLevelType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="text"/>
+ <xsd:enumeration value="multipart"/>
+ <xsd:enumeration value="application"/>
+ <xsd:enumeration value="message"/>
+ <xsd:enumeration value="image"/>
+ <xsd:enumeration value="audio"/>
+ <xsd:enumeration value="video"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/datatypes_modified.xsd
===================================================================
--- test/cases/xbean/compile/som/datatypes_modified.xsd (revision 0)
+++ test/cases/xbean/compile/som/datatypes_modified.xsd (revision 0)
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- global elems added for testing -->
+ <xsd:element name="testroot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" \
type="attchmentExtensionListTypes"/> + <xsd:element \
name="testUnionTypeElem" type="union.attachmentUnionType" maxOccurs="unbounded"/> + \
<xsd:element ref="header"/> <!-- simple content test --> + \
<xsd:element name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + \
<xsd:element name="testComplexTypeMixedElem" type="mixedContentType"/> + \
<xsd:element name="testComplexTypeEmptyElem" type="emptyContentType"/> + \
<xsd:element name="testChoiceGroupElem" type="choiceGroupType"/> + \
<xsd:element name="testAllGroupElem" type="allGroupType"/> + \
</xsd:sequence> + </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" type="attchmentExtensionListTypes"/>
+ <xsd:element name="testUnionTypeElem" type="union.attachmentUnionType"/>
+ <xsd:element name="testComplexTypeSimpleContentElem" type="headerType"/> <!-- \
simple content test --> + <xsd:element \
name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + <xsd:element \
name="testComplexTypeMixedElem" type="mixedContentType"/> + <xsd:element \
name="testComplexTypeEmptyElem" type="emptyContentType"/> + <xsd:element \
name="testChoiceGroupElem" type="choiceGroupType"/> + <xsd:element \
name="testAllGroupElem" type="allGroupType"/> +
+
+ <!-- Types added for testing -->
+ <!-- atomic type -->
+ <!-- commented for modify
+ <xsd:simpleType name="attachmentTypes" >
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="MS Word" />
+ <xsd:enumeration value="Adobe Acrobat" />
+ <xsd:enumeration value="Ascii Text" />
+ <xsd:enumeration value="Web Page" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ -->
+
+ <!-- list type -->
+ <xsd:simpleType name="attachmentNums">
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="1"/>
+ <xsd:maxInclusive value="4"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- commented for modify testing
+ <xsd:simpleType name="attchmentExtensionListTypes">
+ <xsd:list itemType="attachmentNums" />
+ </xsd:simpleType>
+ -->
+
+ <!-- union type -->
+ <xsd:simpleType name="union.attachmentUnionType">
+ <xsd:union memberTypes="attachmentTypes attchmentExtensionListTypes">
+ </xsd:union>
+ </xsd:simpleType>
+
+ <!-- End of Simple Types added for testing -->
+
+ <!-- complex types adding testing -->
+ <!-- complex type :simple content : refers to element header-->
+
+ <xsd:complexType name="headerType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute ref="name" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- complex type :element only content : refers to element header-->
+
+ <xsd:complexType name="mailsType">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- complex type :mixed only content -->
+
+ <xsd:complexType name="mixedContentType" mixed="true">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- complex type : empty content -->
+
+ <xsd:complexType name="emptyContentType">
+ <xsd:attribute name="value" type="xsd:integer"/>
+ </xsd:complexType>
+
+ <!-- complex types - choice model grouping -->
+ <xsd:complexType name="choiceGroupType">
+ <xsd:choice maxOccurs="unbounded" minOccurs="2">
+ <xsd:element name="Lang" type="xsd:string"/>
+ <xsd:element name="Font" type="xsd:string"/>
+ <xsd:element name="Fontcolor" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <!-- complex types - choice 'all' grouping -->
+ <xsd:complexType name="allGroupType">
+ <xsd:all>
+ <xsd:element name="Greetings" type="xsd:string"/>
+ <xsd:element name="Signature" type="xsd:string"/>
+ <xsd:element name="ContactNumber" type="xsd:string"/>
+ </xsd:all>
+ </xsd:complexType>
+
+ <!-- other types , attributes and elems from the orig schema -->
+ <xsd:element name="Date" type="xsd:dateTime"/>
+ <xsd:element name="mails" type="mailsType"/>
+ <xsd:element name="header" type="headerType"/>
+
+ <xsd:attribute name="name" type="xsd:string"/>
+
+ <xsd:attributeGroup name="mimeTypeAttributes">
+ <xsd:attribute name="type" type="mimeTopLevelType" use="required"/>
+ <xsd:attribute name="subtype" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <xsd:complexType name="mailType">
+ <xsd:sequence>
+ <xsd:element name="envelope" type="envelopeType"/>
+ <xsd:element name="body" type="bodyType"/>
+ <xsd:element name="attachment" type="attachmentType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute use="required" name="id" type="xsd:integer"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="envelopeType">
+ <xsd:sequence>
+ <xsd:element name="From" type="xsd:string"/>
+ <xsd:element name="To" type="xsd:string"/>
+ <xsd:element ref="Date"/>
+ <xsd:element name="Subject" type="xsd:string"/>
+ <xsd:element ref="header" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="From" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="bodyType">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+ <xsd:complexType name="attachmentType">
+ <xsd:group ref="attachmentContent"/>
+ <xsd:attribute ref="name" use="required"/>
+ </xsd:complexType>
+
+ <xsd:group name="attachmentContent">
+ <xsd:sequence>
+ <xsd:element name="mimetype">
+ <xsd:complexType>
+ <xsd:attributeGroup ref="mimeTypeAttributes"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="content" type="xsd:string" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:group>
+
+
+ <xsd:simpleType name="mimeTopLevelType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="text"/>
+ <xsd:enumeration value="multipart"/>
+ <xsd:enumeration value="application"/>
+ <xsd:enumeration value="message"/>
+ <xsd:enumeration value="image"/>
+ <xsd:enumeration value="audio"/>
+ <xsd:enumeration value="video"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/elemattr_added.xsd
===================================================================
--- test/cases/xbean/compile/som/elemattr_added.xsd (revision 0)
+++ test/cases/xbean/compile/som/elemattr_added.xsd (revision 0)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="TestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SimpleTypeElem" />
+ <xsd:element ref="ComplexTypeElem" />
+ </xsd:sequence>
+ <xsd:attribute ref="testAttributeComplex" />
+ </xsd:complexType>
+
+ </xsd:element>
+
+ <!-- elements -->
+ <xsd:element name="ComplexTypeElem" type="testComplexType"/>
+ <xsd:element name="SimpleTypeElem" type="xsd:string" />
+
+ <!-- attributes -->
+ <xsd:attribute name="testAttributeComplex">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="10" />
+ <xsd:maxInclusive value="20" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+
+ <xsd:attribute name="testAttrSimple" type="xsd:string"/>
+
+
+ <!-- type definitions -->
+ <xsd:complexType name="testComplexType">
+ <xsd:sequence minOccurs="1" maxOccurs="unbounded">
+ <xsd:element name="testComplexTypeSubElem1" type="xsd:string"/>
+ <xsd:element name="testComplexTypeSubElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ <xsd:attribute ref="testAttrSimple" use="required "/>
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/instance_subst_grps_valid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_subst_grps_valid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_subst_grps_valid.xml (revision 0)
@@ -0,0 +1,52 @@
+<?xml version="1.0" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+
+<TestRootElem>
+ <SubGrpHeadElem SubGrpHeadAttr1="required Head Elem Attribute">
+ <SubGrpInnerElem1>This is a child of the Head Elem in the Substitution \
Group</SubGrpInnerElem1> + <SubGrpInnerElem2>10</SubGrpInnerElem2>
+ </SubGrpHeadElem>
+
+ <!-- add a Substitution Group Type here - should work just fine! -->
+ <SubGrpMemberElem1 SubGrpHeadAttr1="now this is required">
+ <SubGrpInnerElem1>This is a child of the Substituted Element \
</SubGrpInnerElem1> + <SubGrpInnerElem2>10</SubGrpInnerElem2>
+ </SubGrpMemberElem1>
+
+ <!-- substitution group with extended type from the head elem -->
+ <SubGrpMemberElem2 SubGrpHeadAttr1="now this is required">
+ <SubGrpInnerElem1>This is a child of the Substituted Element \
</SubGrpInnerElem1> + <SubGrpInnerElem2>10</SubGrpInnerElem2>
+ <SubGrpInnerElem3>Element Added by Extension</SubGrpInnerElem3>
+ </SubGrpMemberElem2>
+
+ <ModelGrpTypeElem>
+ <ModelGrpElem1> This is an element from a Named Model Group </ModelGrpElem1>
+ <ModelGrpElem2> This is also from NamedMode Group with Min Occurs = \
1</ModelGrpElem2> + <ModelGrpTypeSubElem1> This elemen is part of the type \
definition for ModelGrpTypeElem</ModelGrpTypeSubElem1> + </ModelGrpTypeElem>
+
+ <AttrGrpTypeElem AttrGrpAttribute1="Attr From Attribute Group" \
AttrGrpAttribute2="This one too" AttrGrpTypeAttr1="And this is from the Element \
definition"> + <AttrGrpTypeSubElem1> This is Child Elem of \
AttrGrpTypeElem</AttrGrpTypeSubElem1> + </AttrGrpTypeElem>
+
+</TestRootElem>
+
+
Index: test/cases/xbean/compile/som/groups_added.xsd
===================================================================
--- test/cases/xbean/compile/som/groups_added.xsd (revision 0)
+++ test/cases/xbean/compile/som/groups_added.xsd (revision 0)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+
+ <!-- elements -->
+ <xsd:element name="TestRootElem">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SubGrpHeadElem" maxOccurs="unbounded" />
+ <xsd:element ref="ModelGrpTypeElem" minOccurs="1"/>
+ <xsd:element ref="AttrGrpTypeElem" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType" />
+ <xsd:element name="SubGrpHeadElem2" type="SubGrpHeadElemType2" />
+ <xsd:element name="SubGrpMemberElem1" substitutionGroup="SubGrpHeadElem" />
+ <xsd:element name="SubGrpMemberElem2" type="ExtensionSubGrpHeadElemType" \
substitutionGroup="SubGrpHeadElem"/> +
+ <xsd:element name="ModelGrpTypeElem" type="ModelGrpType" />
+ <xsd:element name="AttrGrpTypeElem" type="AttrGrpType" />
+
+
+ <!-- types -->
+
+ <xsd:complexType name="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem1" type="xsd:string" />
+ <xsd:element name="SubGrpInnerElem2" type="xsd:integer" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <xsd:complexType name="ExtensionSubGrpHeadElemType">
+ <xsd:complexContent>
+ <xsd:extension base="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:token" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+
+ <!-- reusable group definitions here -->
+ <!-- Named Model Groups -->
+ <xsd:group name="NamedModelGroup">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem1" type="xsd:string" />
+ <xsd:element name="ModelGrpElem2" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+
+ <xsd:group name="NamedModelGroup2">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem3" type="xsd:string" />
+ <xsd:element name="ModelGrpElem4" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+
+ <xsd:complexType name="ModelGrpType">
+ <xsd:sequence>
+ <xsd:group ref="NamedModelGroup" minOccurs="1" />
+ <xsd:element name="ModelGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- attribute groups -->
+ <xsd:attributeGroup name="AttributeGroup">
+ <xsd:attribute name="AttrGrpAttribute1" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute2" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <xsd:attributeGroup name="AttributeGroup2">
+ <xsd:attribute name="AttrGrpAttribute3" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute4" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <xsd:complexType name="AttrGrpType">
+ <xsd:sequence>
+ <xsd:element name="AttrGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attributeGroup ref="AttributeGroup"/>
+ <xsd:attribute name="AttrGrpTypeAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/instance_derived_types_modify.xml
===================================================================
--- test/cases/xbean/compile/som/instance_derived_types_modify.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_derived_types_modify.xml (revision 0)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<DerivedTypesTestRoot>
+
+ <!-- this xsd has only the modified derived types -->
+ <ExtensionDerivedComplexContentTypeElem>
+ <ExtBaseTypeElem3>This and the next Elem are from the new base \
type</ExtBaseTypeElem3> + <ExtBaseTypeElem4>0001</ExtBaseTypeElem4>
+ <ExtDerivedTypeElem1>
+ <Valves>6</Valves>
+ </ExtDerivedTypeElem1>
+ </ExtensionDerivedComplexContentTypeElem>
+
+ <ExtensionDerivedMixedContentTypeElem ExtDerivedMixedAttr="1">
+ <ExtBaseMixedElem3>New Base Type for Mixed Content - has elems 3 and 4 \
instead of 1 and 2</ExtBaseMixedElem3> + <ExtBaseMixedElem4>
+ <Capacity>1.0</Capacity>
+ </ExtBaseMixedElem4>
+
+ <ExtDerivedMixedElem1>Elem in deriving type</ExtDerivedMixedElem1>
+ </ExtensionDerivedMixedContentTypeElem>
+
+ <!-- simple content unchanged -->
+ <RestrictionSimpleContentDerivedTypeElem \
RestrictionSimpleContentBaseAttr1="required \
here">3</RestrictionSimpleContentDerivedTypeElem> +
+ <RestrictionBaseComplexContentTypeElem>
+ <RestrictionBaseElem1>This is a string type</RestrictionBaseElem1>
+ <RestrictionBaseElem2>25</RestrictionBaseElem2>
+ <RestrictionBaseElem3>2</RestrictionBaseElem3>
+ <RestrictionBaseElem4>This has Min Requires 0 - is missing in the derived \
type </RestrictionBaseElem4> + </RestrictionBaseComplexContentTypeElem>
+
+ <RestrictionDerivedComplexContentTypeElem>
+ <RestrictionBaseElem1>This is a string type</RestrictionBaseElem1>
+ <RestrictionBaseElem2>25</RestrictionBaseElem2>
+ </RestrictionDerivedComplexContentTypeElem>
+
+
+ <RestrictionBaseMixedContentTypeElem>
+ <ResBaseMixedElem1>This is present in the derived type</ResBaseMixedElem1>
+ <ResBaseMixedElem2>
+ <Capacity>2.0</Capacity>
+ </ResBaseMixedElem2>
+ </RestrictionBaseMixedContentTypeElem>
+
+ <RestrictionDerivedMixedContentTypeElem>
+ <ResBaseMixedElem1>This is present in the derived type</ResBaseMixedElem1>
+ </RestrictionDerivedMixedContentTypeElem>
+
+ <RestrictionBaseEmptyContentTypeElem \
RestrictionBaseEmptyContentAttr1="34"></RestrictionBaseEmptyContentTypeElem> + \
<RestrictionDerivedEmptyContentTypeElem \
RestrictionBaseEmptyContentAttr1="1"></RestrictionDerivedEmptyContentTypeElem> +
+
+</DerivedTypesTestRoot>
Index: test/cases/xbean/compile/som/instance_datatypes_valid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_datatypes_valid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_datatypes_valid.xml (revision 0)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<testroot>
+ <testAtomicTypeElem>MS Word</testAtomicTypeElem>
+ <testListTypeElem>3</testListTypeElem>
+
+ <testUnionTypeElem>Adobe Acrobat</testUnionTypeElem>
+ <testUnionTypeElem>2</testUnionTypeElem>
+
+ <header name="testheader">This is a test Email Header </header>
+ <testComplexTypeElementOnlyContentElem>
+ <mail id="0">
+ <envelope From="x@bea.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>Xml Beans Testing</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ <body>
+ As subject says, is it possible to implement it?
+ </body>
+ <attachment name="signature.doc">
+ <mimetype type="application" subtype="msword"/>
+ <content>
+ ### removed by spamoracle ###
+ </content>
+ </attachment>
+
+ </mail>
+ </testComplexTypeElementOnlyContentElem>
+
+
+ <testComplexTypeMixedElem>
+
+ <mail id="1">
+ <envelope From="x@bea.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>Xml Beans Testing</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ <body>
+ As subject says, is it possible to implement it?
+ </body>
+ <attachment name="signature.doc">
+ <mimetype type="application" subtype="msword"/>
+ <content>
+ ### removed by spamoracle ###
+ </content>
+ </attachment>
+
+ </mail>
+
+
+ </testComplexTypeMixedElem>
+
+ <testComplexTypeEmptyElem value="2" />
+
+ <testChoiceGroupElem>
+ <Lang>English</Lang>
+ </testChoiceGroupElem>
+
+ <testAllGroupElem>
+ <Greetings>Hello</Greetings>
+ <Signature> Mr X., Bea Systems</Signature>
+ <ContactNumber>425-123-1234</ContactNumber>
+ </testAllGroupElem>
+
+</testroot>
Index: test/cases/xbean/compile/som/instance_constraints_invalid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_constraints_invalid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_constraints_invalid.xml (revision 0)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<!-- the uniquness constraint is for value of UniqueConstraintSubElem1Child -->
+
+<root>
+ <!-- invalid - value 12 repeats -->
+ <TestRootElemUniqueConstraint>
+ <UniqueConstraintElem1>
+ <UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1Child>12</UniqueConstraintSubElem1Child>
+ </UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1Child>12</UniqueConstraintSubElem1Child>
+ </UniqueConstraintSubElem1>
+ </UniqueConstraintElem1>
+ </TestRootElemUniqueConstraint>
+
+ <!-- key constraint comment out - required child elem -->
+ <TestRootElemKeyConstraint>
+ <KeyConstraintElem1>
+ <KeyConstraintSubElem1>
+ <!--
+ <KeyConstraintSubElem1Child>Ok this is a constrained \
Elem</KeyConstraintSubElem1Child> + -->
+ </KeyConstraintSubElem1>
+ </KeyConstraintElem1>
+ </TestRootElemKeyConstraint>
+</root>
+
Index: test/cases/xbean/compile/som/instance_elemattr.xml
===================================================================
--- test/cases/xbean/compile/som/instance_elemattr.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_elemattr.xml (revision 0)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<!-- valid xml instance document for schema mails_elemattr.xsd -->
+<mails>
+ <mail id="0">
+ <envelope From="bill@microsoft.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>I desperately need XML Schema support in CDuce</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ <body>
+ As subject says, is it possible to implement it?
+ </body>
+ <attachment name="signature.doc">
+ <mimetype type="application" subtype="msword"/>
+ <content>
+ ### removed by spamoracle ###
+ </content>
+ </attachment>
+ </mail>
+ <mail id="1">
+ <envelope From="zack@cs.unibo.it">
+ <From>zack@di.ens.fr</From>
+ <To>bill@microsoft.com</To>
+ <Date>2003-10-15T16:17:39Z</Date>
+ <Subject>Re: I desperately need XML Schema support in CDuce</Subject>
+ </envelope>
+ <body>
+ user@unknown.domain.org wrote:
+ > As subject says, is possible to implement it?
+
+ Sure, I'm working on it, in a few years^Wdays it will be finished
+ </body>
+ </mail>
+</mails>
+
Index: test/cases/xbean/compile/som/derived_types.xsd
===================================================================
--- test/cases/xbean/compile/som/derived_types.xsd (revision 0)
+++ test/cases/xbean/compile/som/derived_types.xsd (revision 0)
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="DerivedTypesTestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="ExtensionBaseTypeElem"/>
+ <xsd:element ref="ExtensionDerivedComplexContentTypeElem"/>
+
+ <xsd:element ref="ExtensionBaseMixedContentTypElem"/>
+ <xsd:element ref="ExtensionDerivedMixedContentTypeElem"/>
+
+ <xsd:element ref="RestrictionSimpleContentBaseTypeElem"/>
+ <xsd:element ref="RestrictionSimpleContentDerivedTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseComplexContentTypeElem"/>
+ <xsd:element ref="RestrictionDerivedComplexContentTypeElem"/>
+
+ <xsd:element ref="RestrictionBaseMixedContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedMixedContentTypeElem" />
+
+ <xsd:element ref="RestrictionBaseEmptyContentTypeElem" />
+ <xsd:element ref="RestrictionDerivedEmptyContentTypeElem" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="ExtensionBaseTypeElem" type="ExtensionBaseType"/>
+ <xsd:element name="ExtensionDerivedComplexContentTypeElem" \
type="ExtensionDerivedComplexContentType"/> +
+ <xsd:element name="ExtensionBaseMixedContentTypElem" \
type="ExtensionBaseMixedContentType"/> + <xsd:element \
name="ExtensionDerivedMixedContentTypeElem" type="ExtensionDerivedMixedContentType"/> \
+ + <xsd:element name="RestrictionSimpleContentBaseTypeElem" \
type="RestrictionSimpleContentBaseType"/> + <xsd:element \
name="RestrictionSimpleContentDerivedTypeElem" \
type="RestrictionSimpleContentDerivedType"/> +
+ <xsd:element name="RestrictionBaseComplexContentTypeElem" \
type="RestrictionBaseComplexContentType"/> + <xsd:element \
name="RestrictionDerivedComplexContentTypeElem" \
type="RestrictionDerivedComplexContentType"/> +
+ <xsd:element name="RestrictionBaseMixedContentTypeElem" \
type="RestrictionBaseMixedContentType"/> + <xsd:element \
name="RestrictionDerivedMixedContentTypeElem" \
type="RestrictionDerivedMixedContentType"/> +
+ <xsd:element name="RestrictionBaseEmptyContentTypeElem" \
type="RestrictionBaseEmptyContentType"/> + <xsd:element \
name="RestrictionDerivedEmptyContentTypeElem" \
type="RestrictionDerivedEmptyContentType"/> +
+ <!-- derivation by extension testing...-->
+ <!-- complex type, simple content : headerType from mails_types_added.xsd -->
+
+ <!-- complex type, complex content -->
+ <!-- commented out for testing
+ <xsd:complexType name="ExtensionBaseType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem1" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ -->
+
+
+ <xsd:complexType name="ExtensionDerivedComplexContentType">
+ <xsd:complexContent>
+ <xsd:extension base="ExtensionBaseType">
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="ExtDerivedTypeElem1" type="CarEngineType"/>
+ <xsd:element name="ExtDerivedTypeElem2" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- complex type, mixed content -->
+
+ <xsd:complexType name="ExtensionDerivedMixedContentType" mixed="true">
+ <xsd:complexContent>
+ <xsd:extension base="ExtensionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ExtDerivedMixedElem1" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attribute name="ExtDerivedMixedAttr" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- commented out for testing
+ <xsd:complexType name="ExtensionBaseMixedContentType" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
+ <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ -->
+
+
+ <xsd:complexType name="ExtensionBaseType2">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseTypeElem3" type="xsd:string"/>
+ <xsd:element name="ExtBaseTypeElem4" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="CarEngineType">
+ <xsd:choice>
+ <xsd:element name="Valves" type="xsd:integer"/>
+ <xsd:element name="Capacity" type="xsd:decimal"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <!-- derived types restriction testing -->
+ <!-- 1. complex types : simple content -->
+ <xsd:complexType name="RestrictionSimpleContentBaseType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:integer">
+ <xsd:attribute name="RestrictionSimpleContentBaseAttr1" \
type="xsd:string" /> + </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- restricts the base with range and making the attribute required -->
+ <xsd:complexType name="RestrictionSimpleContentDerivedType">
+ <xsd:simpleContent>
+ <xsd:restriction base="RestrictionSimpleContentBaseType">
+ <xsd:minInclusive value="2" />
+ <xsd:maxExclusive value="6" />
+ <xsd:attribute name= "RestrictionSimpleContentBaseAttr1" \
type="xsd:string" use="required" /> + </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- 2. complex content -->
+ <!-- commented out for testing ..
+ <xsd:complexType name="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string" />
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer" />
+ <xsd:element name="RestrictionBaseElem3" type="xsd:integer" \
minOccurs="0"/> + <xsd:element name="RestrictionBaseElem4" \
type="xsd:string" minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+ -->
+
+ <xsd:complexType name="RestrictionDerivedComplexContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseComplexContentType">
+ <xsd:sequence>
+ <xsd:element name="RestrictionBaseElem1" type="xsd:string"/>
+ <xsd:element name="RestrictionBaseElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- 3. mixed content -->
+ <!-- commented out for testing ..
+ <xsd:complexType name="RestrictionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" \
minOccurs="0"/> + </xsd:sequence>
+ </xsd:complexType>
+ -->
+
+ <xsd:complexType name="RestrictionDerivedMixedContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseMixedContentType">
+ <xsd:sequence>
+ <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- empty content -->
+ <!-- commented out for testing ..
+ <xsd:complexType name="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" type="xsd:integer" />
+ </xsd:complexType>
+ -->
+
+ <xsd:complexType name="RestrictionDerivedEmptyContentType">
+ <xsd:complexContent>
+ <xsd:restriction base="RestrictionBaseEmptyContentType">
+ <xsd:attribute name="RestrictionBaseEmptyContentAttr1" \
type="xsd:short" /> + </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/constraints.xsd
===================================================================
--- test/cases/xbean/compile/som/constraints.xsd (revision 0)
+++ test/cases/xbean/compile/som/constraints.xsd (revision 0)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="root">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="TestRootElemUniqueConstraint" />
+ <xsd:element ref="TestRootElemKeyConstraint" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <!-- unique Constraint - specifies that the child elem for the \
UniqueConstraintSubElem1 has to be unique --> + <xsd:element \
name="TestRootElemUniqueConstraint" type="UniqueConstraintElemType"> + <!-- \
constraint commented out for testing + <xsd:unique name="uniqueConstraint">
+ <xsd:selector xpath="*/UniqueConstraintSubElem1" />
+ <xsd:field xpath="UniqueConstraintSubElem1Child" />
+ </xsd:unique>
+ -->
+ </xsd:element>
+
+ <!-- key Constraint - specifies the child elem for the KeyConstraintSubElem1 \
must exist --> +
+ <xsd:element name="TestRootElemKeyConstraint" type="KeyConstraintElemType">
+ <!-- constraint commented out for testing
+ <xsd:key name="keyConstraint">
+ <xsd:selector xpath="*/KeyConstraintSubElem1"/>
+ <xsd:field xpath="KeyConstraintSubElem1Child"/>
+ </xsd:key>
+ -->
+ <xsd:keyref name="KeyRefConstraint" refer="keyConstraint">
+ <xsd:selector xpath="*/KeyConstraintSubElem1" />
+ <xsd:field xpath="KeyConstraintSubElem1Child2" />
+ </xsd:keyref>
+ </xsd:element>
+
+
+ <xsd:complexType name="UniqueConstraintElemType">
+ <xsd:sequence>
+ <xsd:element name="UniqueConstraintElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="UniqueConstraintSubElem1" \
maxOccurs="unbounded"/> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="KeyConstraintElemType">
+ <xsd:sequence>
+ <xsd:element name="KeyConstraintElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="KeyConstraintSubElem1" \
maxOccurs="unbounded"/> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <!-- the Unique constraint Sub Elem which has a child elem -->
+ <xsd:element name="UniqueConstraintSubElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="UniqueConstraintSubElem1Child" type="xsd:integer" \
maxOccurs="25"></xsd:element> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- the Key constraint Sub Elem which has a child elem -->
+ <xsd:element name="KeyConstraintSubElem1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="KeyConstraintSubElem1Child" \
type="xsd:string"></xsd:element> + </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/instance_simple_types_invalid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_simple_types_invalid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_simple_types_invalid.xml (revision 0)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<testroot>
+ <testAtomicTypeElem>MS Word</testAtomicTypeElem>
+ <testListTypeElem>3</testListTypeElem>
+
+ <testUnionTypeElem>My App</testUnionTypeElem>
+ <testUnionTypeElem>4</testUnionTypeElem>
+
+ <header>This is a test Email Header </header>
+ <testComplexTypeElementOnlyContentElem>
+ <mail>
+ <envelope From="x@bea.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>Xml Beans Testing</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ </mail>
+ </testComplexTypeElementOnlyContentElem>
+
+
+ <testComplexTypeMixedElem>
+
+ <mail>
+ <envelope From="x@bea.com">
+ <From>user@unknown.domain.org</From>
+ <To>user@cduce.org</To>
+ <Date>2003-10-15T15:44:01Z</Date>
+ <Subject>Xml Beans Testing</Subject>
+ <header name="Reply-To">bill@microsoft.com</header>
+ </envelope>
+ </mail>
+
+
+ </testComplexTypeMixedElem>
+
+ <testComplexTypeEmptyElem value="ABC" />
+
+ <testChoiceGroupElem>
+ <Lang>English</Lang>
+ <Font>Arial</Font>
+ </testChoiceGroupElem>
+ <testAllGroupElem>
+ <Greetings>Hello</Greetings>
+ <Signature> Mr X., Bea Systems</Signature>
+ <ContactNumber>425-123-1234</ContactNumber>
+ </testAllGroupElem>
+ <testAllGroupElem>
+ <Greetings>Hello</Greetings>
+ <Signature> Mr X., Bea Systems</Signature>
+ <ContactNumber>425-123-1234</ContactNumber>
+ </testAllGroupElem>
+
+
+</testroot>
Index: test/cases/xbean/compile/som/instance_derived_types_valid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_derived_types_valid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_derived_types_valid.xml (revision 0)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<DerivedTypesTestRoot>
+
+ <ExtensionBaseTypeElem>
+ <ExtBaseTypeElem1>Product One</ExtBaseTypeElem1>
+ <ExtBaseTypeElem2>0001</ExtBaseTypeElem2>
+ </ExtensionBaseTypeElem>
+
+ <ExtensionDerivedComplexContentTypeElem>
+ <ExtBaseTypeElem1>Mazda 6</ExtBaseTypeElem1>
+ <ExtBaseTypeElem2>0001</ExtBaseTypeElem2>
+ <ExtDerivedTypeElem1>
+ <Valves>6</Valves>
+ </ExtDerivedTypeElem1>
+ </ExtensionDerivedComplexContentTypeElem>
+
+ <ExtensionBaseMixedContentTypElem>
+ <ExtBaseMixedElem1>Mixed Base Elem1</ExtBaseMixedElem1>
+ <ExtBaseMixedElem2>
+ <Capacity>2.0</Capacity>
+ </ExtBaseMixedElem2>
+ </ExtensionBaseMixedContentTypElem>
+
+ <ExtensionDerivedMixedContentTypeElem ExtDerivedMixedAttr="1">
+ <ExtBaseMixedElem1>Mixed Base Elem1 Again</ExtBaseMixedElem1>
+ <ExtBaseMixedElem2>
+ <Capacity>1.0</Capacity>
+ </ExtBaseMixedElem2>
+
+ <ExtDerivedMixedElem1>
+
+ </ExtDerivedMixedElem1>
+ </ExtensionDerivedMixedContentTypeElem>
+
+ <RestrictionSimpleContentBaseTypeElem \
RestrictionSimpleContentBaseAttr1="optional \
here">25</RestrictionSimpleContentBaseTypeElem> +
+ <RestrictionSimpleContentDerivedTypeElem \
RestrictionSimpleContentBaseAttr1="required \
here">3</RestrictionSimpleContentDerivedTypeElem> +
+ <RestrictionBaseComplexContentTypeElem>
+ <RestrictionBaseElem1>This is a string type</RestrictionBaseElem1>
+ <RestrictionBaseElem2>25</RestrictionBaseElem2>
+ <RestrictionBaseElem3>2</RestrictionBaseElem3>
+ <RestrictionBaseElem4>This has Min Requires 0 - is missing in the derived \
type </RestrictionBaseElem4> + </RestrictionBaseComplexContentTypeElem>
+
+ <RestrictionDerivedComplexContentTypeElem>
+ <RestrictionBaseElem1>This is a string type</RestrictionBaseElem1>
+ <RestrictionBaseElem2>25</RestrictionBaseElem2>
+ </RestrictionDerivedComplexContentTypeElem>
+
+
+ <RestrictionBaseMixedContentTypeElem>
+ <ResBaseMixedElem1>This is present in the derived type</ResBaseMixedElem1>
+ <ResBaseMixedElem2>
+ <Capacity>2.0</Capacity>
+ </ResBaseMixedElem2>
+ </RestrictionBaseMixedContentTypeElem>
+
+ <RestrictionDerivedMixedContentTypeElem>
+ <ResBaseMixedElem1>This is present in the derived type</ResBaseMixedElem1>
+ </RestrictionDerivedMixedContentTypeElem>
+
+ <RestrictionBaseEmptyContentTypeElem \
RestrictionBaseEmptyContentAttr1="34"></RestrictionBaseEmptyContentTypeElem> + \
<RestrictionDerivedEmptyContentTypeElem \
RestrictionBaseEmptyContentAttr1="1"></RestrictionDerivedEmptyContentTypeElem> +
+
+</DerivedTypesTestRoot>
Index: test/cases/xbean/compile/som/instance_constraints_valid.xml
===================================================================
--- test/cases/xbean/compile/som/instance_constraints_valid.xml (revision 0)
+++ test/cases/xbean/compile/som/instance_constraints_valid.xml (revision 0)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<!-- the uniquness constraint is for value of UniqueConstraintSubElem1Child -->
+
+<root>
+ <TestRootElemUniqueConstraint>
+ <UniqueConstraintElem1>
+ <UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1Child>12</UniqueConstraintSubElem1Child>
+ </UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1>
+ <UniqueConstraintSubElem1Child>10</UniqueConstraintSubElem1Child>
+ </UniqueConstraintSubElem1>
+ </UniqueConstraintElem1>
+ </TestRootElemUniqueConstraint>
+
+ <TestRootElemKeyConstraint>
+ <KeyConstraintElem1>
+ <KeyConstraintSubElem1>
+ <KeyConstraintSubElem1Child>Ok this is a constrained \
Elem</KeyConstraintSubElem1Child> + <!-- Child2 is constrained by a \
keyref and its value has to be the same as Child1 above --> + \
<KeyConstraintSubElem1Child2>Ok this is a constrained \
Elem</KeyConstraintSubElem1Child2> + </KeyConstraintSubElem1>
+ </KeyConstraintElem1>
+ </TestRootElemKeyConstraint>
+</root>
+
+
+
+
Index: test/cases/xbean/compile/som/elemattr_modified.xsd
===================================================================
--- test/cases/xbean/compile/som/elemattr_modified.xsd (revision 0)
+++ test/cases/xbean/compile/som/elemattr_modified.xsd (revision 0)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="TestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SimpleTypeElem" />
+ <xsd:element ref="ComplexTypeElem" />
+ </xsd:sequence>
+ <xsd:attribute ref="testAttributeComplex" />
+ </xsd:complexType>
+
+ </xsd:element>
+
+ <!-- elements -->
+ <xsd:element name="ComplexTypeElem" type="testComplexType"/>
+
+ <!-- modifying the TestRoot Elem by commenting a contained elem
+ <xsd:element name="SimpleTypeElem" type="xsd:string" />
+ -->
+
+ <!-- attributes -->
+ <xsd:attribute name="testAttributeComplex" >
+ <xsd:simpleType>
+ <!--
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="10" />
+ <xsd:maxInclusive value="20" />
+ </xsd:restriction>
+ -->
+ <xsd:restriction base="xsd:string">
+ <xsd:length value="3" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+
+ <xsd:attribute name="testAttrSimple" type="xsd:string"/>
+
+
+ <!-- type definitions -->
+ <xsd:complexType name="testComplexType">
+ <xsd:sequence minOccurs="1" maxOccurs="unbounded">
+ <xsd:element name="testComplexTypeSubElem1" type="xsd:string"/>
+ <xsd:element name="testComplexTypeSubElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ <xsd:attribute ref="testAttrSimple" use="required "/>
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/elemattr.xsd
===================================================================
--- test/cases/xbean/compile/som/elemattr.xsd (revision 0)
+++ test/cases/xbean/compile/som/elemattr.xsd (revision 0)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="TestRoot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SimpleTypeElem" />
+ <xsd:element ref="ComplexTypeElem" />
+ </xsd:sequence>
+ <xsd:attribute ref="testAttributeComplex" />
+ </xsd:complexType>
+
+ </xsd:element>
+
+ <!-- elements -->
+ <!-- comment out element defn for testing
+ <xsd:element name="ComplexTypeElem" type="testComplexType"/>
+ <xsd:element name="SimpleTypeElem" type="xsd:string" />
+ -->
+
+ <!-- attributes -->
+ <!-- commentout for testing
+ <xsd:attribute name="testAttributeComplex">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="10" />
+ <xsd:maxInclusive value="20" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ -->
+
+ <xsd:attribute name="testAttrSimple" type="xsd:string"/>
+
+
+ <!-- type definitions -->
+ <xsd:complexType name="testComplexType">
+ <xsd:sequence minOccurs="1" maxOccurs="unbounded">
+ <xsd:element name="testComplexTypeSubElem1" type="xsd:string"/>
+ <xsd:element name="testComplexTypeSubElem2" type="xsd:integer"/>
+ </xsd:sequence>
+ <xsd:attribute ref="testAttrSimple" use="required "/>
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/groups_modified.xsd
===================================================================
--- test/cases/xbean/compile/som/groups_modified.xsd (revision 0)
+++ test/cases/xbean/compile/som/groups_modified.xsd (revision 0)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="TestRootElem">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SubGrpHeadElem" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- change head elem type for testing
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType" />
+ -->
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType2" />
+
+ <xsd:element name="SubGrpHeadElem2" type="SubGrpHeadElemType2" />
+ <xsd:element name="SubGrpMemberElem1" substitutionGroup="SubGrpHeadElem" />
+ <xsd:element name="SubGrpMemberElem2" type="ExtensionSubGrpHeadElemType" \
substitutionGroup="SubGrpHeadElem"/> +
+
+ <xsd:complexType name="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem1" type="xsd:string" />
+ <xsd:element name="SubGrpInnerElem2" type="xsd:integer" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <!-- modify Extension Type to extend new head type -->
+ <xsd:complexType name="ExtensionSubGrpHeadElemType">
+ <xsd:complexContent>
+ <!-- modified for testing
+ <xsd:extension base="SubGrpHeadElemType">
+ -->
+ <xsd:extension base="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem4" type="xsd:token" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/groups.xsd
===================================================================
--- test/cases/xbean/compile/som/groups.xsd (revision 0)
+++ test/cases/xbean/compile/som/groups.xsd (revision 0)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- elements -->
+ <xsd:element name="TestRootElem">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="SubGrpHeadElem" maxOccurs="unbounded" />
+ <xsd:element ref="ModelGrpTypeElem" minOccurs="1"/>
+ <xsd:element ref="AttrGrpTypeElem" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="SubGrpHeadElem" type="SubGrpHeadElemType" />
+ <xsd:element name="SubGrpHeadElem2" type="SubGrpHeadElemType2" />
+ <xsd:element name="SubGrpMemberElem1" substitutionGroup="SubGrpHeadElem" />
+ <xsd:element name="SubGrpMemberElem2" type="ExtensionSubGrpHeadElemType" \
substitutionGroup="SubGrpHeadElem"/> +
+ <xsd:element name="ModelGrpTypeElem" type="ModelGrpType" />
+ <xsd:element name="AttrGrpTypeElem" type="AttrGrpType" />
+
+
+ <!-- types -->
+
+ <!-- commented out head elem type def for testing
+ <xsd:complexType name="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem1" type="xsd:string" />
+ <xsd:element name="SubGrpInnerElem2" type="xsd:integer" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+ -->
+
+ <xsd:complexType name="ExtensionSubGrpHeadElemType">
+ <xsd:complexContent>
+ <xsd:extension base="SubGrpHeadElemType">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="SubGrpHeadElemType2">
+ <xsd:sequence>
+ <xsd:element name="SubGrpInnerElem3" type="xsd:token" />
+ </xsd:sequence>
+ <xsd:attribute name="SubGrpHeadAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+ <!-- reusable group definitions here -->
+ <!-- Named Model Groups -->
+
+ <xsd:group name="NamedModelGroup">
+ <xsd:sequence>
+ <xsd:element name="ModelGrpElem1" type="xsd:string" />
+ <xsd:element name="ModelGrpElem2" type="xsd:string" minOccurs="1" />
+ </xsd:sequence>
+ </xsd:group>
+
+ <xsd:complexType name="ModelGrpType">
+ <xsd:sequence>
+ <xsd:group ref="NamedModelGroup" minOccurs="1" />
+ <xsd:element name="ModelGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- attribute groups -->
+ <xsd:attributeGroup name="AttributeGroup">
+ <xsd:attribute name="AttrGrpAttribute1" type="xsd:string" use="required"/>
+ <xsd:attribute name="AttrGrpAttribute2" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <xsd:complexType name="AttrGrpType">
+ <xsd:sequence>
+ <xsd:element name="AttrGrpTypeSubElem1" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attributeGroup ref="AttributeGroup"/>
+ <xsd:attribute name="AttrGrpTypeAttr1" type="xsd:string" use="required" />
+ </xsd:complexType>
+
+</xsd:schema>
Index: test/cases/xbean/compile/som/datatypes_added.xsd
===================================================================
--- test/cases/xbean/compile/som/datatypes_added.xsd (revision 0)
+++ test/cases/xbean/compile/som/datatypes_added.xsd (revision 0)
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- global elems -->
+ <xsd:element name="testroot">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" \
type="attchmentExtensionListTypes"/> + <xsd:element \
name="testUnionTypeElem" type="union.attachmentUnionType" maxOccurs="unbounded"/> + \
<xsd:element ref="header"/> <!-- simple content test --> + \
<xsd:element name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + \
<xsd:element name="testComplexTypeMixedElem" type="mixedContentType"/> + \
<xsd:element name="testComplexTypeEmptyElem" type="emptyContentType"/> + \
<xsd:element name="testChoiceGroupElem" type="choiceGroupType"/> + \
<xsd:element name="testAllGroupElem" type="allGroupType"/> + \
</xsd:sequence> + </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="testAtomicTypeElem" type="attachmentTypes"/>
+ <xsd:element name="testListTypeElem" type="attchmentExtensionListTypes"/>
+ <xsd:element name="testUnionTypeElem" type="union.attachmentUnionType"/>
+ <xsd:element name="testComplexTypeSimpleContentElem" type="headerType"/> <!-- \
simple content test --> + <xsd:element \
name="testComplexTypeElementOnlyContentElem" type="mailsType"/> + <xsd:element \
name="testComplexTypeMixedElem" type="mixedContentType"/> + <xsd:element \
name="testComplexTypeEmptyElem" type="emptyContentType"/> + <xsd:element \
name="testChoiceGroupElem" type="choiceGroupType"/> + <xsd:element \
name="testAllGroupElem" type="allGroupType"/> +
+ <!-- Types added for testing -->
+ <!-- Simple Types:atomic type -->
+ <xsd:simpleType name="attachmentTypes">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="MS Word"/>
+ <xsd:enumeration value="Adobe Acrobat"/>
+ <xsd:enumeration value="Ascii Text"/>
+ <xsd:enumeration value="Web Page"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- Simple Types:list type -->
+ <xsd:simpleType name="attachmentNums">
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="1"/>
+ <xsd:maxInclusive value="4"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="attchmentExtensionListTypes">
+ <xsd:list itemType="attachmentNums"/>
+ </xsd:simpleType>
+
+ <!-- Simple Types:union type -->
+ <xsd:simpleType name="union.attachmentUnionType">
+ <xsd:union memberTypes="attachmentTypes attchmentExtensionListTypes">
+ </xsd:union>
+ </xsd:simpleType>
+
+ <!-- End of Simple Types added for testing -->
+
+ <!-- complex types adding testing -->
+ <!-- complex type :simple content : refers to element header-->
+ <xsd:complexType name="headerType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute ref="name" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <!-- complex type :element only content : refers to element header-->
+
+ <xsd:complexType name="mailsType">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- complex type :mixed only content -->
+
+ <xsd:complexType name="mixedContentType" mixed="true">
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="mail" type="mailType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- complex type : empty content -->
+
+ <xsd:complexType name="emptyContentType">
+ <xsd:attribute name="value" type="xsd:integer"/>
+ </xsd:complexType>
+
+ <!-- complex types - choice model grouping -->
+ <xsd:complexType name="choiceGroupType">
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="Lang" type="xsd:string"/>
+ <xsd:element name="Font" type="xsd:string"/>
+ <xsd:element name="Fontcolor" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <!-- complex types - choice 'all' grouping -->
+ <xsd:complexType name="allGroupType">
+ <xsd:all>
+ <xsd:element name="Greetings" type="xsd:string"/>
+ <xsd:element name="Signature" type="xsd:string"/>
+ <xsd:element name="ContactNumber" type="xsd:string"/>
+ </xsd:all>
+ </xsd:complexType>
+
+
+ <!-- other types , attributes and elems from the email schema -->
+ <xsd:element name="mails" type="mailsType"/>
+ <xsd:element name="Date" type="xsd:dateTime"/>
+ <xsd:element name="header" type="headerType" />
+
+ <xsd:attribute name="name" type="xsd:string"/>
+
+ <xsd:attributeGroup name="mimeTypeAttributes">
+ <xsd:attribute name="type" type="mimeTopLevelType" use="required"/>
+ <xsd:attribute name="subtype" type="xsd:string" use="required"/>
+ </xsd:attributeGroup>
+
+ <xsd:complexType name="mailType">
+ <xsd:sequence>
+ <xsd:element name="envelope" type="envelopeType"/>
+ <xsd:element name="body" type="bodyType"/>
+ <xsd:element name="attachment" type="attachmentType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute use="required" name="id" type="xsd:integer"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="envelopeType">
+ <xsd:sequence>
+ <xsd:element name="From" type="xsd:string"/>
+ <xsd:element name="To" type="xsd:string"/>
+ <xsd:element ref="Date"/>
+ <xsd:element name="Subject" type="xsd:string"/>
+ <xsd:element ref="header" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="From" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="bodyType">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+ <xsd:complexType name="attachmentType">
+ <xsd:group ref="attachmentContent"/>
+ <xsd:attribute ref="name" use="required"/>
+ </xsd:complexType>
+
+ <xsd:group name="attachmentContent">
+ <xsd:sequence>
+ <xsd:element name="mimetype">
+ <xsd:complexType>
+ <xsd:attributeGroup ref="mimeTypeAttributes"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="content" type="xsd:string" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:group>
+
+ <xsd:simpleType name="mimeTopLevelType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="text"/>
+ <xsd:enumeration value="multipart"/>
+ <xsd:enumeration value="application"/>
+ <xsd:enumeration value="message"/>
+ <xsd:enumeration value="image"/>
+ <xsd:enumeration value="audio"/>
+ <xsd:enumeration value="video"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic