Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > making reference to other elements...

Reply
Thread Tools

making reference to other elements...

 
 
Pablo Gomes Ludermir
Guest
Posts: n/a
 
      11-27-2004
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>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-27-2004


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?

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Pablo Gomes Ludermir
Guest
Posts: n/a
 
      11-27-2004
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

Martin Honnen wrote:
>
>
> 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?
>

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      11-27-2004


Pablo Gomes Ludermir wrote:


> 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?


xs:ID needs to be unique inside of the complete document but you can use
xs:key to define keys in the scope of an element, see the example in
http://www.w3.org/TR/xmlschema-0/#sp...ysAndtheirRefs

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A fresh new approach to making making online Fakename Computer Information 0 11-18-2005 02:10 AM
Making new Flavors : Making a custom transferhandler for and drop applications ebby83@gmail.com Java 5 01-12-2005 11:10 AM
Making A Particular Folder "Stand Out" From The Other Folders ? Robert11 Computer Support 1 11-26-2004 03:54 PM
Making Macros available to other users? John Computer Information 7 04-13-2004 07:19 AM
Making files on other Servers available Halvor Nyberg ASP .Net 0 10-16-2003 09:09 AM



Advertisments