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

June 3rd, 2013, 03:17 AM
|
|
Authorized User
|
|
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
|
|
entity < converted as ascii character
I'm using saxon8.jar to do some xml conversion. The problem is while doing conversion an element's attribute value < converted as ascii character. Please advice how to avoid this
Input XML
<mfenced open="<" close=">">
Output XML
<mml:mfenced open="<" close=">">
Regards
Bala
|
|

June 3rd, 2013, 07:11 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
Try
Code:
<xsl:value-of select="@open" disable-output-escaping="yes" />
http://www.w3schools.com/xsl/el_value-of.asp
|
|

June 7th, 2013, 05:36 AM
|
|
Authorized User
|
|
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
|
|
already tried this syntax but no use
|
|

June 7th, 2013, 10:41 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Are you sure this is what is being output? Having an < inside an attribute is not valid XML, so I doubt that the Saxon XSLT processor is generating it. Either you are explicitly telling Saxon to generate invalid XML, or you are not using a property XML serializer to generate your XML from the XSLT processor output.
Perhaps show us the bit of your XSLT which you are having the problem with?
|
|
The Following User Says Thank You to samjudson For This Useful Post:
|
|
|

June 7th, 2013, 01:18 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Please note that the current version of Saxon is 9.5; I don't know which version exactly you are using, but it's rather old.
But I doubt that is the cause of your problem. You need to explain more precisely what your transformation is doing it and how you are running it. Ideally supply all the information needed for someone else to reproduce the problem.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

June 8th, 2013, 12:59 PM
|
|
Authorized User
|
|
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Yes you are correct I'm using saxon8.jar. For your reference code mentioned below.
xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='2.0'>
<xsl:output method="html" encoding="us-ascii" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="mfenced">
<xsl:copy>
<xsl:attribute name="open">
<xsl:value-of select="@open" disable-output-escaping="yes"/>
</xsl:attribute>
<xsl:attribute name="close">
<xsl:value-of select="@close" disable-output-escaping="yes"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
input:
<html>
<head></head>
<body><math><mrow><mfenced open="&#60;" close="&#62;"><mn>123</mn></mfenced></mrow></math></body>
</html>
output:
<mfenced open="<" close=">"></mfenced>
Last edited by priyan24; June 8th, 2013 at 01:20 PM..
|
|

June 8th, 2013, 01:09 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
So which input do you have and which one do you want?
disable-output-escaping does not work in attribute values, as far as I remember.
__________________
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:
|
|
|

June 8th, 2013, 02:30 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
With the HTML output method, "<" is the correct way to output the less-than character: see http://www.w3.org/TR/xslt-xquery-ser.../#HTML_ATTRIBS
disable-output-escaping has no effect on the way attributes are output.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|
The Following 2 Users Say Thank You to mhkay For This Useful Post:
|
|
|

June 9th, 2013, 11:08 AM
|
|
Authorized User
|
|
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Thanks for the reply
|
|
 |