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 September 20th, 2007, 11:27 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default escaping < char

how do I escape < in my xslt? thanks

 
Old September 20th, 2007, 11:37 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

In fact, using:

<xsl:text disable-output-escaping="yes"><</xsl:text>

I still get wellformedness error.. Any help is appreciated. Thanks

 
Old September 20th, 2007, 11:41 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Try \<



 
Old September 20th, 2007, 11:45 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

XML won't accept < other than as tag construct or inside a CDATA section. Use one of the built in entity references, & l t ; (without the spaces).

--

Joe (Microsoft MVP - XML)
 
Old September 20th, 2007, 11:49 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

joe, by "Use one of the built in entity references, & l t ; (without the spaces).", I don't know what you mean. Could you just give me a code example? Thank you

 
Old September 20th, 2007, 12:22 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

< in any XML document (including XSLT) is written &lt;. In case that doesn't show up in the forum it is four characters, "&", "l", "t", ";".

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

Ahh. thank you. this is better, but still not completely solving my problem. In the output, I need to see the "<" and ">" characters, but instead are seeing "&lt;" and "&gt;".

Am I still missing something here? Thank you so far!

 
Old September 20th, 2007, 01:13 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Why do you need to see < and > in the output? Is it perhaps because you are trying to generate tags "by hand"? That's not the right thing to do in XSLT - if you want to generate an element node, use instructions like xsl:element.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 20th, 2007, 07:30 PM
Registered User
 
Join Date: Sep 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a similiar need but it is to output the following 5 characters: #10; to the result stream. I am writing a SpreadsheetML xslt that needs to put multiple strings in an Excel Cell and have them appear on separate lines within the cell. Here is what Excel generates when I put 3 lines of text to a cell and then save the worksheet as xml.

<Cell ss:StyleID="s62">
  <Data ss:Type="String">ron#10;was #10;here#10;</Data>
</Cell>

I'm trying to do the same thing with xslt.
My real code is:

<Cell ss:StyleID="{$rowStyle}">
  <Data ss:Type="String">
    <xsl:for-each select="msxml:node-set($splitString)/token"> <xsl:value-of select="."/>#10;
    </xsl:for-each>
  </Data>
</Cell>

Instead of getting #10; in the output I get &amp;#10;

Is there a way that I can get what I need or am I trying to do something that can't be done.

Thanks for the help


 
Old September 20th, 2007, 07:37 PM
Registered User
 
Join Date: Sep 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a note on my previous post. In all the places where I entered 5 characters (an ampersand plus #10;) the ampersand disappeared. Now I'm not even sure how to express what the problem is except that where you see #10; I keyed in ampersand#10;






Similar Threads
Thread Thread Starter Forum Replies Last Post
<?javax.xml.transform.disable-output-escaping ?> robbert XSLT 5 January 5th, 2011 07:28 PM
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM
Escaping Ampersand Entities android66 Visual Basic 2005 Basics 2 February 5th, 2005 04:46 AM
Escaping < and > barnaclebarnes XSLT 4 October 5th, 2004 08:56 AM





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