Jump to content

deny combination of certain element with others element value

Recommended Posts

Need help for problem resolution with schema (maybe not?)I have a instance file like below:

<?xml version="1.0" encoding="utf-8"?><report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="bilances_poz.xsd"><row><row_id>A1</poz_id><row_country_code>US</row_country_code><row_currency_code>USD</row_currency_code> <gowernm>999</gowernm> <local>999</local> <issuers>999</issuers> <credit_instit>999</credit_instit> <private>999</private></row><row><row_id>A2</poz_id><row_country_code>PL</row_country_code><row_currency_code>POL</row_currency_code> <gowernm>888</gowernm> <local>888</local> <issuers>888</issuers> <credit_instit>888</credit_instit> <private>888</private></row></report>

Is it possible to define in schema to avoid the combination of element <row_id> value A1 with element <issuers> and A2 with <private> ? There could be more than one disallowed combinations per each row_id.I made a syntax by myself, but it is no approved with w3, of course.

<xs:denycombinations><xs:deny name="issuers"><xs:element name="row_id"><xs:element value="A1"/></xs:element></xs:deny><xs:deny name="private"><xs:element name="row_id"><xs:element value="A2"/><xs:element value="A3"/><xs:element value="A5"/></xs:element></xs:deny></xs:denycombinations>

Thank you for your time!Janis

Link to post
Share on other sites
  • 3 weeks later...

Nope. Schema doesn't care about anything but element names. (read my other post Here for more about schemas and what can, cannot, should, and shouldn't be done with them, along with a more theoretical definition of XML).Your solution here, however, is simple: inheritance:

<schema xmlns="...schema ns...">  <complexType name="rowType" abstract="true">	<element name="row_id" type="string" />	<element name="row_country_code" type="string />	<!--and all the others (but Neither issuers nor private-->  </complexType>  <complexType name="issuers_rowType">	<complexContent>	  <extension base="target:rowType">		<element name="issuers" type="integer"/>	  </extension>	</complexContent>  </complexType>  <complexType name="private_rowType">	<complexContent>	  <extension base="target:rowType">		<element name="private" type="integer"/>	  </extension>	</complexContent>  </complexType></schema>


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...