• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

select first child element values

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am newbie to xslt, just a day old.

i have a xml file like this

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="C:/Documents and Settings/nbk8paw/Desktop/Capture Activity By Card Type/cvsraw1.xsl"?>
<RowSet>
<Row>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
</Row>
<Row>
<MID>3896025600000513</MID>
<MCC>8011</MCC>
<Merch_Name>LINCOLN PARK FAMILY PHYSICIANS</Merch_Name>
<Merch_City>CHICAGO</Merch_City>
<Merch_Zip>606141207</Merch_Zip>
<Merch_State>IL</Merch_State>
<RunDate>4/14/2006</RunDate>
<Bank>3896</Bank>
<Rpt_ID>C101C</Rpt_ID>
<Rpt_Start_Date>10/01/2005</Rpt_Start_Date>
<Rpt_End_Date>03/01/2006</Rpt_End_Date>
<Rpt_Title>Capture Activity By Card Type</Rpt_Title>

<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$20.00</Tran_Amt>
<CardHolder_Num>4782001005905413 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>060710</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$20.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$10.00</Tran_Amt>
<CardHolder_Num>4782001005593201 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>010715</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$10.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$20.00</Tran_Amt>
<CardHolder_Num>4720460020899388 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>619862</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$20.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$20.00</Tran_Amt>
<CardHolder_Num>4782001004243576 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>085613</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$20.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$20.00</Tran_Amt>
<CardHolder_Num>4385110700026796 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>721901</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$20.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$20.00</Tran_Amt>
<CardHolder_Num>4264299459270204 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>05509A</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$20.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans></Trans>
<Trans></Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$15.00</Tran_Amt>
<CardHolder_Num>5491139051734409 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>068235</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$15.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans>
<POS_Entry>90-Swiped</POS_Entry>
<Tran_Amt>$35.00</Tran_Amt>
<CardHolder_Num>5416600046950402 </CardHolder_Num>
<Tran_Date>02/24/2006</Tran_Date>
<Tran_Time>12:02</Tran_Time>
<Auth_CD>024641</Auth_CD>
<Ref_Num>00889 </Ref_Num>
<Inv_Num></Inv_Num>
<Auth_Amt>$35.00</Auth_Amt>
<Tran_Descr>-Sale</Tran_Descr>
</Trans>
<Trans></Trans>
<Trans></Trans>
<Trans></Trans>
</Row>
</RowSet>


I want to select only the first child elements of the Row.
that is <MID></MID>
<MCC></MCC>
<Merch_Name></Merch_Name>
<Merch_City></Merch_City>
<Merch_Zip></Merch_Zip>
<Merch_State></Merch_State>
<RunDate></RunDate>
<Bank></Bank>
<Rpt_ID></Rpt_ID>
<Rpt_Start_Date></Rpt_Start_Date>
<Rpt_End_Date></Rpt_End_Date>
<Rpt_Title></Rpt_Title>
i dont want to hardcode but i want to fetch if the values of the first child. Does any of you have the solution for this.

i greatly appreciate for the help.

thanks in advance
 
Marshal
Posts: 28235
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was the example you gave supposed to be what you want as output? Because it isn't anything like the description you gave. The first element children of your Row elements are just

<Trans></Trans>
<MID>3896025600000513</MID>

I don't know how to describe your example at all. You don't seem to want Trans elements. And you seem to want the elements you do want to have no text children. So, sorry, I don't get it. Could you try a different explanation?
 
kiran kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,
The final output that i want is

Row/mid,row/mcc, row/merchantname, .. row/trans1/pos_entry, row/trans/tran_amt,...

Row/mid,row/mcc, row/merchantname, .. row/trans2/pos_entry, row/trans2/tran_amt,...

We have 1 row and say 10 trans
i want row, tran1
row trans2
row trans3
row transn
hope i am clear this time.
 
Paul Clapham
Marshal
Posts: 28235
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kranti Aella:
hope i am clear this time.

No. You just provide an incomplete list of elements you want. (At least I think you want the elements, it's not clear.) They look arbitrary to me. There is no way to guess what "..." means.

Okay, let's pick an element at random.

<Tran_Date>02/24/2006</Tran_Date>

Do you want to write this element to the output? If so, why? If not, why not? And do you want just the start and end tags, or do you want the text content as well, or just the text content?
 
kiran kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul thanks for your intrest to help me.
I could finally achieve the ouput what i wanted. I wanted to retreive all the text of "for each ROW element print the text of all childs of "ROW" and text of elements of Trans[0]"

Row
-child
-child
-child
-Trans1
- Tchild11
-Tchild 12
-Trans2
-Trans21
-Trans22

i wanted output like
child child child Tchild11 Tchild12
child child child Tchild21 Tchild22

onceagin i really appreciate you for your intrest to help.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic