[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

forcing node content to match

  • To: "'XML Developers List'" <xml-dev@l...>
  • Subject: forcing node content to match
  • From: Doug Marttila <doug@v...>
  • Date: Mon, 09 Jan 2006 15:14:21 -0500
  • User-agent: Thunderbird 1.4 (Windows/20050908)

nodeb xml editor
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>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.