Refactoring hard-coded values

Discussion in 'XML' started by Aidan Gauland, Jun 29, 2011.

  1. I'm playing around with scripting SVG with ECMAScript, and I have
    reached the point where my document is full of hard-coded (attribute)
    values. There are three values to which most other values are relative.
    (In this case, there are a bunch of shapes positioned with respect to a
    specific circle.) Even after wading through the SVG specification
    <http://www.w3.org/TR/SVG/>, I am at a loss as to how to refactor my XML
    code. I basically want to say, "you, rectangle, your origin is the
    top-left corner of this circle's bounding-box." But I also have a
    circle in a <clipPath> who's cx and cy values are those of another
    circle *plus* that other circle's stroke width. And to make it even
    trickier, the target circle is within a symbol within the document's
    <defs> element. It's all just a bit crazy.

    It seems that being able to, within an attribute's value,
    refer to the value of another entity's attribute would be the cleanest
    way to tidy up my document. But XML does not allow for this, does it?

    Can anyone offer any advice on how to keep XML (SVG in particular) tidy
    in this manner, and avoid hard-coding values?

    Regards,
    Aidan Gauland
    Aidan Gauland, Jun 29, 2011
    #1
    1. Advertising

  2. On 6/29/2011 7:15 AM, Aidan Gauland wrote:
    > It seems that being able to, within an attribute's value,
    > refer to the value of another entity's attribute would be the cleanest
    > way to tidy up my document. But XML does not allow for this, does it?


    XML is just notation. If anything gives you the ability to do this, it
    would be the specific XML-based language, that being SVG.... or a tool
    you pass the document through. (You could probably write an XSLT
    stylesheet to help resolve this sort of thing, but that's a special case
    of writing an XML processing program.)

    At a purely instinctual level... It sounds like what you need to do is
    step back and redefine the document more hierarchically -- as layers of
    containment -- rather than the current entangled crossreferences.


    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
    Joe Kesselman, Jun 30, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    1
    Views:
    517
    Curt_C [MVP]
    Jan 6, 2005
  2. Luke Airig
    Replies:
    1
    Views:
    580
    Dimitre Novatchev
    Dec 24, 2003
  3. rodchar
    Replies:
    2
    Views:
    354
    rodchar
    Jul 1, 2008
  4. Microsoft

    How to avoid accessing row values with hard coded index

    Microsoft, Sep 24, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    150
    Perecli Manole
    Oct 3, 2003
  5. Kevin
    Replies:
    1
    Views:
    108
    Evertjan.
    Oct 22, 2005
Loading...

Share This Page