[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT/SVG variables question

Subject: Re: XSLT/SVG variables question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 1 Jul 2002 10:11:55 +0100
svg variable
Hi Harry,

> As the block chart is built, I need to account for arbitrary number
> of strings per block and number of blocks. "Normal" variables would
> let me compute and increment SVG coordinates for the rectangles and
> text. But XSLT variables aren't normal!
>
> If you have any suggestions about how I should track the
> coordinates, or better yet an example, that would be helpful.

There are two ways of working that might help here.

The first is to express the algorithm by which you decide where the
blocks should be and how large they should be in terms of the
information that you have about the other blocks. For example, if you
know that each block is 100 units across and 100 units from the
preceding block, then you can work out the location of this block by
counting the number of preceding blocks and multiplying by 200 units.

The trouble is that this method often leads to you revisiting nodes
and recalculating things like widths and heights for all the preceding
blocks for any particular block, and that's not very efficient when
you have lots of blocks to arrange.

The alternative, then, is to control the order of processing of the
blocks and use parameters to keep track of the things that you would
otherwise hold within variables. For example, you could have a
template like:

<xsl:template name="layout">
  <xsl:param name="blocks" select="BlockA | BlockB" />
  <xsl:param name="x" select="0" />
  <xsl:param name="y" select="0" />

  <xsl:variable name="block" select="$blocks[1]" />

  ... various layout stuff to create SVG from $block ...

  <xsl:if test="$blocks[2]">
    <xsl:call-template name="layout">
      <xsl:with-param name="blocks" select="$blocks[position() > 1]" />
      <xsl:with-param name="x" select="$newX" />
      <xsl:with-param name="y" select="$newY" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Here, the parameters $x and $y are updated as you work through the
blocks one by one, until there are no blocks left, so you get a more
procedural style of programming.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.