This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Can't Obtain Results
- From: "Lindy Quick" <lindyq at iwon dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 2 May 2002 15:20:41 -0400 (EDT)
- Subject: RE: [xsl] Can't Obtain Results
- Reply-to: xsl-list at lists dot mulberrytech dot com
This is a repost to my previous messages. I have had to replace the greater than sign with the # sign so it can be sent through this mail client. Also I have added an example of the code I have been trying to use. Thanks in advance
Hello,
Here's my the situation:
I have an XML or tree the looks like this:
#root>
#keyset>
#f1>some text#/f1>
#f2>some text#/f2>
#f3>some text#/f3>
#f6>some text#/f6>
#/keyset>
#keyset outlet="cb">
#f2>SOMETEXT#/f2>
#f3>SOMETEXT#/f3>
#f4>SOMETEXT#/f4>
#f5>SOMETEXT#/f5>
#/keyset>
#/root>
I am passing in a parameter called outlet
If the outlet parameter is "cb" - after transformation I want it to look like this:
#root>
#keyset>
#f1>some text#/f1>
#f2>SOMETEXT#/f2>
#f3>SOMETEXT#/f3>
#f4> SOMETEXT#/f4>
#f5> SOMETEXT#/f5>
#f6>some text#/f6>
#/keyset>
#/root>
If the outlet parameter is "default" - after transformation I want it to look like this:
#root >
#keyset >
#f1>some text#/f1>
#f2>some text#/f2>
#f3>some text#/f3>
#f6>some text#/f6>
#/keyset>
#/root>
I have tried several different approches with for-each statements etc, but have been unable to achieve my results. This is my
most recent attempt and I get close, but I can't figure out how to determine if I have already found a match.
#xsl:template match="/">
#xsl:param name="outlet">cb#/xsl:param>
#xsl:variable name="k1" select="/root/keyset[@outlet=$outlet]/*"/>
#xsl:for-each select="/root/keyset[@outlet='default']/*">
#xsl:variable name="dflt" select="."/>
#xsl:for-each select="$k1">
#xsl:choose>
#xsl:when test="name($dflt)= name(.)">
#xsl:copy-of select="."/>
#/xsl:when>
#xsl:when test="not(name(@dflt)=name(.)) and position()=last()">
#xsl:copy-of select="$dflt"/>
#/xsl:when>
#/xsl:choose>
#/xsl:for-each>
#/xsl:for-each>
#/xsl:template>
Thanks
Lindy
------------------------------------------------
Visit iWon.com - the Internet's largest guaranteed cash giveaway!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list