making reference to other elements...

  • Thread starter Pablo Gomes Ludermir
  • Start date
P

Pablo Gomes Ludermir

Hello,

I have the following case that I am trying to put in XML Schema.
I have the classes HelpItem, Document and Message that work as follows:

One HelpItem contains several Document and Message instances.
Thus, in XML Document and Message are child elements of HelpItem.

However, a Message may have a reference to one or several existing
Docuemnt instances, and also may have a reference to one or several
Message instances (its replies) and another Message that it is the
parent Message (the Message that I am replying to).

How can I make the references to the documents and other messages (I
hope that the reference to the messages is correct in the example bellow)?

The following information is to keep it more clear:

class Message
- referencedDocuments List
- conversation List //messages that reply the current one (optional)
- parentMessage Message //the message that I am replying to
end class

<xs:element name="Document" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:ID" use="required"/>
... other attributes here
</xs:complexType>
</xs:element>


<xs:element name="Message" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="parentMessage" type="xs:IDREF" use="optional"/>
<xs:attribute name="conversation" type="xs:IDREFS" use="optional"/>
... other attributes here
</xs:complexType>
</xs:element>
 
M

Martin Honnen

Pablo Gomes Ludermir wrote:

I have the following case that I am trying to put in XML Schema.
I have the classes HelpItem, Document and Message that work as follows:

One HelpItem contains several Document and Message instances.
Thus, in XML Document and Message are child elements of HelpItem.

However, a Message may have a reference to one or several existing
Docuemnt instances, and also may have a reference to one or several
Message instances (its replies) and another Message that it is the
parent Message (the Message that I am replying to).

How can I make the references to the documents and other messages (I
hope that the reference to the messages is correct in the example bellow)?

The following information is to keep it more clear:

class Message
- referencedDocuments List
- conversation List //messages that reply the current one (optional)
- parentMessage Message //the message that I am replying to
end class

<xs:element name="Document" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:ID" use="required"/>
... other attributes here
</xs:complexType>
</xs:element>


<xs:element name="Message" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="parentMessage" type="xs:IDREF" use="optional"/>
<xs:attribute name="conversation" type="xs:IDREFS" use="optional"/>
... other attributes here
</xs:complexType>
</xs:element>

On a first look your use of xs:ID and xs:IDREF and xs:IDREFS seems fine
to me. Or are you getting any error messages from a schema processor?
 
P

Pablo Gomes Ludermir

Well, XMLSpy did not make any complaints. But the point was that I don't
know how to figure out the reference from the message to the document
element.
And another thing is that the ID is not on the local scope of the
element, but of the whole document. Is there a way to keep the ID unique
on the scope of the element?

Regards,
Pablo
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top