xml-xsl transformation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sgxbytes
    New Member
    • Sep 2008
    • 25

    xml-xsl transformation

    Hi,
    xml:..........
    [code=xml]
    <catalog>
    <cd>
    <title def="2" >Empire1 </title>
    <title def="2" >Empire2 </title>
    <title def="2" >Empire3 </title>
    <title def="2">
    <run>raj1</run>
    </title>
    <title def="2">
    <run>raj2</run>
    </title>
    <title def="2">
    <run>raj3</run>
    </title>
    </cd>
    </catalog>
    [/code]
    when i require to select the values which are inside run tag alone i used this xsl statement to get the output
    [code=xml]<xsl:for-each select="catalog/cd/title[@def='2']">
    <xsl:value-of select="./run"/>
    </xsl:for-each>[/code]

    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(normaliz e-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..
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    If you want the text of <title> without the text of the <run> inside, use the text() node test:
    Code:
    <xsl:for-each select="catalog/cd/title[@def='2']">
      <xsl:value-of select="text()"/>
    </xsl:for-each>
    regards

    PS: please use [code] tags when posting code

    Comment

    Working...