Peter
Peter

Reputation: 1

xml node reference and xsd schema

Im new to xml/xsd and Im dealing with issue if is possible to make reference to another node in xml and make propper xsd schema for it.

This is how i need to use it:

<data type="String">
    <id>1</id>
    <value>hello</value>
</data>
<data type="Integer">
    <id>2</id>
    <value>12345</value>
</data>
<function>
    <args>
        <reference to data with id 1>
        ...
    </args>
    <code>...</code>
<function>
<function>
    <args>
        <reference to data with id 2>
        ...
    </args>
    <code>...</code>
<function>

Is it possible to achive something like that? If yes, than how should xml and xsd schema look like ? Thanks in advance.

Upvotes: 0

Views: 138

Answers (1)

Michael Kay
Michael Kay

Reputation: 163645

Yes, it is possible. You define data/id as a key, and function/args/reference as a keyref. I suggest you do some reading on key/keyref and then come back here if you can't make it work. There are plenty of examples on StackOverflow, but for an overview you're better off looking at an XML Schema textbook or online tutorial.

Upvotes: 1

Related Questions