Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Node Grouping Node GroupingTo: NULL Date: 6/3/2004 11:35:00 AM Thanks again for all the help. If you don't mind, I would like to ask
another question ...
I'm having trouble with two of the same 'ProductsItem' nodes being passed in
the parameter group of two separate template calls. For example, lets say
we set our count variable to 3. Looking at the same sample XML below, the
XSL is written to pass any 'ProductsItem' nodes in the ("Bar") parameter
where the Identifier/Type='ECCN Nbr' or Identifier/Type='PO Nbr'. Because
the first 'ProductsItem' node contains only a count of 2 child 'Identifier'
nodes that meet this criteria, the second 'ProductsItem' node is also passed
in the parameter of the first call-template instruction because it has an
Identifier node with a Type='ECCN Nbr' or Type='PO Nbr' in a position less
than 3. Now I have two 'ProductsItem' nodes being passed in the parameter
of my first template call with a total of 4 child 'Identifier' nodes that
meet my criteria. This is too many. I only want three. If when passing an
additional 'ProductsItem' node exceeds the count of 3 maximum 'Identifier'
nodes per template call, I want to omit that additional 'ProductsItem' node
until the next call-template is executed. In the case described above, I
would have only wanted the first 'ProductsItem' node to be passed in the
parameter because including the second 'ProductsItem' node will pass too
many 'Identifier' nodes.
Thanks again in advance for all of your help ... I really appreciate your
time!
Ben
"Yan Leshinsky" <yanl@o...> wrote in message
news:OGjVSXDSEHA.2876@T......
> If you want X to differ from execution to execution you shoud define it as
a
> parameter inside of stylesheet:
> <xsl:param name="count" select="3"/>
> 3 would be a default value of it.
> Code is almost the same:
> <xsl:for-each
> select="/Products/ProductsItem/Identifiers/Identifier[position() mod
$count
> = 1]">
> <xsl:call-template name="Foo">
> <xsl:with-param name="Bar" select="(.|following::Identifier[$count
>
> position()])/../.."/>
> </xsl:call-template>
> </xsl:for-each>
>
> If you want to have additional conditions you should put these additional
> predicates after Identifier:
> <xsl:for-each
> select=/Products/ProductsItem/Identifiers/Identifier[Type='ECCN Nbr' or
> Type='PO Nbr'][position() mod $count = 1]">
> <xsl:call-template name="Foo">
> <xsl:with-param name="Bar"
> select="(.|following::Identifier[Type='ECCN Nbr' or Type='PO Nbr'][$count
>
> position()])/../.."/>
> </xsl:call-template>
> </xsl:for-each>
>
> "Ben Schumacher" <bschumacher@i...> wrote in message
> news:OtMX3FCSEHA.2000@T......
> > Thanks for the reply! If you don't mind, I have another question ...
> >
> > Here is the exact XML structure that I am working with ...
> >
> > <Products>
> > <ProductsItem>
> > <Product>
> > <PacketData>
> > <Product>
> > <ProductNbr>1</ProductNbr>
> > <Description>1 Description</Description>
> > </Product>
> > </PacketData>
> > </Product>
> > <Identifiers>
> > <PacketData>
> > <Identifiers>
> > <Identifier>
> > <Type>ECCN Nbr</Type>
> > <Value>ECCN-1</Value>
> > </Identifier>
> > <Identifier>
> > <Type>PO Nbr</Type>
> > <Value>PO-1</Value>
> > </Identifier>
> > <Identifier>
> > <Type>SE Nbr</Type>
> > <Value>SE-1</Value>
> > </Identifier>
> > </Identifiers>
> > </PacketData>
> > </Identifiers>
> > </ProductsItem>
> > <ProductsItem>
> > <Product>
> > <PacketData>
> > <Product>
> > <ProductNbr>2</ProductNbr>
> > <Description>2 Description</Description>
> > </Product>
> > </PacketData>
> > </Product>
> > <Identifiers>
> > <PacketData>
> > <Identifiers>
> > <Identifier>
> > <Type>ECCN Nbr</Type>
> > <Value>ECCN-2</Value>
> > </Identifier>
> > <Identifier>
> > <Type>PO Nbr</Type>
> > <Value>PO-2</Value>
> > </Identifier>
> > </Identifiers>
> > </PacketData>
> > </Identifiers>
> > </ProductsItem>
> > </Products>
> >
> > Because this is only a snippet of the actual XML structure, please keep
in
> > mind that there can be many more repeating 'ProductsItem' nodes along
with
> > many more repeating child 'Identifier' nodes under each 'ProductsItem'
> > node.
> >
> > I'm wodering how I can call a template that passes a group of
> > 'ProductsItem'
> > nodes as a parameter. The group of 'ProductsItem' nodes being passed as
a
> > parameter cannot have a count of child 'Identifier' nodes exceeding X.
> > For
> > example, if the count that cannot be exceed is equal to 3, I want the
> > first
> > template call to pass the first 'ProductsItem' node as the parameter
group
> > (this is because the first 'ProductsItem' node has 3 child 'Identifier'
> > nodes. Because I cannot exceed a maximum 3 Identifier nodes per each
> > call-template instruction, I would still only want to pass the first
> > 'ProductsItem' node if the count of its child 'Identifier' nodes was
only
> > 2.
> > Passing both 'ProductsItem' nodes would exceed a maximum count of 3
> > Identifiers per call-template instruction.). Then, on the second
template
> > call the parameter would contain the second 'ProductsItem' node with two
> > remaining child 'Identifier' nodes. Another example would be to set the
> > maximum number of 'Identifier' nodes per template call to say 10. In
this
> > case, my first and only template call would pass both 'ProductsItem'
node
> > becuase the combined count of the 'Identifier' nodes is only 5.
> >
> > I guess what I'm having trouble using the code snippet you provided
above
> > because I don't know how to pass the first few 'ProductsItem' nodes in
one
> > template call. Then, pick up where that last template call left off
> > passing
> > the next few 'ProductsItem' nodes as a parameter. Also, it would be
nice
> > to
> > qualify the count of 'Identifier' nodes by their corresponding child
> > 'Type'
> > node value. For example, I only want to include in my count
> > Identifier[Type='ECCN Nbr' or Type='PO Nbr'].
> >
> > Thanks so much in advance for any help you can give me ... I'm
definetly
> > having some trouble here.
> >
> > Ben
> >
> >
> >
> > "Yan Leshinsky" <yanl@o...> wrote in message
> > news:uy%23FlMaREHA.132@T......
> >> <xsl:for-each
> >> select="/Products/ProductsItem/Identifiers/Identifier[position() mod 3
=
> >> 1]">
> >> <xsl:call-template name="Foo">
> >> <xsl:with-param name="Bar" select="(.|following::Identifier[3 >
> >> position()])/../.."/>
> >> </xsl:call-template>
> >> </xsl:for-each>
> >>
> >> "Ben Schumacher" <bschumacher@i...> wrote in message
> >> news:umi2jwOREHA.3348@T......
> >> > Looking at the XML below ...
> >> >
> >> > <Products>
> >> > <ProductsItem>
> >> > <Identifiers>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>12345</Value>
> >> > </Identifier>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>54321</Value>
> >> > </Identifier>
> >> > </Identifiers>
> >> > </ProductsItem>
> >> > <ProductsItem>
> >> > <Identifiers>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>13245</Value>
> >> > </Identifier>
> >> > </Identifiers>
> >> > </ProductsItem>
> >> > <ProductsItem>
> >> > <Identifiers>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>13245</Value>
> >> > </Identifier>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>14235</Value>
> >> > </Identifier>
> >> > <Identifier>
> >> > <Type>ECCN Nbr</Type>
> >> > <Value>15234</Value>
> >> > </Identifier>
> >> > </Identifiers>
> >> > </ProductsItem>
> >> > </Products>
> >> >
> >> > I'm trying to call a template and pass a parameter equal to a group
of
> >> > ProductsItem nodes where the count of the combined Identifier child
> > nodes
> >> > under each ProductsItem node exceeds no more than a count of three.
> >> > For
> >> > example, the first matching template call would contain a parameter
> >> > holding
> >> > the first two ProductsItem nodes because the combined count of the
> >> > Identifier nodes under these two ProductsItem nodes equals three.
The
> >> > next
> >> > call would contain the third positioned (and only the third
positioned)
> >> > ProductsItem node because that ProductsItem node also has a count of
> > three
> >> > child Identifier nodes. Hope this makes sense ... Any help is
greatly
> >> > appreciated!
> >> >
> >> > Ben
> >> >
> >> >
> >>
> >>
> >
> >
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
