Loading ...
Sorry, an error occurred while loading the content.

Grouping question

Expand Messages
  • friefrench
    To all: I cannot figure out how to get a unique list of notes from the following XML:
    Message 1 of 3 , Jul 14, 2002
    • 0 Attachment
      To all:
      I cannot figure out how to get a unique list of notes from the
      following XML:
      <ProductCatalog>
      <CatalogData>
      <Product SchemaCategoryRef="A11006">
      <Basis_Weight_Type name="Basis 45#">
      <Notes>
      <Note Sequence="10">Basis 45 lb is subject...</Note>
      </Notes>
      </Basis_Weight_Type>
      </Product>

      <Product SchemaCategoryRef="A11012">
      <Basis_Weight_Type name="Basis 45#">
      <Notes>
      <Note Sequence="30">Basis 45 lb is subject...</Note>
      </Notes>
      </Basis_Weight_Type>
      </Product>

      <Product SchemaCategoryRef="A11011">
      <Basis_Weight_Type name="Basis 45#">
      <Notes>
      <Note Sequence="20">Basis 45 lb is subject...</Note>
      </Notes>
      </Basis_Weight_Type>
      <Basis_Weight_Type name="Basis 45#+">
      <Notes>
      <Note Sequence="40">Basis 45 lb+ has no minimum run</Note>
      </Notes>
      </Basis_Weight_Type>
      </Product>
      </CatalogData>
      </ProductCatalog>

      I tried to use the following:
      <xsl:apply-templates select="/ProductCatalog/CatalogData[not
      Product/Basis_Weight_Type/Notes/Note = preceding-
      sibling::CatalogData/Product/Basis_Weight_Type/Notes/Note)]/Product/Ba
      sis_Weight_Type/Notes/Note">
      <xsl:sort select="./@Sequence" data-type="number" />
      </xsl:apply-templates>

      but it doesn't work and I can't seem to find why.

      Could somebody help me?

      Thank you in advance,
      Pascal.
    • Oleg Tkachenko
      ... Actually you can use
      Message 2 of 3 , Jul 15, 2002
      • 0 Attachment
        friefrench wrote:
        > To all:
        > I cannot figure out how to get a unique list of notes from the
        > following XML:
        > <ProductCatalog>
        > <CatalogData>
        > <Product SchemaCategoryRef="A11006">
        > <Basis_Weight_Type name="Basis 45#">
        > <Notes>
        > <Note Sequence="10">Basis 45 lb is subject...</Note>
        > </Notes>
        > </Basis_Weight_Type>
        > </Product>
        >
        > <Product SchemaCategoryRef="A11012">
        > <Basis_Weight_Type name="Basis 45#">
        > <Notes>
        > <Note Sequence="30">Basis 45 lb is subject...</Note>
        > </Notes>
        > </Basis_Weight_Type>
        > </Product>
        >
        > <Product SchemaCategoryRef="A11011">
        > <Basis_Weight_Type name="Basis 45#">
        > <Notes>
        > <Note Sequence="20">Basis 45 lb is subject...</Note>
        > </Notes>
        > </Basis_Weight_Type>
        > <Basis_Weight_Type name="Basis 45#+">
        > <Notes>
        > <Note Sequence="40">Basis 45 lb+ has no minimum run</Note>
        > </Notes>
        > </Basis_Weight_Type>
        > </Product>
        > </CatalogData>
        > </ProductCatalog>
        >
        > I tried to use the following:
        > <xsl:apply-templates select="/ProductCatalog/CatalogData[not
        > Product/Basis_Weight_Type/Notes/Note = preceding-
        > sibling::CatalogData/Product/Basis_Weight_Type/Notes/Note)]/Product/Ba
        > sis_Weight_Type/Notes/Note">
        > <xsl:sort select="./@Sequence" data-type="number" />
        > </xsl:apply-templates>

        Actually you can use
        <xsl:apply-templates
        select="/ProductCatalog/CatalogData/Product/Basis_Weight_Type/Notes/Note[not(
        . = preceding::Note)]">
        <xsl:sort select="@Sequence" data-type="number"/>
        </xsl:apply-templates>

        You can also use Muenchian method (see http://www.jenitennison.com/xslt/grouping):

        <xsl:key name="kNote" match="Note" use="."/>
        <xsl:template match="/">
        <out>
        <xsl:apply-templates
        select="/ProductCatalog/CatalogData/Product/Basis_Weight_Type/Notes/Note[generate-id()
        = generate-id(key('kNote', .)[1])]">
        <xsl:sort select="@Sequence" data-type="number"/>
        </xsl:apply-templates>
        </out>
        </xsl:template>

        --
        Oleg Tkachenko
        Multiconn International, Israel
      • friefrench
        It worked great! Thank you, Pascal. ... sibling::CatalogData/Product/Basis_Weight_Type/Notes/Note)]/Product/Ba ...
        Message 3 of 3 , Jul 17, 2002
        • 0 Attachment
          It worked great!
          Thank you,
          Pascal.

          --- In XSL-FO@y..., Oleg Tkachenko <olegt@m...> wrote:
          > friefrench wrote:
          > > To all:
          > > I cannot figure out how to get a unique list of notes from the
          > > following XML:
          > > <ProductCatalog>
          > > <CatalogData>
          > > <Product SchemaCategoryRef="A11006">
          > > <Basis_Weight_Type name="Basis 45#">
          > > <Notes>
          > > <Note Sequence="10">Basis 45 lb is subject...</Note>
          > > </Notes>
          > > </Basis_Weight_Type>
          > > </Product>
          > >
          > > <Product SchemaCategoryRef="A11012">
          > > <Basis_Weight_Type name="Basis 45#">
          > > <Notes>
          > > <Note Sequence="30">Basis 45 lb is subject...</Note>
          > > </Notes>
          > > </Basis_Weight_Type>
          > > </Product>
          > >
          > > <Product SchemaCategoryRef="A11011">
          > > <Basis_Weight_Type name="Basis 45#">
          > > <Notes>
          > > <Note Sequence="20">Basis 45 lb is subject...</Note>
          > > </Notes>
          > > </Basis_Weight_Type>
          > > <Basis_Weight_Type name="Basis 45#+">
          > > <Notes>
          > > <Note Sequence="40">Basis 45 lb+ has no minimum run</Note>
          > > </Notes>
          > > </Basis_Weight_Type>
          > > </Product>
          > > </CatalogData>
          > > </ProductCatalog>
          > >
          > > I tried to use the following:
          > > <xsl:apply-templates select="/ProductCatalog/CatalogData[not
          > > Product/Basis_Weight_Type/Notes/Note = preceding-
          > >
          sibling::CatalogData/Product/Basis_Weight_Type/Notes/Note)]/Product/Ba
          > > sis_Weight_Type/Notes/Note">
          > > <xsl:sort select="./@Sequence" data-type="number" />
          > > </xsl:apply-templates>
          >
          > Actually you can use
          > <xsl:apply-templates
          >
          select="/ProductCatalog/CatalogData/Product/Basis_Weight_Type/Notes/No
          te[not(
          > . = preceding::Note)]">
          > <xsl:sort select="@Sequence" data-type="number"/>
          > </xsl:apply-templates>
          >
          > You can also use Muenchian method (see
          http://www.jenitennison.com/xslt/grouping):
          >
          > <xsl:key name="kNote" match="Note" use="."/>
          > <xsl:template match="/">
          > <out>
          > <xsl:apply-templates
          >
          select="/ProductCatalog/CatalogData/Product/Basis_Weight_Type/Notes/No
          te[generate-id()
          > = generate-id(key('kNote', .)[1])]">
          > <xsl:sort select="@Sequence" data-
          type="number"/>
          > </xsl:apply-templates>
          > </out>
          > </xsl:template>
          >
          > --
          > Oleg Tkachenko
          > Multiconn International, Israel
        Your message has been successfully submitted and would be delivered to recipients shortly.