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

Re: Converting pseudo-tags in attribute to real tags

Subject: Re: Converting pseudo-tags in attribute to real tags
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 22 Aug 2007 15:04:00 +0200
Re:  Converting pseudo-tags in attribute to real tags
Hi Thomas,

Well, it's against my feeling of a good design to have interpreted (stringized, textized) XML or HTML in an attribute or element, but assuming you already have this situation and you want it fixed, here're a couple of ways to solve it:

1.
use d-o-e (short for disable-output-escaping). Many experts on this list will vote against it because of its design flaws, amongst which that a processor is not required to implement it, and that, even if they do, it won't disable the escaping in all situations. Further more, you loose the guarantee of having well-formed XML (or HTML) in the output.


2.
Use character-maps. But this only works with XSLT 2.0, so you'll have to use one of the three currently available XSLT 2.0 processors, of which Saxon is the one that is most complete and compliant currently. If you can go for this solution, I can explain you in a next post how that would look.


3.
Use an extension function. This subject was the subject of many posters these days and it is also in the FAQ. In saxon you can use saxon:parse. In other implementations it may be something else.


4.
Replace the &lt; with a character in the private use area of unicode. Then in the post-process, replace this character with the '<' character.



The most portable is solution nr 2, the most easy is nr 1. Nrs 3 and 4 require a specific processor or the ability to post-process.


Cheers,
-- Abel Braaksma


Thomas Widmann wrote:
Hi there,

I'm fairly new to XSLT (but not to XML processing -- I've been using
Perl's XML::Twig for ages).  So far I've been quite happy with it, but
today I've found a problem that I can't find a solution for -- I've
checked O'Reilly's XSLT and XSLT cookbook, and the FAQ.

My problem is that I have an attribute that looks like this:

<sentence text="this is &lt;b>bold&lt;/b> text"/>

If I do the following:

<xsl:template match="sentence">
	<i>
		<xsl:value-of select="@text"/>
	</i>
</xsl:template>

Then the result obviously is:

<i>this is &lt;b>bold&lt;/b> text</i>

However, I really want the pseudotags within the attribute to become
real tags:

<i>this is <b>bold</b> text</i>

How do I do this?

I hope somebody will be able to help!

Thanks a lot,

Thomas

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.