REXML question

Discussion in 'Ruby' started by Tim Hunter, Jan 9, 2005.

  1. Tim Hunter

    Tim Hunter Guest

    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?
     
    Tim Hunter, Jan 9, 2005
    #1
    1. Advertising

  2. Tim Hunter

    James Britt Guest

    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/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
     
    James Britt, Jan 9, 2005
    #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. Damphyr
    Replies:
    2
    Views:
    147
    Damphyr
    Jul 16, 2003
  2. Ralph Mason
    Replies:
    2
    Views:
    98
    Ralph Mason
    Jan 13, 2004
  3. Han Holl

    Rexml xpath question

    Han Holl, Feb 22, 2004, in forum: Ruby
    Replies:
    7
    Views:
    148
    Han Holl
    Mar 6, 2004
  4. Daniel Berger

    rexml error - REXML::Validation

    Daniel Berger, Oct 12, 2004, in forum: Ruby
    Replies:
    2
    Views:
    157
    Henrik Horneber
    Oct 12, 2004
  5. Phlip
    Replies:
    0
    Views:
    148
    Phlip
    Jan 15, 2008
Loading...

Share This Page