[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Converting entities into string

Subject: RE: Converting entities into string
From: "Robert C. Lyons" <boblyons@xxxxxxxxxx>
Date: Wed, 18 Jul 2001 10:08:24 -0400
convert entities in string
Christian,

The following stylesheet should work:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/DESCR">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
    <xsl:text>&lt;</xsl:text>
    <xsl:value-of select="name(.)"/>
    <xsl:text>&gt;</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>&lt;/</xsl:text>
    <xsl:value-of select="name(.)"/>
    <xsl:text>&gt;</xsl:text>
  </xsl:template>

</xsl:stylesheet>

Hope this helps.

Bob

<sig name    = 'Bob Lyons'
     title   = 'XML Consultant'
     company = 'Unidex, Inc.'
     phone   = '+1-732-975-9877'
     email   = 'boblyons@xxxxxxxxxx'
     url     = 'http://www.unidex.com/'
     product = 'XML Convert: transforms flat files to XML and vice versa' />

-----Original Message-----

Hello list,

i need to convert a xml-file into another xml-file. I ran into this
problem:

Source XML:

<DESCR>
 some text
 <b>
   more text
 </b>
 even more text
</DESCR>

My Target XML should look like:

<DESCR>
 some text
 &lt;b&gt;
   more text
 &lt;/b&gt;
 even more text
</DESCR>

i tried <xsl:copy-of> which gave me a copy of the source. <xsl:copy>
removed the <b>, but I want to keep the information about the <b>, just not
as <b>

In short: how can i convert the '<' and '>' into '&lt;' and '&gt;' easily?

Or is there another solution?

Thanks for your help,
Christian


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.