yet another feeb attempt to escape quotes in XPaths

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phlip

    yet another feeb attempt to escape quotes in XPaths

    XMLers:

    Try this failing test:

    assert_xml '<html>
    <form class=\'for_"sa le"\' />
    </html>'

    assert_tag_id :form, :class ='for_"sale"'

    assert_tag_id builds the XPath needed to find that for_"sale" sign. Here's
    what it builds for libxml:

    descendant-or-self::form[ @class = "for_&quot;sale &quot;" ]

    Yet that doesn't hit the sample XML. No error message, but no hit either.

    (I'm going thru libxml-ruby, BTW, and Ruby's native REXML has similar
    problems...)

    --
    Phlip

    "Test Driven Ajax (on Rails)"
    assert_xpath, assert_javascri pt, & assert_ajax


  • Bjoern Hoehrmann

    #2
    Re: yet another feeb attempt to escape quotes in XPaths

    * Phlip wrote in comp.text.xml:
    >Try this failing test:
    >
    assert_xml '<html>
    <form class=\'for_"sa le"\' />
    </html>'
    >
    assert_tag_id :form, :class ='for_"sale"'
    >
    >assert_tag_i d builds the XPath needed to find that for_"sale" sign. Here's
    >what it builds for libxml:
    >
    descendant-or-self::form[ @class = "for_&quot;sale &quot;" ]
    >
    >Yet that doesn't hit the sample XML. No error message, but no hit either.
    The entity references would be expanded only inside an XML document like
    a XSLT document, XPath itself has no such mechanism. You would have to
    use ' for the outer quotes

    ...[ @class = 'for_"sale"' ]

    And if you have to nest the quotes, you have to use concat to build the
    string, or variabels if you can.
    --
    Björn Höhrmann · mailto:bjoern@h oehrmann.de · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

    Comment

    • Phlip

      #3
      Re: yet another feeb attempt to escape quotes in XPaths

      Bjoern Hoehrmann wrote:
      And if you have to nest the quotes, you have to use concat to build the
      string, or variabels if you can.
      Tx! I will settle for a sternly worded error message to the user-programmer.
      (-;

      --
      Phlip


      Comment

      Working...