REXML question

T

Tim Hunter

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?
 
J

James Britt

Tim said:
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/tutorial.html

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top