Perhaps my note was too long to consider. I will try to condense.
If I have an XML Stream like this:
<SoccerPitch>
<RedChap/>
<BlackChap/>
<Midfield/>
<RedChap/>
<BlackChap/>
</SoccerPitch>
And a Schema for this stream like this:
<xsd:element name="SoccerPitch">
<xsd:complexType>
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="RedChap" type="xsd:string"/>
<xsd:element name="BlackChap" type="xsd:string"/>
</xsd:choice>
<xsd:element name="Midfield" type="xsd:string"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="RedChap" type="xsd:string"/>
<xsd:element name="BlackChap" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Should I expect the unmarshaling order to be retained such that I can get
the number of Black & Red chaps prior to the Midfield element and the
number of Black & Red chaps after the Midfield element?
Kind Regards,
Greg Kedge
716-25-35127
Gregory_Kedge@ne
xpress.com To: [EMAIL PROTECTED]
cc:
10/03/2002 11:58 Subject: [castor-dev] Should Sequence
Order be Maintained?
AM
Please respond
to castor-dev
I have an XML Schema that describes a soccer pitch having red and black
shirted players. The XML stream order of player elements combined with a
Midfield element attempts to determine how may of each of the two team
members are on either side of Midfield using the order of the stream to
count. So, with this XML stream:
<?xml version="1.0"?>
<SoccerPitch xmlns="WorldCup" xmlns:ex="WorldCup"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="WorldCup ../xsd/SoccerPitch.xsd">
<RedChap/>
<BlackChap/>
<Midfield/>
<RedChap/>
<BlackChap/>
</SoccerPitch>
I would expect order to be maintained when unmarshalled to show two players
on either side of Midfield, one from each team. The expected print
out(Parenthesis encapsulate total player count):
RedChap(0)
BlackChap(1)
Midfield
RedChap(2)
BlackChap(3)
The following schema that I Castorize seems to constrain the stream
properly:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="WorldCup" xmlns="WorldCup"
elementFormDefault="qualified">
<xsd:element name="SoccerPitch">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>
Type to deal with a soccer pitch having Red and Black jersey
players.
The hope is to allow for players to play both sides of Midfield.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="RedChap" type="xsd:string"/>
<xsd:element name="BlackChap" type="xsd:string"/>
</xsd:choice>
<xsd:element name="Midfield" type="xsd:string"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="RedChap" type="xsd:string"/>
<xsd:element name="BlackChap" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Catorizing produces the expected 2 Choices and access to the Midfield
element. However, the first choice always snarfs up ALL players leaving
the second choice collection with nothing to show. I generate the
following output:
RedChap(0)
BlackChap(1)
RedChap(2)
BlackChap(3)
Midfield <---- Red Card!
Using this Java source:
private void printDocument(SoccerPitch doc) {
int elements = 0;
// (
// <---------------------- s ---------------------->
// (RedChap|BlackChap)*,Midfield,(RedChap|BlackChap)*
// <------- sc1 ------> <------- sc2 ------>
// )
if (doc.getSoccerPitchChoiceCount() > 0) {
for (Enumeration sc1Enum = doc.enumerateSoccerPitchChoice();
sc1Enum.hasMoreElements();)
{
SoccerPitchChoice sc1
= (SoccerPitchChoice)sc1Enum.nextElement();
SoccerPitchChoiceItem sc1Item =
sc1.getSoccerPitchChoiceItem();
if (sc1Item.getRedChap() != null)
System.out.println("RedChap(" + elements++ + "): " +
sc1Item.getRedChap());
else if (sc1Item.getBlackChap() != null)
System.out.println("BlackChap(" + elements++ + "): " +
sc1Item.getBlackChap());
}
}
if (doc.getMidfield() != null)
System.out.println("Midfield");
else
System.out.println("Error! Should have Midfield somewhere...");
if (doc.getSoccerPitchChoice2Count() > 0) {
for (Enumeration sc2Enum = doc.enumerateSoccerPitchChoice2();
sc2Enum.hasMoreElements();)
{
SoccerPitchChoice2 sc2
= (SoccerPitchChoice2)sc2Enum.nextElement();
SoccerPitchChoice2Item sc2Item =
sc2.getSoccerPitchChoice2Item();
if (sc2Item.getRedChap() != null)
System.out.println("RedChap(" + elements++ + "): " +
sc2Item.getRedChap());
else if (sc2Item.getBlackChap() != null)
System.out.println("BlackChap(" + elements++ + "): " +
sc2Item.getBlackChap());
}
}
System.out.println("");
} // void printDocument()
Kind Regards,
Greg K
______________________________________________________________________
IMPORTANT NOTICE:
The information in this email is confidential and proprietary to NexPress
Solutions LLC and may be legally privileged. It is for the intended
recipient(s) named above only. Any unauthorized review, printing, copying,
use or distribution of this email by anyone else is prohibited and may be a
criminal offense. If you have received this email in error, please notify
the
sender immediately by reply email and delete the original message.
______________________________________________________________________
IMPORTANT NOTICE:
The information in this email is confidential and proprietary to NexPress
Solutions LLC and may be legally privileged. It is for the intended
recipient(s) named above only. Any unauthorized review, printing, copying,
use or distribution of this email by anyone else is prohibited and may be a
criminal offense. If you have received this email in error, please notify
the
sender immediately by reply email and delete the original message.
______________________________________________________________________
IMPORTANT NOTICE:
The information in this email is confidential and proprietary to NexPress
Solutions LLC and may be legally privileged. It is for the intended
recipient(s) named above only. Any unauthorized review, printing, copying,
use or distribution of this email by anyone else is prohibited and may be a
criminal offense. If you have received this email in error, please notify
the
sender immediately by reply email and delete the original message.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
______________________________________________________________________
IMPORTANT NOTICE:
The information in this email is confidential and proprietary to NexPress
Solutions LLC and may be legally privileged. It is for the intended
recipient(s) named above only. Any unauthorized review, printing, copying,
use or distribution of this email by anyone else is prohibited and may be a
criminal offense. If you have received this email in error, please notify
the
sender immediately by reply email and delete the original message.
______________________________________________________________________
IMPORTANT NOTICE:
The information in this email is confidential and proprietary to NexPress
Solutions LLC and may be legally privileged. It is for the intended
recipient(s) named above only. Any unauthorized review, printing, copying,
use or distribution of this email by anyone else is prohibited and may be a
criminal offense. If you have received this email in error, please notify
the
sender immediately by reply email and delete the original message.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev