← Prev in month ← Prev in thread

Re: [xml-dev] XML Designing Problems.

From
Rajesh AVRS <>
To
,
Date
2002-02-08T09:42:18Z
ID
<083701c1b084$e6424940$9f1fc80a@ITPEXE107981>
Thread
Re: [xml-dev] XML Designing Problems.
Thanks for all those who responded.

I am developing an application using the XERCES DOM parser which will
provide some methods using which you can retrive the values from a given XML
document.  For example the below piece of code takes document object as a
parameter and returns the value represented by tagName Node.

 public String getValueByTag(Document document, String tagName, int index)
    throws NullPointerException, Exception
 {
  String value = null;

  try
  {
    NodeList
nodelist=document.getDocumentElement().getElementsByTagName(tagName);

value=((Node)((Element)nodelist.item(index))).getFirstChild().getNodeValue()
.trim();
  }
  catch(Exception e)
  {
   throw e;
  }
  return value;
 }

Now if I have this kind of design for the document the results will be
unpredictable right?  I never know corresponding the which XYZ tag the value
has been returned.  Any suggestions on how I can modify my method so that
the caller can say, get me the value of XYZ which is a child of the root
element or something like that.

Thanks & Regards,
Rajesh


----- Original Message -----
From: "Lisa Retief" <>
To: "'Rajesh AVRS'" <>; <>
Sent: Friday, February 08, 2002 12:10 PM
Subject: RE: [xml-dev] XML Designing Problems.


> Hi Rajesh,
>
> There is nothing wrong with re-using an element in different places and
> levels. A <date> elements, for example, could be used in many contexts in
> the same document. If you are duplicating the actual information then that
> is bad.
>
> Lisa
>
> -----Original Message-----
> From: Rajesh AVRS [mailto:]
> Sent: 08 February 2002 06:25
> To: 
> Subject: [xml-dev] XML Designing Problems.
>
>
> Hi All,
>
> I have an xml document that looks like this.
>
> <XML>
>     <XYZ> Value of xyz </XYZ>
>     <Children1>
>         <ABC> Value of Element1 </ABC>
>         <XYZ> Value for this xyz </XYZ>
>     </Children1>
> </XML>
>
> As you can see, the element XYZ is being used twice, once as the direct
> child of the root and another as children for the element 'Children1'.
>
> My Questions:
>
> 1) Is this an acceptible design for the document?
> 2) Is there any specification that states that XML document shouldn't have
> duplicate elements like this?
>
> Please respond ASAP!
>
> Thanks & Regards,
> Rajesh
>
>
← Prev in month ← Prev in thread