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 June 3rd, 2013, 03:17 AM
Authorized User
 
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
Default 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="&lt;" close="&gt;">

Output XML
<mml:mfenced open="<" close="&gt;">

Regards
Bala
 
Old June 3rd, 2013, 07:11 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
Code:
 <xsl:value-of select="@open" disable-output-escaping="yes" />
http://www.w3schools.com/xsl/el_value-of.asp
 
Old June 7th, 2013, 05:36 AM
Authorized User
 
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
Default

already tried this syntax but no use
 
Old June 7th, 2013, 10:41 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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?
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
bonekrusher (June 8th, 2013)
 
Old June 7th, 2013, 01:18 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old June 8th, 2013, 12:59 PM
Authorized User
 
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
Default

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="&amp;#60;" close="&amp;#62;"><mn>123</mn></mfenced></mrow></math></body>
</html>

output:
<mfenced open="<" close="&gt;"></mfenced>

Last edited by priyan24; June 8th, 2013 at 01:20 PM..
 
Old June 8th, 2013, 01:09 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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:
bonekrusher (June 8th, 2013)
 
Old June 8th, 2013, 02:30 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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:
bonekrusher (June 8th, 2013), priyan24 (June 9th, 2013)
 
Old June 9th, 2013, 11:08 AM
Authorized User
 
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
Default

Thanks for the reply





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find the non-ascii character using perl thava Perl 3 November 13th, 2011 10:24 PM
Get Ascii code for a character in XSLT mswin XSLT 8 November 28th, 2008 08:21 AM
character entity into numeric character entity srkumar XSLT 1 November 22nd, 2007 04:53 AM
Get UNICODE or ASCII Value of a character Eyob_the_pro C# 0 January 10th, 2007 03:42 AM
Converting an ASCII character to binary? skyraider Visual Basic 2005 Basics 0 May 7th, 2006 08:20 PM





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