Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF support for block(<xsd:complexType name="name" block="#all">)
EMF support for block [message #655170] Fri, 18 February 2011 14:38 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Another edge case Smile

I have a schema that looks like the following

	<xsd:complexType name="coreIdentifier" block="#all">
		<xsd:sequence>
			<xsd:element name="surname" type="xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:complexType name="enhancedIdentifier">
		<xsd:complexContent>
			<xsd:extension base="ns1:coreIdentifier">
				<xsd:sequence>
					<xsd:element name="firstname" type="xsd:string"/>
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>
	<xsd:complexType name="Household">
		<xsd:sequence>
			<xsd:element name="family" type="ns1:coreIdentifier"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name="myBaseInfo" type="ns1:coreIdentifier"/>
	<xsd:element name="myFullInfo" type="ns1:enhancedIdentifier"/>
	<xsd:element name="myHousehold" type="ns1:Household"/>


The code is generated fine, however with the use of block="#all" a user would
normally expect it not to be possible to do the following:

	EnhancedIdentifier createenhancedIdentifier = ComplexBlockFactory.eINSTANCE.createEnhancedIdentifier();
	createenhancedIdentifier.setFirstname("Barney");
	createenhancedIdentifier.setSurname("Rubble");
		
	Household createHousehold = ComplexBlockFactory.eINSTANCE.createHousehold();
	createHousehold.setFamily(createenhancedIdentifier);


As the "block" would prevent any coreIdentifier element being set with anything other than
another coreIdentifier (i.e. nothing that extends coreIdentifier)

Unfortunately, this does not fail on validate either, and it can also read in invalid XML OK.

I have had a look at the ecore generated from this XSD and it does not appear to include anything to highlight
the existance of the block.

I have also investigated the use of block on elements:

	<xsd:complexType name="Household">
		<xsd:sequence>
			<xsd:element name="family" type="ns1:coreIdentifier" block="#all"/>
		</xsd:sequence>
	</xsd:complexType>


And this appears to behave in the same way.

Am I correct in assuming that this is one of the edge cases that EMF does not support, or have I miss-configured my system?

Thanks, Rob
Re: EMF support for block [message #655646 is a reply to message #655170] Tue, 22 February 2011 06:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Rob,

There's no support for block.

Rob wrote:
> Another edge case :)
> I have a schema that looks like the following
>
> <xsd:complexType name="coreIdentifier" block="#all">
> <xsd:sequence>
> <xsd:element name="surname" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="enhancedIdentifier">
> <xsd:complexContent>
> <xsd:extension base="ns1:coreIdentifier">
> <xsd:sequence>
> <xsd:element name="firstname" type="xsd:string"/>
> </xsd:sequence>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
> <xsd:complexType name="Household">
> <xsd:sequence>
> <xsd:element name="family" type="ns1:coreIdentifier"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:element name="myBaseInfo" type="ns1:coreIdentifier"/>
> <xsd:element name="myFullInfo" type="ns1:enhancedIdentifier"/>
> <xsd:element name="myHousehold" type="ns1:Household"/>
>
> The code is generated fine, however with the use of block="#all" a
> user would
> normally expect it not to be possible to do the following:
>
> EnhancedIdentifier createenhancedIdentifier =
> ComplexBlockFactory.eINSTANCE.createEnhancedIdentifier();
> createenhancedIdentifier.setFirstname("Barney");
> createenhancedIdentifier.setSurname("Rubble");
>
> Household createHousehold =
> ComplexBlockFactory.eINSTANCE.createHousehold();
> createHousehold.setFamily(createenhancedIdentifier);
>
> As the "block" would prevent any coreIdentifier element being set with
> anything other than another coreIdentifier (i.e. nothing that extends
> coreIdentifier)
>
> Unfortunately, this does not fail on validate either, and it can also
> read in invalid XML OK.
>
> I have had a look at the ecore generated from this XSD and it does not
> appear to include anything to highlight
> the existance of the block.
>
> I have also investigated the use of block on elements:
>
> <xsd:complexType name="Household">
> <xsd:sequence>
> <xsd:element name="family" type="ns1:coreIdentifier"
> block="#all"/>
> </xsd:sequence>
> </xsd:complexType>
>
> And this appears to behave in the same way.
>
> Am I correct in assuming that this is one of the edge cases that EMF
> does not support, or have I miss-configured my system?
>
> Thanks, Rob
Previous Topic:Serializing EObject using Object handle
Next Topic:In memory Ecore to XSD
Goto Forum:
  


Current Time: Fri Oct 18 08:50:25 GMT 2019

Powered by FUDForum. Page generated in 0.01932 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top