jeudi 30 janvier 2020

How to validate if one attribute value is always a value of another attribute in XML by XSD

I have an xm structure like this and I want to Validate the XMl with XSD

<recipeConfig>
    <recipeStructures> <!-- recipe template/ recipeStructureTypes-->

        <recipeStructureDef mnemonic="BREAD" title="Recipe.Bread"/>
        <recipeStructureDef mnemonic="CAKE" title="Recipe.Bread"/> 
         <recipeStructureDef mnemonic="PANCAKE" title="Recipe.Bread"/> 

     </recipeStructures>
     <preDefinedRecipes>
        <preDefinedRecipe type="BREAD" name="sweet bread"  ordinal="1" writerLevel="Service">
        <parameterDef ref="SUGAR_QTY" value="3" />
                <parameterDef ref="SALT_QTY" value="3" />
                <parameterDef ref="OIL_QTY" value="1" /> 

        </preDefinedRecipe>
      </preDefinedRecipes>
</recipeConfig>

I want to check if the <preDefinedRecipe type="BREAD"> is always a value of mnemonic attribute from recipeStructureDef mnemonic= ""

I am stuck here and i dont know how to proceed.Below is my part of code form XSD

  <xs:complexType name="preDefinedRecipeType">
    <xs:sequence>

    <xs:element type="preDefinedRecipeParameterDefType" name="parameterDef" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="type" use="required"/>
    <xs:attribute type="xs:string" name="name" use="required"/>
    <xs:attribute type="xs:byte" name="ordinal" use="required"/>
    <xs:attribute type="xs:string" name="writerLevel" use="required"/>
  </xs:complexType>

Thanks in advance for the help

Aucun commentaire:

Enregistrer un commentaire