Reg parsing Design

S

sivga

Hi all i wan to whether the right approach for the design is corerct.
this is wat my input xml going to be

<Transactions>
<transctionList>
<Trans name="ADD_AG">
<childTrans>ADD_ED</childTrans>
<childTrans>ADD_CD</childTrans>
</Trans>
<Trans name="ADD_ED">
< actionIntf>add_r</actionIntf>
<actionIntf>add_ml</actionIntf>
<actionIntf>sub_mlk</actionIntf>
</Trans>
<Trans name="ADD_CD">
<actionIntf>add_rkm</actionIntf>
<actionIntf>sub_mlcd</actionIntf>
<actionIntf>sub_mlki</actionIntf>
</Trans>
</transactionList>
</Transactions >


input to the java program will be xml file and Trans name so for eg
when the input is ADD_AG i need to check whether it has any child and
if it is then nee to get all the elements underneath it ..so in this
case we have two child elements so the output should be

ADD_AG
ADD_ED
add_r
add_ml
sub_mlk
Add_CD
add_rkm
sub_mlcd
sub_mlki


when the input is goin to be ADD_ED ( this does not have any child so
)the output is

ADD_ED
add_r
add_ml
sub_mlk

planning to use Jdom and create a tree structure and then store each
node and its contents in alist ...is this approach corerct . after
storing it in a list how do i associate ie check that it has child or
not .

or is is possible to produce a tree structure with above xml like

add_AG ->ADD_ED->add_r ......
|
Add_cd -> add_rkm ..... etc

...what is the right approach to take ..thanks for the help
 
O

Oliver Wong

sivga said:
Hi all i wan to whether the right approach for the design is corerct.
this is wat my input xml going to be

<Transactions>
<transctionList>
<Trans name="ADD_AG">
<childTrans>ADD_ED</childTrans>
<childTrans>ADD_CD</childTrans>
</Trans>
<Trans name="ADD_ED">
< actionIntf>add_r</actionIntf>
<actionIntf>add_ml</actionIntf>
<actionIntf>sub_mlk</actionIntf>
</Trans>
<Trans name="ADD_CD">
<actionIntf>add_rkm</actionIntf>
<actionIntf>sub_mlcd</actionIntf>
<actionIntf>sub_mlki</actionIntf>
</Trans>
</transactionList>
</Transactions >


input to the java program will be xml file and Trans name so for eg
when the input is ADD_AG i need to check whether it has any child and
if it is then nee to get all the elements underneath it ..so in this
case we have two child elements so the output should be

ADD_AG
ADD_ED
add_r
add_ml
sub_mlk
Add_CD
add_rkm
sub_mlcd
sub_mlki


when the input is goin to be ADD_ED ( this does not have any child so
)the output is

ADD_ED
add_r
add_ml
sub_mlk

planning to use Jdom and create a tree structure and then store each
node and its contents in alist ...is this approach corerct .

This approach sounds fine to me.
after
storing it in a list how do i associate ie check that it has child or
not .

Assuming each item in your list is one of those Trans element, you can
just ask the element whether or not it has children.

- Oliver
 
S

sivga

thanks oliver so the approach woould be to build a tree store all its
elements in a list and then manipulate the list ie looking each list
whether it has elements right ?
 
O

Oliver Wong

sivga said:
thanks oliver so the approach woould be to build a tree store all its
elements in a list and then manipulate the list ie looking each list
whether it has elements right ?

I'd use a hashtable, and I wouldn't store all the elements (only the
Trans elements) but otherwise yes.

- Oliver
 
M

Mark Jeffcoat

sivga said:
thanks oliver so the approach woould be to build a tree store all its
elements in a list and then manipulate the list ie looking each list
whether it has elements right ?


If you squint at that paragraph just right, it describes
every reasonable algorithm on an XML document interpreted
with the Document Object Model.


Just do it. Nobody's going to be able to give you a complete
tutorial on designing programs in a single post. If you
get stuck somewhere, you can ask a more specific question.
By the time you're done, you'll know how to do it better
next time.
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top