Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 2nd, 2008, 10:39 AM
Newbie
 
Join Date: Sep 2008
Posts: 18
Default xml-xsl transformation

Hi,
xml:..........
Expand|Select|Wrap|Line Numbers
  1. <catalog>
  2.     <cd>
  3.         <title def="2" >Empire1 </title>
  4.         <title def="2" >Empire2 </title>
  5.         <title def="2" >Empire3 </title>
  6.         <title def="2">
  7.             <run>raj1</run>
  8.         </title>
  9.         <title def="2">
  10.             <run>raj2</run>
  11.         </title>
  12.         <title def="2">
  13.             <run>raj3</run>
  14.         </title>
  15.     </cd>
  16. </catalog>
  17.  
when i require to select the values which are inside run tag alone i used this xsl statement to get the output
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="catalog/cd/title[@def='2']">
  2. <xsl:value-of select="./run"/>
  3. </xsl:for-each>
the below one gives me all the values which are in <title def="2" > tags along with the values of child tag run

<xsl:for-each select="catalog/cd/title[@def='2']">
<xsl:value-of select="."/>
</xsl:for-each>

how can i get the values from <title def="2" > tag ommiting the run tag.

i hav used the conditions like

<xsl:if test="string-length(normalize-space(catalog/cd/title[@def='2']/run)) &gt; 0">

to show the values under run tag alone..

but how to get the values other than run tag....

Thanks
Raj..
Reply
  #2  
Old October 2nd, 2008, 11:21 AM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 673
Default

If you want the text of <title> without the text of the <run> inside, use the text() node test:
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="catalog/cd/title[@def='2']">
  2.   <xsl:value-of select="text()"/>
  3. </xsl:for-each>
regards

PS: please use [code] tags when posting code
Reply
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles