You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by sshanmug <sr...@fico.com> on 2014/07/15 18:08:19 UTC
Adding XSD 1.1 assertions to a complex type
I am using the XSD 1.1 and trying to add assertions to the complex types.
I have an abstract complex type and another concrete complex type extending
the abstract complex type.
For example:
<xs:complexType name="abstract-comp-type" abstract="true">
<xs:sequence>
<xs:element type="xs:string" name="description" minOccurs="1"
maxOccurs="1" />
<xs:element name="comp-id" type="xs:ID" minOccurs="1" />
</xs:complexType>
<xs:complexType name="concrete-comp-type">
<xs:complexContent>
<xs:extension base="abstract-comp-type">
<xs:sequence>
<xs:element name="element1" type="xs:string" minOccurs="1"
fixed="test"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
If I have more than one complex types extending from abstract-comp-type,
how do I add validation to check if all the sub types have an element named
element1?
The reason why I need to add element1 in the sub type is to provide a fixed
value. I cannot use restriction because the sub type will have more elements
than the abstract type.
I created a JIRA ticket for this issue and the resolution given for that is
to open a question in the forum.
--
View this message in context: http://apache-xml-project.6118.n7.nabble.com/Adding-XSD-1-1-assertions-to-a-complex-type-tp41267.html
Sent from the Xerces - J - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Adding XSD 1.1 assertions to a complex type
Posted by Mukul Gandhi <mu...@apache.org>.
On 15 July 2014 21:38, sshanmug <sr...@fico.com> wrote:
> If I have more than one complex types extending from abstract-comp-type,
> how do I add validation to check if all the sub types have an element named
> element1?
>
> <j-...@xerces.apache.org>
I think, this can be simply accomplished by having following assertion
within your type abstract-comp-type,
<xs:assert test="element1"/>
This will work for your requirement, because asserts are derived all the
way down the type hierarchy.
--
Regards,
Mukul Gandhi
Re: Adding XSD 1.1 assertions to a complex type
Posted by Mukul Gandhi <mu...@apache.org>.
On 17 July 2014 21:19, sshanmug <sr...@fico.com> wrote:
> Thanks for the response. I added the assert and it's working.
> Basically I added the following assert
> <xs:assert test="exists(element1)" />
>
That shall also work. Its upto you. If you wish to save few keystrokes, you
can opt for the <assert> I mentioned.
--
Regards,
Mukul Gandhi
Re: Adding XSD 1.1 assertions to a complex type
Posted by sshanmug <sr...@fico.com>.
Thanks for the response. I added the assert and it's working.
Basically I added the following assert
<xs:assert test="exists(element1)" />
--
View this message in context: http://apache-xml-project.6118.n7.nabble.com/Adding-XSD-1-1-assertions-to-a-complex-type-tp41267p41274.html
Sent from the Xerces - J - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org