Subject: [xsl] Special Characters display incorrectly in XSL From: "King Wilder" <king@xxxxxxxxxxxxxx> Date: Sun, 17 Mar 2002 19:36:15 -0800 |
I am in a quandry regarding special characters. I grab data from a form and escape special characters using a simple escaping function on &, <, >, ', " and dynamically create an XML string. The problems are many fold... (example is below) 1) After the character is escaped and part of the XML, how do you display it correctly in XSL? 2) When I display an escaped value in a form field such as an escaped-ampersand, it displays as the escaped code, & not &. How do I show just the & in the form field? 3) You'll notice in the XSL example below where the output is not in a form field, I try to separate two fields with a space. Every code I try appears in the browser as the code, not as a space. Any ideas? Essentially, I'd like to know the best most reliable way to escape any and all special characters for XML and database storage, and retrieve those values and display them correctly in any or all mediums, html, pda, phone, etc. I've looked every where and there doesn't seem to be one distinct answer on this. Thanks in advance. King Wilder king@xxxxxxxxxxxxxx ================================================ Content entered in ASP form. Firstname: King Lastname: Wilder Company: Gizmo Beach's & Friends ================================================ ================================================ Dynamically generated XML via ASP forms. <account> <customer firstname="King" lastname="Wilder" company="Gizmo Beach's & Friends" /> </account> (This is ok and I suspect required.) ================================================ ================================================ Display in browser via XSL. <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <table cellspacing="2" cellpadding="2" border="0"> <!-- View as text in browser --> <!-- The space between the names appears as a character (Á) not a space. --> <tr> <td>Name:</td> <td><xsl:value-of select="/account/customer/@firstname"/> <xsl:value-of select="/account/customer/@lastname"/></td> </tr> <!-- The company name appears with the ' and & instead of just the ' and & --> <tr> <td>Company:</td> <td><xsl:value-of select="/account/customer/@company" disable-output-escaping="yes" /></td> </tr> <!-- View in form in browser --> <!-- The same problem occurs in form fields. --> <tr> <td align="right">First name: *</td> <td> <xsl:element name="input"> <xsl:attribute name="TYPE">text</xsl:attribute> <xsl:attribute name="NAME">firstname</xsl:attribute> <xsl:attribute name="ID">firstname</xsl:attribute> <xsl:attribute name="SIZE">30</xsl:attribute> <xsl:attribute name="maxlength">100</xsl:attribute> <xsl:attribute name="CLASS"></xsl:attribute> <xsl:attribute name="VALUE"><xsl:value-of select="/account/customer/@firstname" /></xsl:attribute> </xsl:element> </td> </tr> <tr> <td align="right">Last name: *</td> <td> <xsl:element name="input"> <xsl:attribute name="TYPE">text</xsl:attribute> <xsl:attribute name="NAME">lastname</xsl:attribute> <xsl:attribute name="ID">lastname</xsl:attribute> <xsl:attribute name="SIZE">30</xsl:attribute> <xsl:attribute name="maxlength">100</xsl:attribute> <xsl:attribute name="CLASS"></xsl:attribute> <xsl:attribute name="VALUE"><xsl:value-of select="/account/customer/@lastname" /></xsl:attribute> </xsl:element> </td> </tr> <tr> <td align="right">Company:</td> <td> <xsl:element name="input"> <xsl:attribute name="TYPE">text</xsl:attribute> <xsl:attribute name="NAME">company</xsl:attribute> <xsl:attribute name="ID">company</xsl:attribute> <xsl:attribute name="SIZE">30</xsl:attribute> <xsl:attribute name="maxlength">100</xsl:attribute> <xsl:attribute name="CLASS"></xsl:attribute> <xsl:attribute name="VALUE"><xsl:value-of select="/account/customer/@company" disable-output-escaping="yes" /></xsl:attribute> </xsl:element> </td> </tr> </table> </xsl:template> </xsl:stylesheet> ================================================ King Wilder ------------- Gizmo Beach king@xxxxxxxxxxxxxx www.gizmobeach.com 626 351-4334 ------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] filtering descendent text, Joerg Pietschmann | Thread | RE: [xsl] Special Characters displa, Michael Kay |
[xsl] filtering descendent text nod, Aseef Jamaluddin | Date | RE: [xsl] How to Disable Right Clic, Aradhana Liyanage |
Month |