xsl for a given xml

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

    #1

    xsl for a given xml

    Hi,

    XML:


    <richtext xmlns:sgx="http ://www.lotus.com/dxl">
    <pardef id="2" leftmargin="1in " rightmargin="10 0%" keeptogether="t rue" />
    <par def="2">Name of director : Chan Siew Key Steven</par>
    <par def="2" />
    <par def="2">Date of notice to company : 23 September 1997</par>
    <par def="2" />
    <par def="2">Date of change of shareholding : 21 August 1997</par>
    <par def="2" />
    <par def="2">Name of registered holder : Chan Siew Key Steven</par>
    <par def="2" />
    <par def="2">Circums tance given rise to the change : Share option granted.</par>
    <par def="2" />
    <par def="2">No. of options of the change : 40,000</par>

    </richtext>


    xsl one :

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

    xsl two:

    <xsl:for-each select="par[@def='2']">
    <xsl:value-of select="par[@def='2']"></xsl:value-of>
    <br />
    </xsl:for-each>

    whats the difference between these two xsl's..
    why xsl two doesnt give any out put ..i mean same like xsl one.


    Thanks in advance..
    Raj
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by sgxbytes
    why xsl two doesnt give any out put ..i mean same like xsl one.
    actually, no. both are different. in the first xsl you access the same node as defined in the loop ( . = self::node() ), whereas in the second xsl you access the <par> (value-of) that is a child of <par> (for-each), only that there is no such node, ergo no value (the <xsl:value-of> is looking for "par[@def='2']/par[@def='2']" so to speak)

    regards

    Comment

    Working...