469,364 Members | 2,332 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

XSLT: Copy-of with condition

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

Feb 23 '07 #1
3 2296
Aargh I forgot to translate the most important lines :\. Please have a
look again

On 23 Feb., 08:13, adu...@cs.tu-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
Feb 23 '07 #2
In article <11**********************@j27g2000cwj.googlegroups .com>,
<ad****@cs.tu-berlin.dewrote:
><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.
Feb 23 '07 #3
On 23 Feb., 22:54, rich...@cogsci.ed.ac.uk (Richard Tobin) wrote:
In article <1172216011.870605.203...@j27g2000cwj.googlegroups .com>,

<adu...@cs.tu-berlin.dewrote:
<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!

Feb 26 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Christian Roth | last post: by
reply views Thread by Manoj Nair | last post: by
3 posts views Thread by Peter Kirk | last post: by
6 posts views Thread by naima.mans | last post: by
8 posts views Thread by Hercules Dev. | last post: by
2 posts views Thread by olivier.scalbert | last post: by
3 posts views Thread by Andy Dingley | last post: by
1 post views Thread by Karsten | last post: by
6 posts views Thread by kluge.wolfram | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.