xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Srivastava <Rahul.Srivast...@Sun.COM>
Subject Re: Traversing an XMLDocument
Date Wed, 12 Sep 2001 12:18:35 GMT
If  you want pqr and lmn to be treated as two different names and abc+xyz as a 
single name, then, where is the problem!!.

You can parse your xml file using SAX/DOM. Anything that you encounter b/w 
elements <name> and </name> events in SAX can be marked as a single name. 
Alternatively, if you are using DOM, all the childs of Node "Name" represent a 
single name. These childs may have both LastName, Firstname or just one or none.

Cheers,
Rahul.


> From: "abhishekhp" <abhishekhp@infy.com>
> To: <xerces-j-user@xml.apache.org>
> 
> Hi,
> Suppose i have the following in an XSD
> <xsd:complexType name="Name" minOccurs="0" maxOccurs = "3">
> 	<xsd:sequence>
> 		<xsd:element name="FirstName" type="xsd:string"
> minOccurs="0" maxOccurs="1">
> 		<xsd:element name="LastName" type="xsd:string"
> minOccurs="0" maxOccurs="1">
> 	</xsd:sequence>
> </xsd:complexType>
> 
> i.e Name itself is optional, so are the subelements within it.
> 
> I need to have name-value pairs for FirstName and LastName within the
> same Name tag.
> i.e. if
> <Name>
> 	<FirstName>abc</FirstName>
> 	<LastName>xyz</LastName>
> </Name>
> <Name>
> 	<FirstName>pqr</FirstName>
> </Name>
> <Name>
> 	<LastName>lmn</LastName>
> </Name>
> 
> I have the Document type object with me. I want 'abc and 'xyz' to be
> together (say, stored in one java object) because they occur in the same
> <Name> tag, but 'pqr' and 'lmn' should be separate from each other (in
> different objects) because they occur in different <Name> tags.
> 
> Any pointers, how this can be done?
> 
> TIA,
> abhishek.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Mime
View raw message