You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Mike Kellstrand <ke...@yahoo.com> on 2004/06/03 16:37:41 UTC
Dimension math, i.e. width="{$x+10}"
I need to layout some blocks and SVG's using dimensions
based on input values. I can easily use the original input values,
i.e. width="{$x}", but I also need to do some calculations.
For instance, if I want a box around my SVG, I need to either
draw it in the SVG at 1px smaller or use a block-container at 1px larger.
I've tried some examples I've found online (like width="{$x+10}" ),
but FOP doesn't like it.
What is the correct syntax for doing this type of thing?
Thanks, Mike
---------------------------------
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger
RE: Dimension math, i.e. width="{$x+10}"
Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Mike Kellstrand [mailto:kellstrand@yahoo.com]
Hi Mike,
> A very interesting discussion.
>
> I tried the latest suggestion:
> height="{concat($height,'+10px')}"
>
> and got an error:
> [ERROR] svg graphic could not be built: null:-1
> The attribute 'height' of the element <rect> is invalid
> org.apache.batik.bridge.BridgeException: null:-1
> The attribute 'height' of the element <rect> is invalid
>
> I guess it doesn't want to add numbers with units ....
Nope. FOP still does, but, since it's defined in an attribute of an embedded
SVG rect element, passes the unresolved expression to Batik, which doesn't
know what to do with it...
Greetz,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: Dimension math, i.e. width="{$x+10}"
Posted by Mike Kellstrand <ke...@yahoo.com>.
Hi,
A very interesting discussion.
I tried the latest suggestion:
height="{concat($height,'+10px')}"
and got an error:
[ERROR] svg graphic could not be built: null:-1
The attribute 'height' of the element <rect> is invalid
org.apache.batik.bridge.BridgeException: null:-1
The attribute 'height' of the element <rect> is invalid
I guess it doesn't want to add numbers with units ....
Thanks, Mike
"Andreas L. Delmelle" <a_...@pandora.be> wrote:
> -----Original Message-----
> From: Mike Kellstrand [mailto:kellstrand@yahoo.com]
Hi,
>
> Not to nit-pick, but for posterity, the syntax I ended up with is:
>
> width="{concat(substring($width,1,string-length($width)-2)+10,'px')}"
>
> If anyone else wants to chime it with any of the subtler details of this
stuff,
> feel free to educate me further.
Well, Clay was right (and IIC, I'm the one who corrected Clay in the thread
he remembered) and the problem is actually that it's Xalan (or any other
XSLT processor for that matter) that can't add numbers to strings...
You may want try:
width="{concat($width,'+10px')}"
In this way, the value of the width property that FOP gets to see is, for
example:
width="1px+10px"
in which case FOP should have no problem with it. Right now you're trimming
the measurement units and have Xalan do the calculation, and FOP gets to see
for example:
width="11px"
which comes down to the same thing, of course, but wouldn't be usable if the
'10px' were to be an expression in itself rather than a literal value.
HTH!
Greetz,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
---------------------------------
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger
RE: Dimension math, i.e. width="{$x+10}"
Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Mike Kellstrand [mailto:kellstrand@yahoo.com]
Hi,
>
> Not to nit-pick, but for posterity, the syntax I ended up with is:
>
> width="{concat(substring($width,1,string-length($width)-2)+10,'px')}"
>
> If anyone else wants to chime it with any of the subtler details of this
stuff,
> feel free to educate me further.
Well, Clay was right (and IIC, I'm the one who corrected Clay in the thread
he remembered) and the problem is actually that it's Xalan (or any other
XSLT processor for that matter) that can't add numbers to strings...
You may want try:
width="{concat($width,'+10px')}"
In this way, the value of the width property that FOP gets to see is, for
example:
width="1px+10px"
in which case FOP should have no problem with it. Right now you're trimming
the measurement units and have Xalan do the calculation, and FOP gets to see
for example:
width="11px"
which comes down to the same thing, of course, but wouldn't be usable if the
'10px' were to be an expression in itself rather than a literal value.
HTH!
Greetz,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Dimension math, i.e. width="{$x+10}"
Posted by Mike Kellstrand <ke...@yahoo.com>.
Clay,
Thanks a lot, that did the trick for me.
Not to nit-pick, but for posterity, the syntax I ended up with is:
width="{concat(substring($width,1,string-length($width)-2)+10,'px')}"
If anyone else wants to chime it with any of the subtler details of this stuff,
feel free to educate me further.
Thanks Clay,
Mike
Clay Leeds <cl...@medata.com> wrote:
On Jun 3, 2004, at 7:37 AM, Mike Kellstrand wrote:
> I need to layout some blocks and SVG's using dimensions
> based on input values. I can easily use the original input values,
> i.e. width="{$x}", but I also need to do some calculations.
>
> For instance, if I want a box around my SVG, I need to either
> draw it in the SVG at 1px smaller or use a block-container at 1px
> larger.
>
> I've tried some examples I've found online (like width="{$x+10}" ),
> but FOP doesn't like it.
>
> What is the correct syntax for doing this type of thing?
>
> Thanks, Mike
I *think* the problem is that $x probably is equivalent to '1px' which
is a string of the characters '1'+'p'+'x' and there may be difficulties
with adding a number to a string. There is a recent discussion on this
in the archives, where someone provided some insight into how I was not
completely correct on that assumption with one aspect of XSL-FO (I
don't recall exactly which at the moment) however, that discussion may
not be appropriate for SVG calculation (I don't know).
What should be possible, is for you to modify your system to strip the
'px' for the purposes of the calculation with something like:
width="{concat(substring($x,length()-2)+10,'px')}"
I *hope* that'll do the trick, but you should see where I'm trying to
go with it...
Hope this helps!
Web Maestro Clay
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
---------------------------------
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger
Re: Dimension math, i.e. width="{$x+10}"
Posted by Clay Leeds <cl...@medata.com>.
On Jun 3, 2004, at 7:37 AM, Mike Kellstrand wrote:
> I need to layout some blocks and SVG's using dimensions
> based on input values. I can easily use the original input values,
> i.e. width="{$x}", but I also need to do some calculations.
>
> For instance, if I want a box around my SVG, I need to either
> draw it in the SVG at 1px smaller or use a block-container at 1px
> larger.
>
> I've tried some examples I've found online (like width="{$x+10}" ),
> but FOP doesn't like it.
>
> What is the correct syntax for doing this type of thing?
>
> Thanks, Mike
I *think* the problem is that $x probably is equivalent to '1px' which
is a string of the characters '1'+'p'+'x' and there may be difficulties
with adding a number to a string. There is a recent discussion on this
in the archives, where someone provided some insight into how I was not
completely correct on that assumption with one aspect of XSL-FO (I
don't recall exactly which at the moment) however, that discussion may
not be appropriate for SVG calculation (I don't know).
What should be possible, is for you to modify your system to strip the
'px' for the purposes of the calculation with something like:
width="{concat(substring($x,length()-2)+10,'px')}"
I *hope* that'll do the trick, but you should see where I'm trying to
go with it...
Hope this helps!
Web Maestro Clay
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org