This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Special characters and XML-to-WML problem


Michael J. Hudson wrote:
> I'm converting an XML file to a WML file
> 
> the problem is I have a <A HREF> tag in the XSLT script that I want
> to end up looking like this in the WML file:
> 
> <A
> HREF="http://myserver.com:8001/addItemToOrder?item_name=CPU&order_id=0&user_name=jdoe">
> 
> The problem with this is the '&' special characters.  In the XSLT
> script, I have to reference them using their entity values: &amp;
> I know how to usually get around this problem, which is using
> the disable-escape-outputing attribute for either <xsl:text>
> ro <xsl:value-of>.  However, this solution only works for text
> inside of elements, never for attribute values.  For some reason, 
> attributes are immune to escaping special characters.  

The usual answer is "you shouldn't ever need an unescaped ampersand in an
SGML or XML-based document, including HTML and WML". This is because the
document is going to have common entities like that replaced with the 
characters they represent during the parsing stage, prior to processing.
This is dictated by the specs for those markup languages. It makes no
difference where the ampersands occur -- they can be in attribute values
or in the character data content of elements.

Do you have an example of a WML application that incorrectly handles
escaped ampersands in attribute values? If so, then you can use SAXON's
saxon:disable-output-escaping extension attribute documented at
http://users.iclway.co.uk/mhkay/saxon/extensions.html, or post-process
your WML to make the appropriate replacements. There are no pure XSLT
options (nor should there be, IMHO), because disable-output-escaping only
applies to text nodes, as you have noted.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]