Topic
  • 2 replies
  • Latest Post - ‏2012-10-23T21:24:12Z by SystemAdmin
SystemAdmin
SystemAdmin
746 Posts

Pinned topic Removing enclosing element while preserving markup?

‏2012-10-23T20:34:26Z |
Suppose that I have the following element:

<quote><em>Four score</em> and <b>seven</b> years ago</quote>


What is the best way with XQuery (e.g., with a function) to strip the surrounding element, and wind up with the string:

"<em>Four score</em> and <b>seven</b> years ago"
while preserving the markup?
Updated on 2012-10-23T21:24:12Z at 2012-10-23T21:24:12Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    746 Posts

    Re: Removing enclosing element while preserving markup?

    ‏2012-10-23T20:55:47Z  
    Assuming $q is the quote element, use

    
    $q/node()
    


    This doesn't return a string as requested, it returns a sequence of two element and two text nodes, which will be serialized as the required string if/when you serialize it.
  • SystemAdmin
    SystemAdmin
    746 Posts

    Re: Removing enclosing element while preserving markup?

    ‏2012-10-23T21:24:12Z  
    Assuming $q is the quote element, use

    <pre class="jive-pre"> $q/node() </pre>

    This doesn't return a string as requested, it returns a sequence of two element and two text nodes, which will be serialized as the required string if/when you serialize it.
    Thanks, that worked beautifully.