You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christian Barth <ch...@buerobarth.de> on 2006/01/10 14:39:53 UTC

Why doesn't this XSL work??

Hi!


I wrote the following XSL-File:
 
...
<xsl:for-each
select="//Bs_Bauteil_Liste/Brandwand_Liste/Brandwand[funktion='Trennwand']">
<xsl:variable name="ID" select="@ID" />
<xsl:variable name="bez" select="bezeichnung" />
<xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
<xsl:for-each
select="//Gebaeude[@ID=$gebId]/Stockwerk_Liste/Stockwerk[@ID=$stock_ID]//bau
teil_id">
<xsl:if test=". = $wand_ID">
nTrennwand=nNodeIdx;
nNodeIdx++;
Note(nTrennwand,nTrennwaende,'<xsl:value-of
select="$bez"/>','javascript:select(\'wand\', 
	\'Trennwand\',<xsl:value-of select="$ID"/>,<xsl:value-of
select="$stock_ID"/>)','wand')
<xsl:sort select="." order="ascending" data-type="text"/>
<xsl:for-each
select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
...

It's just a part of the file. But the rest is working. My Problem is the
<xsl:if>. Is there anything wrong with it? It's always true.
When I write <xsl:value-of select="." /> and <xsl:value-of select="$wand_ID"
/>, the values are correct. I don't understand this.

Another problem is that when I remove the <xsl:sort>-Tag I get an "Unable to
get transformer handler"-error.
I thought the sort-Tag is optional, isn't it?

Greets,
Barthi


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: AW: Why doesn't this XSL work??

Posted by Geert Josten <Ge...@daidalos.nl>.
Your for-each loops all start with //, which mean that descendants are searched for through the 
entire document for each iteration in each loop. This is not only slow, but most likely explains 
your duplicates.

Make the expressions relative by removing the // and adding some sub-path if necessary, or by adding 
a period in front of the //, e.g. './/etc'.

Cheers

Christian Barth wrote:

> Ok, thanks. I got a step further. I mean, I get a result and no error. 
> 
> 
>>-----Ursprüngliche Nachricht-----
>>Von: Geert Josten [mailto:Geert.Josten@daidalos.nl] 
>>Gesendet: Dienstag, 10. Januar 2006 16:02
>>An: users@cocoon.apache.org
>>Betreff: Re: AW: Why doesn't this XSL work??
>>
>> > 	<xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
>>
>>Are you sure this expression results only one wand_id?
> 
> 
> This one returns several wand_ids, but I only want to test one of these.
> Isn't this correct this way?
> 
> 
>>>		<xsl:if test="generate-id(.) = generate-id($wand_ID)">
>>
>>You could use: string(.) = string($wand_ID) to be clearer. 
>>This also takes the first wand_id element from the $want_ID variable..
>>
>> > 			<xsl:sort select="." order="ascending"
>> > data-type="text"/>
>>
>>Put the sort just below the xsl:for-each open tag. I think 
>>this error is masking other ones.
>>
>>
>>>			<xsl:for-each
>>>select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
>>
>>Variable names are case sensitive: use $wand_ID instead of $wand_id.
> 
> 
> Ok, I didn't see this one.
> 
>>Cheers,
>>Geert
>>
> 
> 
> The problem now is, that I see the resulting "Trennwand" three times instead
> of one time. Mysterious! Maybe a problem with the DB. Or can you find
> another mistake?
> 
> 
> Barthi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: AW: Why doesn't this XSL work??

Posted by Christian Barth <ch...@buerobarth.de>.
Ok, thanks. I got a step further. I mean, I get a result and no error. 

> -----Ursprüngliche Nachricht-----
> Von: Geert Josten [mailto:Geert.Josten@daidalos.nl] 
> Gesendet: Dienstag, 10. Januar 2006 16:02
> An: users@cocoon.apache.org
> Betreff: Re: AW: Why doesn't this XSL work??
> 
>  > 	<xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
> 
> Are you sure this expression results only one wand_id?

This one returns several wand_ids, but I only want to test one of these.
Isn't this correct this way?

> 
> > 		<xsl:if test="generate-id(.) = generate-id($wand_ID)">
> 
> You could use: string(.) = string($wand_ID) to be clearer. 
> This also takes the first wand_id element from the $want_ID variable..
> 
>  > 			<xsl:sort select="." order="ascending"
>  > data-type="text"/>
> 
> Put the sort just below the xsl:for-each open tag. I think 
> this error is masking other ones.
> 
> > 			<xsl:for-each
> > select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
> 
> Variable names are case sensitive: use $wand_ID instead of $wand_id.

Ok, I didn't see this one.
> 
> Cheers,
> Geert
> 

The problem now is, that I see the resulting "Trennwand" three times instead
of one time. Mysterious! Maybe a problem with the DB. Or can you find
another mistake?


Barthi
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: Why doesn't this XSL work??

Posted by Geert Josten <Ge...@daidalos.nl>.
 > 	<xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>

Are you sure this expression results only one wand_id?

> 		<xsl:if test="generate-id(.) = generate-id($wand_ID)">

You could use: string(.) = string($wand_ID) to be clearer. This also takes the first wand_id element 
from the $want_ID variable..

 > 			<xsl:sort select="." order="ascending"
 > data-type="text"/>

Put the sort just below the xsl:for-each open tag. I think this error is masking other ones.

> 			<xsl:for-each
> select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">

Variable names are case sensitive: use $wand_ID instead of $wand_id.

Cheers,
Geert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: Why doesn't this XSL work??

Posted by Christian Barth <ch...@buerobarth.de>.
> -----Ursprüngliche Nachricht-----
> Von: Sylvain Wallez [mailto:sylvain@apache.org] 
> Gesendet: Dienstag, 10. Januar 2006 15:08
> An: users@cocoon.apache.org
> Betreff: Re: Why doesn't this XSL work??
> 
> Christian Barth wrote:
> > Hi!
> >
> >
> > I wrote the following XSL-File:
> >  
> > ...
> > <xsl:for-each
> > 
> select="//Bs_Bauteil_Liste/Brandwand_Liste/Brandwand[funktion='Trennwa
> > nd']"> <xsl:variable name="ID" select="@ID" /> <xsl:variable 
> > name="bez" select="bezeichnung" /> <xsl:variable name="wand_ID" 
> > select="Wand_id_Liste/wand_id"/> <xsl:for-each 
> > 
> select="//Gebaeude[@ID=$gebId]/Stockwerk_Liste/Stockwerk[@ID=$stock_ID
> > ]//bau
> > teil_id">
> > <xsl:if test=". = $wand_ID">
> > nTrennwand=nNodeIdx;
> > nNodeIdx++;
> > Note(nTrennwand,nTrennwaende,'<xsl:value-of
> > select="$bez"/>','javascript:select(\'wand\', 
> > 	\'Trennwand\',<xsl:value-of select="$ID"/>,<xsl:value-of
> > select="$stock_ID"/>)','wand')
> > <xsl:sort select="." order="ascending" data-type="text"/> 
> > <xsl:for-each 
> > select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
> > ...
> >
> > It's just a part of the file. But the rest is working. My 
> Problem is 
> > the <xsl:if>. Is there anything wrong with it? It's always true.
> > When I write <xsl:value-of select="." /> and <xsl:value-of 
> select="$wand_ID"
> > />, the values are correct. I don't understand this.
> >   
> 
> This because this tests compares the string values of 
> elements. So if they happen to have the same content or be 
> both empty, the test will be true. If you want to test these 
> are the same nodes, you can use
>   <xsl:if test="generate-id(.) = generate-id($wand_ID)">
> 

I want to compare the string values. So the test should be correct, right?


> > Another problem is that when I remove the <xsl:sort>-Tag I get an 
> > "Unable to get transformer handler"-error.
> > I thought the sort-Tag is optional, isn't it?
> >   
> 
> Yep. Now I can't see a closing <xsl:if tag>. Is it somewhere 
> down the XSL?
> 

Here is the complete for-each-code:

<xsl:for-each
select="//Bs_Bauteil_Liste/Brandwand_Liste/Brandwand[funktion='Trennwand']">
	<xsl:variable name="ID" select="@ID" />
	<xsl:variable name="bez" select="bezeichnung" />
	<xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
	<xsl:for-each
select="//Gebaeude[@ID=$gebId]/Stockwerk_Liste/Stockwerk[@ID=$stock_ID]//bau
teil_id">
		<xsl:if test="generate-id(.) = generate-id($wand_ID)">
			nTrennwand=nNodeIdx;
			nNodeIdx++;
			Note(nTrennwand,nTrennwaende,'<xsl:value-of
select="$bez"/>','javascript:select(\'wand\', 
				\'Trennwand\',<xsl:value-of
select="$ID"/>,<xsl:value-of select="$stock_ID"/>)','wand')
			<xsl:sort select="." order="ascending"
data-type="text"/>
			<xsl:for-each
select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
				<xsl:if test="Tuer">
					nNodeIdx++;
					nOeffnung=nNodeIdx;
					Note(nOeffnung,nTrennwand,'Tuer
','javascript:select(\'oeffnung\', 
						\'Tuer\',<xsl:value-of
select="@ID"/>)','tuer')
					nNodeIdx++;
				</xsl:if>
				<xsl:if test="Fenster">
					nNodeIdx++;
					nOeffnung=nNodeIdx;
					Note(nOeffnung,nTrennwand,'Fenster
','javascript:select(\'oeffnung\', 
						\'Fenster\',<xsl:value-of
select="@ID"/>)','fenster')
					nNodeIdx++;
				</xsl:if>
			</xsl:for-each>
		</xsl:if>	
	</xsl:for-each>
</xsl:for-each>


I hope this helps. This is the working code. When I remove the sort-tag I
get the error I mensioned before


Barthi


> Sylvain
> 
> -- 
> Sylvain Wallez                        Anyware Technologies
> http://bluxte.net                     http://www.anyware-tech.com
> Apache Software Foundation Member     Research & Technology Director
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Why doesn't this XSL work??

Posted by Sylvain Wallez <sy...@apache.org>.
Christian Barth wrote:
> Hi!
>
>
> I wrote the following XSL-File:
>  
> ...
> <xsl:for-each
> select="//Bs_Bauteil_Liste/Brandwand_Liste/Brandwand[funktion='Trennwand']">
> <xsl:variable name="ID" select="@ID" />
> <xsl:variable name="bez" select="bezeichnung" />
> <xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
> <xsl:for-each
> select="//Gebaeude[@ID=$gebId]/Stockwerk_Liste/Stockwerk[@ID=$stock_ID]//bau
> teil_id">
> <xsl:if test=". = $wand_ID">
> nTrennwand=nNodeIdx;
> nNodeIdx++;
> Note(nTrennwand,nTrennwaende,'<xsl:value-of
> select="$bez"/>','javascript:select(\'wand\', 
> 	\'Trennwand\',<xsl:value-of select="$ID"/>,<xsl:value-of
> select="$stock_ID"/>)','wand')
> <xsl:sort select="." order="ascending" data-type="text"/>
> <xsl:for-each
> select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
> ...
>
> It's just a part of the file. But the rest is working. My Problem is the
> <xsl:if>. Is there anything wrong with it? It's always true.
> When I write <xsl:value-of select="." /> and <xsl:value-of select="$wand_ID"
> />, the values are correct. I don't understand this.
>   

This because this tests compares the string values of elements. So if 
they happen to have the same content or be both empty, the test will be 
true. If you want to test these are the same nodes, you can use
  <xsl:if test="generate-id(.) = generate-id($wand_ID)">

> Another problem is that when I remove the <xsl:sort>-Tag I get an "Unable to
> get transformer handler"-error.
> I thought the sort-Tag is optional, isn't it?
>   

Yep. Now I can't see a closing <xsl:if tag>. Is it somewhere down the XSL?

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://bluxte.net                     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Why doesn't this XSL work??

Posted by Irv Salisbury <ir...@gmail.com>.
There is something wrong here.  When I look at your code, it is hard to
figure out because there are no ending tags for your for-each statements.
So, it is hard to know if you are in a nested for-each or not.  Also, the
xsl:sort only works when it is the first child of an apply-templates or
for-each.  Your xsl:sort is in a place that should give an error.  Did you
just type in this snippet, or is this really what your file looks like?  If
you can resend with appropriate end tags, etc it would be easier to figure
out.

Irv

On 1/10/06, Christian Barth <ch...@buerobarth.de> wrote:
>
> Hi!
>
>
> I wrote the following XSL-File:
>
> ...
> <xsl:for-each
>
> select="//Bs_Bauteil_Liste/Brandwand_Liste/Brandwand[funktion='Trennwand']">
> <xsl:variable name="ID" select="@ID" />
> <xsl:variable name="bez" select="bezeichnung" />
> <xsl:variable name="wand_ID" select="Wand_id_Liste/wand_id"/>
> <xsl:for-each
>
> select="//Gebaeude[@ID=$gebId]/Stockwerk_Liste/Stockwerk[@ID=$stock_ID]//bau
> teil_id">
> <xsl:if test=". = $wand_ID">
> nTrennwand=nNodeIdx;
> nNodeIdx++;
> Note(nTrennwand,nTrennwaende,'<xsl:value-of
> select="$bez"/>','javascript:select(\'wand\',
>         \'Trennwand\',<xsl:value-of select="$ID"/>,<xsl:value-of
> select="$stock_ID"/>)','wand')
> <xsl:sort select="." order="ascending" data-type="text"/>
> <xsl:for-each
> select="//Bauteil[@ID=$wand_id]/Wand/Oeffnungs_Liste/Oeffnung">
> ...
>
> It's just a part of the file. But the rest is working. My Problem is the
> <xsl:if>. Is there anything wrong with it? It's always true.
> When I write <xsl:value-of select="." /> and <xsl:value-of
> select="$wand_ID"
> />, the values are correct. I don't understand this.
>
> Another problem is that when I remove the <xsl:sort>-Tag I get an "Unable
> to
> get transformer handler"-error.
> I thought the sort-Tag is optional, isn't it?
>
> Greets,
> Barthi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>