Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of <ref> to refer a nested composite type. #123

Open
cardefusco opened this issue Jun 6, 2020 · 2 comments
Open

Use of <ref> to refer a nested composite type. #123

cardefusco opened this issue Jun 6, 2020 · 2 comments
Labels

Comments

@cardefusco
Copy link

cardefusco commented Jun 6, 2020

My question is, referring to SBE 2.x, if is possible to use the <ref> tag to link to a composite type that was just defined as a nested composite.
I try to explain it with an example.
Imagine that I have this:

<composite name="longPrice">
    <type name="mantissa" primitiveType="int64" />
    <type name="exponent" primitiveType="int8" />
    <composite name="priceType">
		<type name="internalPriceCode" primitiveType="char" length="3"/>
		<enum name="enumPriceCode" encodingType="uint8">
			<validValue name="USD">0</validValue> 
			<validValue name="EUR">1</validValue>
		</enum>
    </composite>	
</composite>	

<composite name="shortPrice">
    <type name="mantissa" primitiveType="int32" />
    <type name="exponent" primitiveType="int8" />
    <ref name="priceTypeRef" type="priceType" offset="5" />
</composite>	

Technically the XSD of version 2.x allows this. So is this correct? Could I use a <ref> tag in this way where the composite "priceType" is referred despite is nested definition?

I think that however is desiderable and maybe better to have this solution, right?:

<composite name="priceType">
	<type name="internalPriceCode" primitiveType="char" length="3"/>
	<enum name="enumPriceCode" encodingType="uint8">
		<validValue name="USD">0</validValue> 
		<validValue name="EUR">1</validValue>
	</enum>
</composite>

<composite name="longPrice">
    <type name="mantissa" primitiveType="int64" />
    <type name="exponent" primitiveType="int8" />
    <ref name="priceTypeRef" type="priceType" offset="9" />
</composite>	


<composite name="shortPrice">
    <type name="mantissa" primitiveType="int32" />
    <type name="exponent" primitiveType="int8" />
    <ref name="priceTypeRef" type="priceType" offset="5" />
</composite>	
@donmendelson
Copy link
Member

The specification says that the type attribute of <ref> ...

Must match a defined type, enum or set or composite name attribute.

It seems to me that your second example is in line with the intent of the specification.

@cardefusco
Copy link
Author

Ok. Could be useful, I think, to refer a nested composite using "." to concatenate the nested composite. In this way I can write longPrice.priceTypeRef
For example, referring to my first example I could write:

<ref name="longPrice.priceTypeRef" type="priceType" offset="5" />

This could be an idea to avoid ambiguous interpretation, even if I prefer my second example above where there is not a referring to a nested composite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants