Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


forcing node content to match

From: Doug Marttila <doug@---------.--->
To: "'XML Developers List'" <xml-dev@-----.---.--->
Date: 1/9/2006 8:14:00 PM
Hi,

I am writing an xsd and want the content of one node to force the 
content of another. The explanation for why I need this is rather long 
(if anyone's interested, I'd be happy to share).

The best way to describe the problem is as an example...

A parentNode has two child nodes, NodeA and NodeB.

NodeA can have 3 nodes - Node1, Node2, etc. These nodes are different 
and could even be attributes. (If NodeA defined a person, Node1=name, 
Node2=age, etc.)

NodeB must match the structure of NodeA. So, if NodeA has a value for 
Node1, NodeB must have a value for Node1. And, if NodeA does not have a 
value, NodeB cannot.

What I've ended up doing is adding child nodes to Node1, 2, etc. - so 
that Node1, instead of having a value, actually has a choice - that 
choice is a value node and a noValue node. Then using key/keyRefs and 
restricted attributes (restricted to 1 value - true or false) I can 
force NodeB to match up.

Hopefully that makes sense. The solution works - but, results in verbose 
xml (nodes describe themselves as having no value instead of just not 
existing) and seems pretty klugey. Is there a better way to do this w/ 
an xsd? Or - is there another technology that can be used to achieve 
this? I am only familiar with xsds and xml. Other technologies are 
discussed on this list that I know nothing about (e.g., schematron).

Thanks,

Doug

below is some sample xml that might better describe the problem. I also 
have a sample xsd - but, it's rather long (125 lines). I'll post if 
someone requests.

<forcingNodes_r xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="forceContent.xsd">
    <var_o>
        <nodeA>
            <Node1>
                <noValue_o hasValue_b="false"/>
            </Node1>
            <Node2>
                <value_o hasValue_b="true" someMetric_n="10"/>
            </Node2>
            <Node3>
                <noValue_o hasValue_b="false"/>
            </Node3>
        </nodeA>
        <nodeB>
            <Node1>
                <noValue_o hasValue_b="false"/>
            </Node1>
            <Node2>
                <value_o hasValue_b="true" value_n="20"/>
            </Node2>
            <Node3>
                <noValue_o hasValue_b="false"/>
            </Node3>
        </nodeB>
    </var_o>
</forcingNodes_r>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent