RE: [xsl] Param Element

Subject: RE: [xsl] Param Element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 3 Jun 2005 11:56:40 +0100
> Sorry : )
> 
> Structure is:
> 
> <in_proc>
>  <row />
>  <row />
>  ...
> </in_proc>

In that case, this:

<xsl:template match="/">
   <in_proc>
      <xsl:apply-templates select="row"/>

is clearly wrong, because the document node does not have a child called
"row".

Michael Kay
http://www.saxonica.com/


> 
> On 6/2/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > Michael:  the content of the source xml is the persisted 
> state of the
> > > supplied xm data param.
> > 
> > That tells me absolutely nothing about the structure of either.
> > 
> > Let's be concrete. Is the outermost element of your source 
> XML caled <row>
> > or is it called <in_proc>? If it's called <row> then I can 
> point to one set
> > of errors in your stylesheet, if it's called <in_proc> then 
> I can point to a
> > different set. It's possible that your stylesheet is 
> written to allow it to
> > be either, but that seems unlikely.
> > 
> > Michael Kay
> > http://www.saxonica.com/
> > 
> > 
> > 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