XSLT: Copy-of with condition

Discussion in 'XML' started by adurth@cs.tu-berlin.de, Feb 23, 2007.

  1. -berlin.de

    -berlin.de Guest

    Hi!
    I am working on a xml->xml transformation. The source-file contains
    the following entities:

    <ef:Test>
    ....
    ....
    <ef:ID>1234</ef:ID>
    </ef:Test>
    <ef:errorReference>
    ....
    ....
    <ef:reference_test>1234</ef:referemce_test>
    </ef:errorReference>
    <ef:errorReference>
    ....
    ....
    <ef:reference_test>2345</ef:reference_test>
    </ef:errorReference>

    My transformation is supposed to filter for every single test those
    corresponding errorReferences, that have a <ef:reference_test>-value
    matching the <ef:ID>-value of the current test.
    So I´ve been trying...

    <xsl:template match="/">
    ....
    ....
    <xsl:apply-templates select="ef:Test"/>
    </xsl:template match>

    <xsl:template match="ef:Test">
    <xsl:variable name="testID" select="ef:ID"/>
    <!--xsl:copy-of select="..//ef:Fehlerzuordnung[Referenz_Test =
    ef:ID]"/-->
    <xsl:copy-of select="..//ef:Fehlerzuordnung[Referenz_Test =
    $testID]"/>
    </xsl:template>

    Both alternatives WON´T work. Neither the one commented out, nor the
    one currently in place. I suppose the path or the variable is no
    longer valid in that call, respectively.
    So far I haven´t come up with a solution, can somebody help me?

    Thank you,
    Andreas
    -berlin.de, Feb 23, 2007
    #1
    1. Advertising

  2. -berlin.de

    -berlin.de Guest

    Aargh I forgot to translate the most important lines :\. Please have a
    look again

    On 23 Feb., 08:13, -berlin.de wrote:
    > Hi!
    > I am working on a xml->xml transformation. The source-file contains
    > the following entities:
    >
    > <ef:Test>
    > ...
    > ...
    > <ef:ID>1234</ef:ID>
    > </ef:Test>
    > <ef:errorReference>
    > ...
    > ...
    > <ef:reference_test>1234</ef:referemce_test>
    > </ef:errorReference>
    > <ef:errorReference>
    > ...
    > ...
    > <ef:reference_test>2345</ef:reference_test>
    > </ef:errorReference>
    >
    > My transformation is supposed to filter for every single test those
    > corresponding errorReferences, that have a <ef:reference_test>-value
    > matching the <ef:ID>-value of the current test.
    > So I´ve been trying...
    >
    > <xsl:template match="/">
    > ...
    > ...
    > <xsl:apply-templates select="ef:Test"/>
    > </xsl:template match>
    >
    > <xsl:template match="ef:Test">
    > <xsl:variable name="testID" select="ef:ID"/>
    > <!--xsl:copy-of select="..//ef:errorReference[reference_test =
    > ef:ID]"/-->
    > <xsl:copy-of select="..//ef:errorReference[reference_test =
    > $testID]"/>
    > </xsl:template>
    >
    > Both alternatives WON´T work. Neither the one commented out, nor the
    > one currently in place. I suppose the path or the variable is no
    > longer valid in that call, respectively.
    > So far I haven´t come up with a solution, can somebody help me?
    >
    > Thank you,
    > Andreas
    -berlin.de, Feb 23, 2007
    #2
    1. Advertising

  3. In article <>,
    <-berlin.de> wrote:

    >> <ef:errorReference>
    >> ...
    >> ...
    >> <ef:reference_test>1234</ef:referemce_test>
    >> </ef:errorReference>


    >> <xsl:copy-of select="..//ef:errorReference[reference_test =
    >> $testID]"/>


    You forgot the prefix. That should be [ef:reference_test = $testID]

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, Feb 23, 2007
    #3
  4. -berlin.de

    -berlin.de Guest

    On 23 Feb., 22:54, (Richard Tobin) wrote:
    > In article <>,
    >
    > <-berlin.de> wrote:
    > >> <ef:errorReference>
    > >> ...
    > >> ...
    > >> <ef:reference_test>1234</ef:referemce_test>
    > >> </ef:errorReference>
    > >> <xsl:copy-of select="..//ef:errorReference[reference_test =
    > >> $testID]"/>

    >
    > You forgot the prefix. That should be [ef:reference_test = $testID]
    >
    > -- Richard
    > --
    > "Consideration shall be given to the need for as many as 32 characters
    > in some alphabets" - X3.4, 1963.



    Yes you are absolutely right. Finally I got aware of it too and
    knocked down the wall with my head... Thank you never the less!
    -berlin.de, Feb 26, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -
    Replies:
    12
    Views:
    687
    Remon van Vliet
    Jun 15, 2005
  2. Martin Honnen
    Replies:
    1
    Views:
    1,408
    Andy Fish
    Aug 4, 2003
  3. Alex
    Replies:
    2
    Views:
    1,218
  4. Replies:
    26
    Views:
    2,107
    Roland Pibinger
    Sep 1, 2006
  5. Bill W.
    Replies:
    13
    Views:
    289
    Phillip Gawlowski
    May 9, 2011
Loading...

Share This Page