OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   forcing node content to match

[ Lists Home | Date Index | Thread Index ]
  • To: "'XML Developers List'" <xml-dev@lists.xml.org>
  • Subject: forcing node content to match
  • From: Doug Marttila <doug@visual-io.com>
  • Date: Mon, 09 Jan 2006 15:14:21 -0500
  • User-agent: Thunderbird 1.4 (Windows/20050908)


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).



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"; 
                <noValue_o hasValue_b="false"/>
                <value_o hasValue_b="true" someMetric_n="10"/>
                <noValue_o hasValue_b="false"/>
                <noValue_o hasValue_b="false"/>
                <value_o hasValue_b="true" value_n="20"/>
                <noValue_o hasValue_b="false"/>


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS