Page 1 of 1

XML .xsd Schema - Enforce Relationship

Posted: Sun Sep 14, 2014 1:20 pm
by behoove21
I have the following xml which I validate with an .xsd schema.

I can enforce that each of the product names in xProfile exists and is defined in the first half of the xml by using ref and key ref.

I would like to enforce that each 'xProduct' contains an entry for each of the products defined in the top half of the xml but don't know how to do this or if this is possible?

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
    <profiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:noNamespaceSchemaLocation="\\schema.xsd">
        <products>
            <product name="product01" bool_setting="true">
                <code name="AAA"/>
                <code name="BBB"/>
            </product>
            <product name="product02" bool_setting="true">
                <code name="CCC"/>
                <code name="DDD"/>
            </product>
            <product name="product03" bool_setting="true">
                <code name="EEE"/>
            </product>
            <product name="product04" bool_setting="false">
                <code name="FFF"/>
                <code name="GGG"/>
            </product>
            <product name="product05" bool_setting="false">
                <code name="HHH"/>
            </product>
            <product name="product06" bool_setting="false">
                <code name="III"/>
            </product>
        </products>
        <xProfile name="name_one">
            <products>
                <product name="product01" aNumber="1"/>
                <product name="product02" aNumber="1"/>
                <product name="product03" aNumber="1"/>
                <product name="product04" aNumber="1"/>
                <product name="product05" aNumber="1"/>
                <product name="product06" aNumber="1"/>
            </products>
        </xProfile>
            <xProfile name="name_one">
            <products>
                <product name="product01" aNumber="1"/>
                <product name="product02" aNumber="1"/>
                <product name="product03" aNumber="1"/>
                <product name="product04" aNumber="1"/>
                <product name="product05" aNumber="1"/>
                <product name="product06" aNumber="1"/>
            </products>
        </xProfile>
    </profiles>