You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2003/06/11 08:43:05 UTC
XSP/Java - simple? problem
Hi
Can someone explain what is wrong with
the following code:
<labels show="true">
<xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
<xsp:logic>
if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
</xsp:logic>
<xsp:attribute name="rotate">14</xsp:attribute>
<xsp:logic>
} else {
</xsp:logic>
<xsp:attribute name="rotate">1</xsp:attribute>
<xsp:logic>
}
</xsp:logic>
Gives an output of:
<labels show="true" label="null" rotate="14" rotate="1">
ie. if the fGraphPtLabel is null, the rotate should be equal to 1
and not 14 as well?!
Thanks
Derek
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSP/Java - simple? problem
Posted by Andreas Hartmann <an...@apache.org>.
Hi Derek,
Derek Hohls wrote:
> Hi
>
> Can someone explain what is wrong with
> the following code:
>
> <labels show="true">
>
> <xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
>
> <xsp:logic>
> if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
> </xsp:logic>
> <xsp:attribute name="rotate">14</xsp:attribute>
> <xsp:logic>
> } else {
> </xsp:logic>
> <xsp:attribute name="rotate">1</xsp:attribute>
> <xsp:logic>
> }
> </xsp:logic>
>
> Gives an output of:
>
> <labels show="true" label="null" rotate="14" rotate="1">
>
> ie. if the fGraphPtLabel is null, the rotate should be equal to 1
> and not 14 as well?!
it seems that your java code is not interpreted as such, and
the if condition is not added to the Java code ...
At a first glance it looks OK - did you take a look at the
generated Java source?
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSP/Java - simple? problem
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Jun.2003 -- 10:27 AM, Christian Haul wrote:
> On 11.Jun.2003 -- 08:43 AM, Derek Hohls wrote:
> > <labels show="true">
> > <xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
> > <xsp:logic>
> > if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
> > <xsp:attribute name="rotate">14</xsp:attribute>
> > } else {
> > <xsp:attribute name="rotate">1</xsp:attribute>
> > }
> > </xsp:logic>
BTW (after looking at your followup including the generated code) you
could change the order to
<labels show="true">
<xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
<xsp:logic>
if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
rotate = "14";
} else {
rotate = "1";
}
</xsp:logic>
<xsp:attribute name="rotate"><xsp:expr>rotate</xsp:expr></xsp:attribute>
I'm afraid that putting the logic into the xsp:attribute tag is not
possible unless it is a java expression like
<labels show="true">
<xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
<xsp:attribute name="rotate"><xsp:expr>(
(fGraphPtLabel != null) &&
(fGraphPtLabel.equals("name")) ? "14" : "1")
</xsp:expr></xsp:attribute>
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSP/Java - simple? problem
Posted by Joerg Heinicke <jo...@gmx.de>.
This is due to a bug:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15841.
In the code
(cocoon-2.1\src\java\org\apache\cocoon\components\language\markup\xsp\java\xsp.xsl):
<xsl:template match="*[not(namespace-uri(.) = 'http://apache.org/xsp')]">
<!-- matching on your label element -->
<xsl:apply-templates select="@*"/>
<!-- catching all xsp:attributes
they are added to xspAttr -->
<xsl:apply-templates select="xsp:attribute |
xsp:logic[xsp:attribute]"/>
<!-- create the element -->
this.contentHandler.startElement(...);
xspAttr.clear();
<!-- catching the rest of the elements -->
<xsl:apply-templates select="node()[not(
(namespace-uri(.) = $xsp-uri and local-name(.) = 'attribute') or
(namespace-uri(.) = $xsp-uri and local-name(.) = 'logic' and
./xsp:attribute)
)]"/>
<!-- end element -->
this.contentHandler.endElement(...);
</xsl:template>
So first templates are applied for all your <xsp:attribute/>s. And
second the rest including <xsp:logic/>. This is of course completely
buggy, but I don't know how to fix it without breaking existing stuff.
The problem is, that you are creating the attributes in XSL and XSP
*after* the element, in SAX you must already have collected them when
the element is created.
Joerg
Christian Haul wrote:
> On 11.Jun.2003 -- 08:43 AM, Derek Hohls wrote:
>
>> <labels show="true">
>> <xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
>> <xsp:logic>
>> if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
>> <xsp:attribute name="rotate">14</xsp:attribute>
>> } else {
>> <xsp:attribute name="rotate">1</xsp:attribute>
>> }
>> </xsp:logic>
>
>
> Can't see a problem here but you might like to know that you could
> save yourself some of the xsp:logic tags.... (see above)
>
> Chris.
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSP/Java - simple? problem
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Jun.2003 -- 08:43 AM, Derek Hohls wrote:
> <labels show="true">
> <xsp:attribute name="label"><xsp:expr>fGraphPtLabel</xsp:expr></xsp:attribute>
> <xsp:logic>
> if ((fGraphPtLabel != null) && (fGraphPtLabel.equals("name"))) {
> <xsp:attribute name="rotate">14</xsp:attribute>
> } else {
> <xsp:attribute name="rotate">1</xsp:attribute>
> }
> </xsp:logic>
Can't see a problem here but you might like to know that you could
save yourself some of the xsp:logic tags.... (see above)
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org