 |
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
|
|
|

March 20th, 2009, 08:57 AM
|
Registered User
|
|
Join Date: Mar 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
XSLT-escape-sequence
My input xml/xmi file contains special characters like <>,space and " .When i am applying XSLT transform on it these as coming as it is or in some different format like <-><,>->> and "e ->".I need those to come as coresponding symbols like <,> or ".
For space i used normalise-space() for the same and it is ok.Give me some solution for other special symbols.
Mailto:[email protected]
Thanks in advance
|

March 20th, 2009, 09:11 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Please post a relevant sample of your XML input and show us the stylesheet you use and the output you get and the output you want to get.
Do you use XSLT 1.0 or 2.0?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|

March 20th, 2009, 09:12 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
If you want to output "<", then this is probably because you are generating markup rather than text. Remember that XSLT produces a result tree, which is then serialized. If you want markup in the serialized output, you need to generate nodes in the result tree, which you do using instructions such as xsl:element or xsl:comment. Don't try to produce lexical XML markup directly from your XSLT code, that's not how the language is designed to be used.
Perhaps from your description you're in the situation where the input document contains escaped markup, and you want the output to contain unescaped markup. Escaped markup is bad design, but it's used suprisingly often. One solution is to parse the input twice, by using an extension such as saxon:parse(). Another solution is to suppress the escaping of the output using disable-output-escaping="yes". But remember that isn't supported in all environments, it only works where the XML is being serialized, which means for example it doesn't work in Forefox.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|

March 20th, 2009, 09:36 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Well if you want XML output then the output will have to follow XML rules, meaning at least the less-than sign '<' needs to be escaped as '<'. And most serializers do escape the greater-than sign '>' as well.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|

March 20th, 2009, 09:38 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
If you use XSLT 2.0 and you are sure you don't want well-formed XML output then look into character maps in XSLT 2.0: http://www.w3.org/TR/xslt20/#character-maps
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|

March 20th, 2009, 09:40 AM
|
Registered User
|
|
Join Date: Mar 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
As i m new to XSLT serialization could pls give more detail on this?
Quote:
Originally Posted by Martin Honnen
Well if you want XML output then the output will have to follow XML rules, meaning at least the less-than sign '<' needs to be escaped as '<'. And most serializers do escape the greater-than sign '>' as well.
|
Last edited by sunilkswain; March 23rd, 2009 at 11:46 PM..
Reason: more clarity
|

March 20th, 2009, 09:46 AM
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
You seem to use XSLT to transform XML to XML but complain about '<' being escaped as '<' in the result of the XSLT transformation while it has to be that way to have well-formed XML. There is not much you can do about that as long as you want to have XML output. If you don't want/need that then look into character maps, as already suggested.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|

March 23rd, 2009, 03:03 AM
|
Registered User
|
|
Join Date: Mar 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Thanks Mr Martin Honnen and others.
I got the solution through character-map .
Quote:
Originally Posted by Martin Honnen
You seem to use XSLT to transform XML to XML but complain about '<' being escaped as '<' in the result of the XSLT transformation while it has to be that way to have well-formed XML. There is not much you can do about that as long as you want to have XML output. If you don't want/need that then look into character maps, as already suggested.
|
|
|
 |