[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Designing Problems.

  • To: <lisa@i...>, <xml-dev@l...>
  • Subject: Re: XML Designing Problems.
  • From: "Rajesh AVRS" <rajesh.ram@w...>
  • Date: Fri, 8 Feb 2002 15:12:18 +0530
  • References: <007a01c1b06b$7374fac0$1b08a8c0@lisa>

getvaluebytag
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" <lisa@i...>
To: "'Rajesh AVRS'" <rajesh.ram@w...>; <xml-dev@l...>
Sent: Friday, February 08, 2002 12:10 PM
Subject: RE:  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:rajesh.ram@w...]
> Sent: 08 February 2002 06:25
> To: xml-dev@l...
> Subject:  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
>
>

**************************Disclaimer************************************
      


Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.



 ********************************************************************

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.