re: help on xslt

Discussion in 'XML' started by timothy ma and constance lee, Oct 21, 2004.

  1. Sir

    Sorry to bother you once again
    The message structure change with <Resp>......</resp>
    And I make the modification as below but i cannot display the drop list box
    with number
    It look like the length cannot be got

    I simple add message/docList/docSet in for each case
    and try by error using docList/totPage or simply totPage but i cannot
    generate the drop box with index
    any idea?


    <?xml version="1.0"?>
    > <xsl:stylesheet
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > version="1.0">
    >
    > <xsl:eek:utput method="html" indent="yes"/>
    >
    > <xsl:key name="by-docSet" match="docSet" use="."/>
    >
    > <xsl:template match="/Resp">
    > <html>
    > <head>
    > <title/>
    > </head>
    > <body>
    > <table>
    > <xsl:for-each select="/message/docList/docSet[generate-id(.) =
    > generate-id(key('by-docSet', .)[1])]">
    > <tr>
    > <td>
    > DocSet
    > </td>
    > <td>
    > <xsl:value-of select="."/>
    > </td>
    > </tr>
    > <xsl:for-each select="key('by-docSet', .)">
    > <tr>
    > <td>
    > Document type
    > </td>
    > <td>
    > <xsl:value-of
    > select="following-sibling::docTp[1]"/>
    > <select name="{following-sibling::docTp[1]}"
    > onchange="url">
    > <!-- calling a template to generate <option> tags > -->
    > <xsl:call-template name="generateDropdown">
    > <xsl:with-param name="length"
    > select="following-sibling::totPage[1]" />
    > </xsl:call-template>
    > </select>
    > </td>
    > </tr>
    > </xsl:for-each>
    > </xsl:for-each>
    > </table>
    > </body>
    > </html>
    > </xsl:template>
    >
    > <!-- a recursive template to generate <option> tags > -->
    > <xsl:template name="generateDropdown">
    > <xsl:param name="length" />
    >
    > <xsl:if test="$length &gt; 0">
    > <option value="{$length}"><xsl:value-of
    > select="$length" /></option>
    > <xsl:call-template name="generateDropdown">
    > <xsl:with-param name="length" select="$length -
    > 1"/>
    > </xsl:call-template>
    > </xsl:if>
    > </xsl:template>
    >
    > </xsl:stylesheet>



    <Resp>
    <message>
    <docList>
    <docSet>1</docSet>
    <docTp>A1</docTp>
    <totPage>5</totPage>
    <docID>A111</docID>
    </docList>
    <docList>
    <docSet>1</docSet>
    <docTp>B1</docTp>
    <docID>B111</docID>
    <totPage>4</totPage>
    </docList>
    <docList>
    <docSet>2</docSet>
    <docTp>A2</docTp>
    <totPage>6</totPage>
    <docID>A2111</docID>
    </docList>
    <docList>
    <docSet>1</docSet>
    <docTp>C1</docTp>
    <totPage>7</totPage><
    <docID>C111</docID>
    </doclist>
    <docList>
    <docSet>2</docSet>
    <docTp>B2</docTp>
    <totPage>8</totPage>
    <docID>B2111</docID>
    </docList>
    </message>
    <Resp>

    Is there any idea to generatre like
    >>
    >> DocSet 1
    >> Document type = A1 drop down list with length =
    >> totPage (5), onchange to
    >> redirect url: http://.....param?docID docTp
    >> Document Type = B1 drop down list with length =
    >> totPage (4), onchange to
    >> redirect url: http://.....param?docID+docTp>>
    >> Document Type = C1 drop down list with length =
    >> totPage (7), onchange to
    >> redirect url: http://.....param?docID+docTp>>
    >>
    >> docSet 2
    >> Document Type = B2 drop down list with length =
    >> totPage (8), onchange to
    >> redirect url: http://.....param?docID+docTp>>
    >>

    Also, is it possoble to generate the drop down
    >> box

    beside the doc type? The
    size is from totPage no tag?
    >> >>

    I confuse on how to generate xslt. Can you give
    >> me

    some tips how to write
    the good xslt by steps




    Timothy Ma
    timothy ma and constance lee, Oct 21, 2004
    #1
    1. Advertising

  2. timothy ma and constance lee

    Joris Gillis Guest

    > I simple add message/docList/docSet in for each case
    > and try by error using docList/totPage or simply totPage but i cannot
    > generate the drop box with index
    > any idea?
    >


    Try this:

    <?xml version="1.0" ?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:eek:utput method="html" indent="yes"/>

    <xsl:key name="by-docSet" match="docSet" use="."/>

    <xsl:template match="Resp">
    <html>
    <head>
    <title/>
    </head>
    <body>
    <xsl:for-each select="message/docList/docSet[generate-id(.) =
    generate-id(key('by-docSet', .))]">
    <h1>
    DocSet <xsl:value-of select="."/>
    </h1>
    <xsl:for-each select="key('by-docSet', .)">
    <p>
    Document type
    <xsl:value-of select="following-sibling::docTp[1]"/>
    <select name="{following-sibling::docTp[1]}"
    OnChange="location.href='http://www.yoursite.org/param?{following-sibling::docID[1]}+{following-sibling::docTp[1]}'">
    <!-- calling a template to generate <option> tags > -->
    <xsl:call-template name="generateDropdown">
    <xsl:with-param name="length"
    select="following-sibling::totPage[1]" />
    </xsl:call-template>
    </select>
    </p>
    </xsl:for-each>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>

    <!-- a recursive template to generate <option> tags > -->
    <xsl:template name="generateDropdown">
    <xsl:param name="length" />
    <xsl:param name="count" select="$length +1"/>
    <xsl:if test="$length &gt; 0">
    <option value="{$count - $length}"><xsl:value-of
    select="$count - $length" /></option>
    <xsl:call-template name="generateDropdown">
    <xsl:with-param name="length" select="$length -
    1"/>
    <xsl:with-param name="count" select="$count"/>
    </xsl:call-template>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

    regards,

    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Ceterum censeo XML omnibus esse utendum
    Joris Gillis, Oct 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    661
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,681
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    623
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    719
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    4
    Views:
    672
Loading...

Share This Page