Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > REXML question

Reply
Thread Tools

REXML question

 
 
Tim Hunter
Guest
Posts: n/a
 
      01-09-2005
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?

 
Reply With Quote
 
 
 
 
James Britt
Guest
Posts: n/a
 
      01-09-2005
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/soft.../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


 
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
REXML::Element.write is deprecated. See REXML::Formatters Phlip Ruby 0 01-15-2008 08:23 PM
rexml error - REXML::Validation Daniel Berger Ruby 2 10-12-2004 04:19 PM
Rexml xpath question Han Holl Ruby 7 03-06-2004 01:23 PM
REXML & Extended characters - newbie question Ralph Mason Ruby 2 01-13-2004 12:36 AM
soap4r 1.4.8.1 with REXML 2.7.1 - no REXML::VERSION_MAJOR Damphyr Ruby 2 07-16-2003 09:49 AM



Advertisments