Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 27th, 2007, 02:07 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default XML Transformation - General HTML Issue

Hello,
I am working from XML documents that where html syntax is captured as escape sequences rather than as actual tags. For instance, rather than the html content characterized as:

<a href="http://www.state.gov/ofm/">More about OFM</a>

I get the corresponding escape sequences before and after the href as follows:

&lt;a href="http://www.state.gov/ofm/"&gt;More about OFM&lt;/a&gt;

What do I need to do to pre-process these strings such that all html syntax is properly output (as html tags)? Thanks so much for any assitance.


 
Old February 27th, 2007, 03:04 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Parsing converts &lt; to < and converts < to a node. Conversely, serialization converts nodes to < and converts < to &lt; So if you want your transformation to start with &lt; and end up with <, then you either need to parse it twice and serialize it once, or to parse it once and suppress serialization. The first solution involves extracting the HTML as a string and (re-)parsing it to convert it into nodes, using some kind of extension function (e.g. saxon:parse in Saxon). The second solution involves using disable-output-escaping. d-o-e is usually frowned upon for two reasons: it's often misused, and it's not supported in all environments (for example it doesn't work in Firefox - in fact, it doesn't work in any environment where the result tree isn't serialized). But in this case, other than redesigning the source documents, it may be the best option.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 27th, 2007, 03:42 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Michael, thanks so much as usual. DOE is ok for my purposes, frowned upon or not. Works like a charm. Thanks again






Similar Threads
Thread Thread Starter Forum Replies Last Post
CALS to HTML Transformation RussellKay XSLT 1 May 11th, 2009 06:46 AM
search value of XML element/node in general deean XML 1 June 14th, 2008 03:17 AM
Is XML supports transformation of HTML to XML? zeeonline XSLT 1 July 28th, 2006 05:13 PM
XML to literal HTML Issue kwilliams XSLT 3 October 4th, 2005 08:35 AM
Xml to Xml Transformation using xslt ShaileshShinde XSLT 1 July 20th, 2005 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.