XSLT: Copy-of with condition

A

adurth

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
 
R

Richard Tobin

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

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

-- Richard
 
A

adurth

<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


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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,268
Members
46,867
Latest member
Lonny Petersen

Latest Threads

Top