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 January 19th, 2007, 03:37 PM
Authorized User
Join Date: Nov 2006
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Default Need "&" and "<!-- -->" in the output


I need in my xml output file something like:

<Tag1 atr1="&abc;def"/>

I tried in my XSL file to use " atr1="&amp;abc;def" " but in the output I get exactly the same thing: ... atr1="&amp;abc;def". I have almost the same problem with " ", since I try to include them in the output file also (like shown above), but I just can't, since the XSL file treats it like a ordinary comment (which makes sense).

I am using XSLT 2.0, XPath 2.0, and I think the latest version of Saxon.

Thank you!

Old January 19th, 2007, 04:41 PM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

To generate a comment in the result tree, use the xsl:comment instruction.

Generating entity references is more difficult, because entity references do not appear as such in the tree data model: this means they can only be produced at serialization time. Generally it's not a good idea to attempt it: ask yourself carefully WHY you want to do this. If you have a really good reason, then you can achieve it using character maps:

<xsl:character-map name="amp">
  <xsl:output-character character="#" string="&amp;"/>

<xsl:output use-character-maps="amp"/>


<xsl:attribute nmae="atr1">#abc;def</xsl:attribute>

Of course you can use any character in place of #, it doesn't have to be ASCII.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old January 19th, 2007, 05:29 PM
Authorized User
Join Date: Nov 2006
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post

Thank you Michael for your constant help!


Similar Threads
Thread Thread Starter Forum Replies Last Post
.Net2 xslt does not like the &lt; "<" - &gt; ">" ismailc XSLT 4 October 11th, 2008 04:40 AM
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
Response.Write output is of <body></body> yoord BOOK: Beginning ASP.NET 1.0 0 October 13th, 2004 07:06 AM
XML from a DB recordset (removal of &lt;&gt;) Thodoris XML 3 July 13th, 2004 12:28 AM

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