XML Schemas...

A

abu.butt

Hi,

I am still a newbie with XML and was hoping someone could help me with
this query. I want to create an XML Schema that would allow me to have
two elements that have a different structure in two different areas of
XML. It's probably easier if I provide a sample XML :-

<MyXML>
<MDP type="MDP">
<linkFactor type="linkFactor">
<value type="decimal">0.9</value>
</linkFactor>
</MDP>
<MDS type="MDS">
<linkFactor type="linkFactor">0.90</linkFactor>
</MDS>
</MyXML>

Basically, in the above sample linkfactor is present twice, but in the
MDP section I want it to have a value tag.

Is it possible to create an XML Schema to correspond to this ?
I was thinking I need to hide the definitions of linkfactor so that I
have two one for each element. My thoughts of what the actual schema
defn. of this type would be

<xs:complexType name="linkFactorType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="value" type="valueType"/>
</xs:choice>
<xs:attribute name="type" type="xs:string" use="required"/>
</xs:complexType>

for the expanded version that includes the value tag and

<xs:element name="linkFactor" type="linkFactorType"/>

for the simpler type. Just confused on how to pick-up one defn over the
other.


Any guidance greatly appreciated.

Many Thanks,
Ab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top