Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:00:43+00:00 2026-05-27T15:00:43+00:00

I have run into a dilemma. In a particular application, I’m receiving XML results

  • 0

I have run into a dilemma. In a particular application, I’m receiving XML results from a SOAP request that look like this:

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
  <env:Header />
  <env:Body>
    <ns1:searchResponse xmlns:ns1='http://url.to.namespace' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
      <ns1:result>&lt;?xml version="1.0"?&gt;&lt;results count="201" returned="201" code="200" msg="successful"&gt;&lt;result order="0"&gt;&lt;dirkey&gt;DK886shn3525&lt;/dirkey&gt;&lt;eid&gt;smith&lt;/eid&gt;&lt;email&gt;smith@me.edu&lt;/email&gt;&lt;fn&gt;Smith&lt;/fn&gt;&lt;ln&gt;Bob&lt;/ln&gt;&lt;wid&gt;859589157&lt;/wid&gt;&lt;score&gt;70&lt;/score&gt;&lt;/result&gt;&lt;result order="1"&gt;&lt;dirkey&gt;DK547fjx6702&lt;/dirkey&gt;&lt;eid&gt;james31&lt;/eid&gt;&lt;email&gt;ta@me.edu&lt;/email&gt;&lt;fn&gt;Tim&lt;/fn&gt;&lt;ln&gt;Allen&lt;/ln&gt;&lt;stu&gt;&lt;lvl&gt;Senior&lt;/lvl&gt;&lt;plans&gt;&lt;plan&gt;Technology Management-B&lt;/plan&gt;&lt;/plans&gt;&lt;contacts&gt;&lt;contact type="permanent"&gt;&lt;city&gt;Salina&lt;/city&gt;&lt;phone&gt;(123) 456-7890&lt;/phone&gt;&lt;postal&gt;67401&lt;/postal&gt;&lt;street1&gt;1111 Main Ln&lt;/street1&gt;&lt;state&gt;KS&lt;/state&gt;&lt;/contact&gt;&lt;/contacts&gt;&lt;/stu&gt;&lt;wid&gt;2222222222&lt;/wid&gt;&lt;score&gt;20&lt;/score&gt;&lt;/result&gt;</ns1:result>
    </ns1:searchResponse>
  </env:Body>
</env:Envelope>

I am most interested in the data contained within the <ns1:result> element. While this might make sense in an HTML world, I need the <ns1:result> text as XML. Intrigued by the possibility of doing this via XSL, I constructed the following stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns1="http://url.to.namespace"
  exclude-result-prefixes="env ns1">

  <xsl:output omit-xml-declaration="yes" indent="yes" method="text" />
  <xsl:strip-space elements="*"/>

  <!-- Template #1 - Identity Transform -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <!-- Template #2 - for all text() nodes, disable output escaping -->
  <xsl:template match="text()">
    <xsl:copy-of select="." disable-output-escaping="yes" />
  </xsl:template>

</xsl:stylesheet>

…which technically does produce what I want:

<?xml version="1.0"?>
<results count="201" returned="201" code="200" msg="successful">
  <result order="0">
    <dirkey>DK886shn3525</dirkey>
    <eid>smith</eid>
    <email>smith@me.edu</email>
    <fn>Bob</fn>
    <ln>Smith</ln>
    <wid>859589157</wid>
    <score>70</score>
  </result>
  <result order="1">
    <dirkey>DK547fjx6702</dirkey>
    <eid>ta</eid>
    <email>ta@me.edu</email>
    <fn>Tim</fn>
    <ln>Allen</ln>
    <stu>
      <lvl>Senior</lvl>
      <plans>
        <plan>Technology Management-B</plan>
      </plans>
      <contacts>
        <contact type="permanent">
          <city>Salina</city>
          <phone>(123) 456-7890</phone>
          <postal>67401</postal>
          <street1>1111 Main Ln</street1>
          <state>KS</state>
        </contact>
      </contacts>
    </stu>
    <wid>2222222222</wid>
    <score>20</score>
  </result>
</results>

However, I’ve heard it said that DOE is the sign of a desperate individual. Indeed, when I try to run this XSLT through an application of ours (one that is designed to transform XML before passing it on to a templating engine), it doesn’t work. I’m guessing that DOE is not implemented in our particular XSL parser…

So, here’s the ultimate question: is there a way in XSLT 1.0 to unescape these entities without using a parser-specific tactic like DOE? My one thought is constructing a method that translates certain escaped characters (e.g., &gt;) into their literal counterparts (>)…but I’m not entirely sure how I’d go about that.

As always, I appreciate your assistance.

P.S. Please, don’t bother telling me how disgusting this output is or how they’ve mangled their document structure; we’ve already tried to get them to change it and that’s not an option. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:00:44+00:00Added an answer on May 27, 2026 at 3:00 pm

    So, here’s the ultimate question: is there a way in XSLT 1.0 to
    unescape these entities without using a parser-specific tactic like
    DOE? My one thought is constructing a method that translates certain
    escaped characters (e.g., >) into their literal counterparts
    (>)…but I’m not entirely sure how I’d go about that.

    There isn’t a pure XSLT way to reconstruct destroyed markup — until XSLT 3.0 (still a W3C working draft) that will xave a standard function parse-xml()

    Until you have XSLT 3.0 available, the safe way to reconstruct destroyed markup is to call an extension function with a similar signature that you have to write yourself.

    This extension function will try to parse its string argument into an instance of XmlDocument and if successful, return back the result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a situation where I want to ensure that a compound
I have run into a problem... I'm trying to use QTKit in an application
I have run into a regex in Perl that seems to be giving me
I have run into a problem with XSLT transformation. I have input XML as
I have run into an interesting bug where it appears that when you select
I have run into an issue that I have yet to be able to
I've run into a dilemma when working with apps that should support a large
I have run into a common dilemma. Many times, our company relies on using
I have run into a problem where a couple of combos that are bound
I have run into an issue with WPF and Commands that are bound to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.