Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Refactoring hard-coded values

Reply
Thread Tools

Refactoring hard-coded values

 
 
Aidan Gauland
Guest
Posts: n/a
 
      06-29-2011
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
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      06-30-2011
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...lam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refactoring a while loop without if .. else - Java 6 05-13-2005 11:29 PM
What does "refactoring" of a project mean ? Anan H. Samiti Java 33 07-30-2004 08:07 PM
Odd Multi-thread behavior when refactoring Christian Bongiorno Java 1 06-22-2004 07:46 AM
Survey on refactoring activities using IDEs Sebastian Jekutsch Java 5 06-09-2004 06:15 AM
come learn all about refactoring Refactorit Java 0 02-22-2004 06:36 PM



Advertisments