Subject: Re: [xsl] single display of double elements but how to use generate-id From: Heiko Specht <heiko@xxxxxxxxxx> Date: Fri, 20 Dec 2002 11:41:40 +0100 |
Hello all, if have found a solution of my problem in my own script. the solution was to create a new variable (see the commend) and than to generate-id of the variable node-set how easy it could be. but another question: where to find a good tutorial about node, nodeset and this parent:: self:: ancestor:: and so on i need to understand this stuff. a long time ago there was a good xsl tutorial downloadable at mullberry. TIA Heiko <xsl:text>var listC = new DynamicOptionList("C","A","B");</xsl:text> <xsl:for-each select="xalan:nodeset($smallversion)/vers"> <xsl:variable name="thisname" select="."/> <xsl:variable name="systemsForEach"> <xsl:for-each select="$articles[contains(articleName, $thisname)]"> <xsl:variable name="envname" select="articleenv/name"/> <sofar> <xsl:text>listC.addOptions(</xsl:text> <xsl:text>"</xsl:text> <xsl:value-of select="$thisname"/>|<xsl:value-of select="$envname"/> <xsl:text>"</xsl:text> <!-- at this point i need to display each language only once so i declare a variable of all languages and create a nodesset --> <xsl:variable name="langall"> <xsl:for-each select="$articles[contains(articleName, $thisname)]"> <xsl:if test="contains(articleenv/name,$envname)"> <langs><xsl:text>,"</xsl:text><xsl:value-of select="articlelanguage/name"/><xsl:text>","</xsl:text><xsl:value-of select="articlelanguage/shortname"/><xsl:text>"</xsl:text></langs> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:for-each select="xalan:nodeset($langall)/langs"> <xsl:if test="generate-id(.) = generate-id(xalan:nodeset($langall)/langs[.=current()])"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> <!-- end language display --> <xsl:text>);</xsl:text> </sofar> </xsl:for-each> </xsl:variable> <xsl:variable name="newnode" select="xalan:nodeset($systemsForEach)/sofar"/> <xsl:for-each select="$newnode"> <xsl:if test="generate-id(.) = generate-id($newnode[.=current()])"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:for-each> Thursday, December 19, 2002, 5:02:15 PM, you wrote: HS> Hello XSL-List Members, HS> while you all discuss strange (for me) things about verse extractions HS> i hope my question is trivial for you. HS> what i want to do is a javascript extract like this: HS> ------------------------------------------ HS> var listB = new DynamicOptionList("B","A"); HS> listB.addOptions("PM2Q 6","Mac","Mac"); HS> listB.addOptions("PageMaker 7.0","Windows","Windows","Mac","Mac"); HS> listB.setDefaultOption("PM2Q 6","Mac"); HS> listB.setDefaultOption("PageMaker 7.0","Mac"); HS> ------------------------------------------ HS> done with this xsl (works): HS> ------------------------------------------ HS> <xsl:text>var listB = new DynamicOptionList("B","A");</xsl:text> HS> <xsl:for-each select="xalan:nodeset($smallversion)/vers"> HS> <xsl:text>listB.addOptions("</xsl:text> HS> <xsl:value-of select="." /><xsl:text>"</xsl:text> HS> <xsl:variable name="thisname" select="."/> HS> <xsl:variable name="systemsForEach"> HS> <xsl:for-each select="$articles[contains(articleName, $thisname)]"> HS> <sfffe><xsl:text>,"</xsl:text><xsl:value-of select="articleenv/name"/>","<xsl:value-of select="articleenv/name"/><xsl:text>"</xsl:text></sfffe> HS> </xsl:for-each> HS> </xsl:variable> HS> <xsl:variable name="newnode" select="xalan:nodeset($systemsForEach)/sfffe"/> HS> <xsl:for-each select="$newnode"> HS> <xsl:if test="generate-id(.) = generate-id($newnode[.=current()])"> HS> <xsl:value-of select="."/> HS> </xsl:if> HS> </xsl:for-each> HS> <xsl:text>);</xsl:text> HS> </xsl:for-each> HS> <xsl:for-each select="xalan:nodeset($smallversion)/vers"> HS> <xsl:text>listB.setDefaultOption("</xsl:text> HS> <xsl:value-of select="." /> HS> <xsl:text>",</xsl:text> HS> <xsl:for-each select="xalan:nodeset($smallsys)/sys"> HS> <xsl:if test="position()='1'"> HS> <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text> HS> </xsl:if> HS> </xsl:for-each> HS> <xsl:text>);</xsl:text> HS> </xsl:for-each> HS> ---------------------------------------- HS> but the next part drives me crazy. HS> the output should be like this without doubles of languages: HS> ---------------------------------------- HS> var listC = new DynamicOptionList("C","A","B"); HS> listC.addOptions("PM2Q 6|Mac","english/anglais","EN"); HS> listC.addOptions("PageMaker 7.0|Windows","german/allemand","DE","german/allemand","DE","english/anglais","EN"); HS> listC.addOptions("PageMaker 7.0|Mac","german/allemand","DE","german/allemand","DE"); HS> ^firstselect ^secondselect ^option ^value HS> ----------------------------------------- HS> what should the script do: when someone choose an option in a select HS> box the othe box should be filled automatically with new options HS> without reloading. (the jscript works fine allready) HS> but as you can see, the languages are displayed twice. HS> here is the piece of xsl that makes the stuff: HS> i have marked the criteric point with an command. HS> any one got an idea ? HS> at the bottom you can find the the xml i work with ! HS> ------------------------------------------ HS> <xsl:text>var listC = new DynamicOptionList("C","A","B");</xsl:text> HS> <xsl:for-each select="xalan:nodeset($smallversion)/vers"> HS> <xsl:variable name="thisname" select="."/> HS> <xsl:variable name="systemsForEach"> HS> <xsl:for-each select="$articles[contains(articleName, $thisname)]"> HS> <xsl:variable name="envname" select="articleenv/name"/> HS> <sofar> HS> <xsl:text>listC.addOptions(</xsl:text> HS> <xsl:text>"</xsl:text> HS> <xsl:value-of select="$thisname"/>|<xsl:value-of select="$envname"/> HS> <xsl:text>"</xsl:text> HS> <xsl:for-each select="$articles[contains(articleName, $thisname)]"> HS> <xsl:if test="contains(articleenv/name,$envname)"> HS> <!-- at this point i need to display each language only once --> HS> <xsl:text>,"</xsl:text><xsl:value-of select="articlelanguage/name"/><xsl:text>","</xsl:text><xsl:value-of HS> select="articlelanguage/shortname"/><xsl:text>"</xsl:text> HS> <!-- end language display --> HS> </xsl:if> HS> </xsl:for-each> HS> <xsl:text>);</xsl:text> HS> </sofar> HS> </xsl:for-each> HS> </xsl:variable> HS> <xsl:variable name="newnode" select="xalan:nodeset($systemsForEach)/sofar"/> HS> <xsl:for-each select="$newnode"> HS> <xsl:if test="generate-id(.) = generate-id($newnode[.=current()])"> HS> <xsl:value-of select="."/> HS> </xsl:if> HS> </xsl:for-each> HS> </xsl:for-each> -- Best regards, Heiko mailto:heiko@xxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] single display of double elem, Heiko Specht | Thread | Re: [xsl] single display of double , Mike Brown |
Re: [xsl] Testing the name of paren, David Carlisle | Date | Re: [xsl] Yet Another Entity Ref qu, Marco Guazzone |
Month |