|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Can't Obtain Results
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








