[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

REXML question

Tim Hunter

1/9/2005 3:23:00 PM

I'm working on a program that uses REXML to parse SVG. One of the test
programs declares this entity:

<!ENTITY shape " <path d='M60,0 l60,0 l60,60 l0,60 l-60,60 l-60,0
l-60,-60 l0,-60 z'/>">
]>

Then later it refers to the entity like this:

<g fill="yellow" stroke="red" stroke-width="8" >&shape;</g>

How do I get REXML to replace &shape; with its value and then parse it?

1 Answer

James Britt

1/9/2005 5:09:00 PM

0

Tim Hunter wrote:
> I'm working on a program that uses REXML to parse SVG. One of the test
> programs declares this entity:
>
> <!ENTITY shape " <path d='M60,0 l60,0 l60,60 l0,60 l-60,60 l-60,0
> l-60,-60 l0,-60 z'/>">
> ]>
>
> Then later it refers to the entity like this:
>
> <g fill="yellow" stroke="red" stroke-width="8" >&shape;</g>
>
> How do I get REXML to replace &shape; with its value and then parse it?

The tutorial
http://www.germane-software.com/software/rexml/docs/tut...

suggests that REXML does replace internal entity references, but that
they are "unreplaced" when you go fetch the document content as a whole.

You can get the expanded text if you explicitly ask for a node's text
value, but (it seems) asking for the entire document string gives back
the unexpanded version.

Take a look at the tutorial, because REXML's behavior with regard to
entities is probably not what you expect. For example, simply reading a
text value may alter your source document if a node being read contains
text that matches the value of an internal entity. (Though this
tutorial description does not match the actual behavior of some short
code I wrote to see this in action, so the tutorial may be out of date,
or my code is buggy.)


James