Subject: Re: [xsl] Param Element From: Karl Stubsjoen <kstubs@xxxxxxxxx> Date: Thu, 2 Jun 2005 17:39:32 -0700 |
> I'm still a little confused on the parm(s) but no worries! How do you select the root element of a parm and guarantee that it is not the root element of the source? > is equivalent (but slower, probably) to > <xsl:copy-of select="row"/> Thanks for the tip here! > is equivalent (but slower, probably) to > <xsl:copy-of select="row"/> And here! > <xsl:if test="$current_id = $activity_id"> > this test is always true (given the default value of $xm) as $current_id > is an attribute node from the set $activity_id > Even if you supply an xm parameter so that the tests may be false, This is working properly, where activity_id is a RTF of existing activity id's. I did not understand your reason for this to not work / as you put it, "this test is always true". It is working, I hope this is common practice, I do this kind of checks all the time. For example: from an xml source that I use as a lookup, I query for a specific value of "colors", lets say... then check current color to make sure that the current color exists in this list. The xpath (or is this xslt statement) might look like.. <xsl:if test="@current_color = $list_of_valid_colors"/> Michael: the content of the source xml is the persisted state of the supplied xm data param. xm data param may or may not contain new data. This data is appended to the xml source when it is new. There is an id column named "activityid" which allows me a guarantee of unique matches. On 6/2/05, David Carlisle <davidc@xxxxxxxxx> wrote: > > It is working... > > This seems unlikely. > > I'm still a little confused on the parm(s) but no worries! > > On 6/2/05, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote: > > Here is what I have, but not confident that it is working... it seems > > that my check for uniqueness is failing, I get no results. Isn't it a > > fair test to ask of a value it it exists in a set of values as I am > > here: > > <xsl:if test="$current_id = $activity_id"> > > Where activity_id is a set of ID values as defined below.. > > > > <xsl:param name="xm" select="in_proc" /> > > > > <xsl:variable name="activity_id" select="in_proc/row/@id"/> > > > > <xsl:template match="/"> > > <in_proc> > > <xsl:apply-templates select="row"/> > > <xsl:apply-templates select="$xm/row" mode="append"/> > > </in_proc> > > </xsl:template> > > > > <xsl:template match="row"> > > <xsl:copy-of select="."/> > > </xsl:template> > > > > <xsl:template match="row" mode="append"> > > <xsl:variable name="current_id" select="@id"/> > > <xsl:if test="$current_id = $activity_id"> > > <xsl:copy-of select="."/> > > </xsl:if> > > </xsl:template> > > > > </xsl:stylesheet> > > > > > > > <xsl:apply-templates select="row"/> > <xsl:template match="row"> > <xsl:copy-of select="."/> > </xsl:template> > > is equivalent (but slower, probably) to > <xsl:copy-of select="row"/> > it just copies all the row elements. In this case however it prduces > nothing as there are no row element children of the current node (the > only child of / is a in_proc element (I guess, you have not shown your > input format) > > <xsl:if test="$current_id = $activity_id"> > this test is always true (given the default value of $xm) as $current_id > is an attribute node from the set $activity_id > Even if you supply an xm parameter so that the tests may be false, > > <xsl:apply-templates select="$xm/row" mode="append"/> > <xsl:template match="row" mode="append"> > <xsl:variable name="current_id" select="@id"/> > <xsl:if test="$current_id = $activity_id"> > <xsl:copy-of select="."/> > </xsl:if> > </xsl:template> > > is equivalent to > > <xsl:copy-of select="$xm/row[@id = $activity_id]"/> > > David > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Param Element, David Carlisle | Thread | RE: [xsl] Param Element, Michael Kay |
RFC: [xsl] Recursive Template Impro, Bovy, Stephen J | Date | Re: [xsl] Recursive Template ??, Mukul Gandhi |
Month |