XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 29th, 2003, 04:26 AM
Nikky Nikky is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 Nikky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML To TXT help!

Hello I'm new to xml and xsl and I need some help. I have xml file like this
<?xml version="1.0" encoding="UTF-8"?>
<OPIT>
<SYNSET>
<ID>ENG171-01534425-n</ID>
<POS>n</POS>
<SYNONYM>
<LITERAL>kkkkkkk<SENSE>1</SENSE>
</LITERAL>
<LITERAL>hhhhhhhh<SENSE>1</SENSE>
</LITERAL>
<LITERAL>lllllllll<SENSE>1</SENSE>
</LITERAL>
</SYNONYM>
<LNOTE>ENG171-01150487-n<ILR>hypernym</ILR>
</LNOTE>
<TYPE>kjhggsgsgsggs</TYPE>
<RILR>DCMB TEAM 2003/05/23</RILR>
<BCS>1</BCS>
</SYNSET>
<SYNSET>
.......
</SYNSET>

I have to extract to .txt file information for ID(tab)LITERAL(without <sense>)tab LITERAL...

ID LITERAL LITERAL LITERAL ...(new line)
ID .......
for all SYNSETs
Please if anyone can help me. Tanx a lot!

Reply With Quote
  #2  
Old July 29th, 2003, 09:40 AM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
Where's your xsl?
__________________
mr...

mike.rusaw@realpage.com
RalPage, Inc.

"I have made this letter longer than usual, only because I have not had the time to make it shorter." - Blaise Paschal

Reply With Quote
  #3  
Old July 29th, 2003, 01:00 PM
mulligh mulligh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 19 mulligh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="//SYNSET">
<xsl:value-of select="ID"/><xsl:text>& #9;</xsl:text>
<xsl:for-each select="SYNONYM/LITERAL">
<xsl:value-of select="text() |* [not(self::SENSE)]"/>
<xsl:text>& #9;</xsl:text>
</xsl:for-each>
<xsl:text>& #13;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Remove the space between & and # for the 3 entities in the above code.

Last edited by mulligh : July 29th, 2003 at 01:08 PM.

Reply With Quote
  #4  
Old July 29th, 2003, 02:17 PM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
Here is my solution for you. (**I couldn't get it to work witho your existing xml data structure.) I hope this helps. (**Remember to remove the space in & #9; / & #13;)

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
<xsl:output method="text"/> 
<xsl:template match="/"> 
	<xsl:for-each select="//SYNSET"> 
		<xsl:value-of select="ID"/><xsl:text>& #9;</xsl:text>
			<xsl:for-each select="SYNONYM/LITERAL"> 
				<xsl:value-of select="concat(text(), '& #9;')"/>
			</xsl:for-each> 
		<xsl:text>& #13;</xsl:text> 
	</xsl:for-each> 
</xsl:template> 
</xsl:stylesheet> 


Code:
<?xml version="1.0" encoding="UTF-8"?>
<OPIT> 
<SYNSET> 
	<ID>ENG171-01534425-n</ID> 
	<POS>n</POS> 
	<SYNONYM> 
		<LITERAL SENSE="1">kkkkkkk</LITERAL> 
		<LITERAL SENSE="1">hhhhhhhh</LITERAL> 
		<LITERAL SENSE="1">lllllllll</LITERAL> 
	</SYNONYM> 
	<LNOTE>ENG171-01150487-n
		<ILR>hypernym</ILR>
	</LNOTE> 
	<TYPE>kjhggsgsgsggs</TYPE> 
	<RILR>DCMB TEAM 2003/05/23</RILR> 
	<BCS>1</BCS> 
</SYNSET>
<SYNSET> 
	<ID>ENG171-01534425-n1</ID> 
	<POS>n1</POS> 
	<SYNONYM> 
		<LITERAL SENSE="2">kkkkkkk1</LITERAL> 
		<LITERAL SENSE="2">hhhhhhhh1</LITERAL> 
		<LITERAL SENSE="2">lllllllll1</LITERAL> 
	</SYNONYM> 
	<LNOTE>ENG171-01150487-n1
		<ILR>hypernym1</ILR>
	</LNOTE> 
	<TYPE>kjhggsgsgsggs1</TYPE> 
	<RILR>DCMB TEAM 2003/05/231</RILR> 
	<BCS>1</BCS> 
</SYNSET>
<SYNSET> 
	<ID>ENG171-01534425-n2</ID> 
	<POS>n2</POS> 
	<SYNONYM> 
		<LITERAL SENSE="3">kkkkkkk2</LITERAL> 
		<LITERAL SENSE="3">hhhhhhhh2</LITERAL> 
		<LITERAL SENSE="3">lllllllll2</LITERAL> 
	</SYNONYM> 
	<LNOTE>ENG171-01150487-n2
		<ILR>hypernym2</ILR>
	</LNOTE> 
	<TYPE>kjhggsgsgsggs2</TYPE> 
	<RILR>DCMB TEAM 2003/05/232</RILR> 
	<BCS>2</BCS> 
</SYNSET>
</OPIT>

Last edited by mrusaw : July 29th, 2003 at 02:25 PM.

Reply With Quote
  #5  
Old July 30th, 2003, 03:09 AM
Nikky Nikky is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 Nikky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Tanx guys!

Tanx mrusaw, tanx mulligh they are both work.

Reply With Quote
  #6  
Old July 30th, 2003, 03:17 AM
Nikky Nikky is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 Nikky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Tanx guys!

Tanx mrusaw, tanx mulligh they are both work.

Reply With Quote
  #7  
Old July 30th, 2003, 09:15 AM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
mulligh - i was wondering if you have a reference for the character strings (ie. '& #9;'). I have been looking for one for a while.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML To TXT help!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway