• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help with entity transformations

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to write an XSL file that transforms XML using the &lt; and &gt; entities to < and >. So for example, if the xml has an element with the text of "&lt;b&gt;", the transformed xml would be "<b>". How can I do this?

Thank you,
Yuriy Zilbergleyt

[ December 08, 2005: Message edited by: Yuriy Zilbergleyt ]
[ December 08, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am going to interpret your question like this:

If an XML document contains the string "<b>" (which would actually have appeared in escaped form in the document as "&lt;b&gt;"), how can I use XSLT to transform that text into the opening tag of a <b> element?

The alternative, that the document contains the string "&lt;b&gt;" (which would have appeared in escaped form in the document as "&amp;lt;b&amp;gt;"), and you want to remove one level of escaping to end up with the string "<b>" (which would appear in the result document in escaped form as "&lt;b&gt;"), seems unlikely.

The answer to my interpretation of the question is to use <xsl:value-of disable-output-escaping="yes">. This will work in most cases, I believe, although technically XSLT is not required to support that attribute. The reason for that is that it makes it possible to produce non-well-formed XML as the output of a transformation. But if you're just producing HTML it should be okay.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul, that's exactly what I needed!

Yuriy Zilbergleyt
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic