1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

HtmlDecode in XSLT

Discussion in 'XML & RSS' started by Vijay Anand, Dec 12, 2006.

  1. #1
    Hi,

    We're using a XSLT file to convert a XML into RSS complaint XML.

    The input XML contains an element with HtmlEncoded value like "#&174; " for characters like ® or ™. We want to assign the decoded value to the title element of the RSS feed.

    The problem is that, we need to display the title without any Htmlencoded characters.

    Can anyone give us some examples or pointers on how to achieve HtmlDecode functionality in XSLT language?

    Thanks.
     
    Vijay Anand, Dec 12, 2006 IP
  2. Vijay Anand

    Vijay Anand Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Just wanted to add few more additional details to this post.

    The code snippet of the XSLT file which we are using is as shown below:

    <title> <xsl:value-of select="F[@N='1']"/>
    </title>

    Here we are trying to extract the value of the element with name F & attribute N & attribute value 1.

    The code snippet of the input XML looks like this:

    <F N="1"> Tailor Brand &#174;</F>

    After the transformation, the source of the output is as shown below:

    <title> Tailor Brand &#174; </title>
    However, the same logic is working properly & rendering the ®, when we place it under the <description> tag of the RSS XML. That is,

    <description>
    <xsl:value-of select="F[@N='1']"></xsl:value-of>
    </description>

    Can anyone provide some pointers on how to achieve the Htmldecoding inside the title tag of RSS also ?

    Thanks
     
    Vijay Anand, Dec 14, 2006 IP
  3. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #3
    I think your problem could be related to the encoding attribute of your "output method" for the xsl template. Normally feeds has encoding UTF-8 (<?xml version="1.0" encoding="utf-8"?>), and maybe your xslt has other method (not xml) or encoding like this:
    
    <xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
    
    Code (markup):
     
    ajsa52, Dec 14, 2006 IP
  4. Vijay Anand

    Vijay Anand Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,
    I checked my XSLT file & the statement is as follows:

    <xsl: output method="xml" indent="yes" encoding="UTF-8" />

    Further, the final RSS XML contains the following as its header tag

    <?xml version="1.0" encoding="UTF-8"?>

    Should I include any namespace to the RSS XML root element to recognize these characters as HTML?

    Please enlighten !
    Thanks
     
    Vijay Anand, Dec 16, 2006 IP