XSL <> converted into &lt; and &gt; in final HTML

Discussion in 'XML' started by Donald Firesmith, Jan 4, 2005.

  1. I am having trouble having Google Adsense code stored in XSL converted
    properly into HTML. The <> unfortunately become &lt; and &gt; and then
    no longer work.

    XSL code is:

    <script type="text/javascript">
    <![CDATA[
    <!--
    google_ad_client = "pub-5065036055322567";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_channel ="";
    google_page_url = document.location;
    google_color_border = "0000FF";
    google_color_bg = "FFFFFF";
    google_color_link = "0000FF";
    google_color_url = "0000FF";
    google_color_text = "000000";
    //-->
    ]]>
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

    Resulting HTML code is:

    <script type="text/javascript">
    &lt;!--
    google_ad_client = "pub-5065036055322567";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_channel ="";
    google_page_url = document.location;
    google_color_border = "0000FF";
    google_color_bg = "FFFFFF";
    google_color_link = "0000FF";
    google_color_url = "0000FF";
    google_color_text = "000000";
    //--&gt;
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

    How do I fix this?

    I get a similar problem when I try to have an XML description containing
    html tags properly included into the meta description:

    XML:
    <meta name="description">
    <xsl:attribute name="content">
    <xsl:value-of select="definition"/>
    </xsl:attribute>
    </meta>
    </meta>
    XSL:
    <meta name="description">
    <xsl:attribute name="content">
    <xsl:value-of select="definition"/>
    </xsl:attribute>
    </meta>
    Results in HTML:
    <meta name="description" content="
    the &lt;a
    href=&quot;../Activities.html&quot;&gt;activity&lt;/a&gt; consisting of
    the cohesive collection of all
    &lt;a
    href=&quot;../../Tasks/Tasks.html&quot;&gt;tasks&lt;/a&gt; that are
    primarily performed to produce the
    &lt;a
    href=&quot;../../../WorkProducts/RequirementsSet/Requirements/Requirements.html&quot;&gt;requirements&lt;/a&gt;
    and other
    &lt;a
    href=&quot;../../../WorkProducts/RequirementsSet/RequirementsSet.html&quot;&gt;requirements
    work products&lt;/a&gt; for an
    &lt;a
    href=&quot;../../../Endeavors/Endeavors.html&quot;&gt;endeavor

    &lt;/a&gt;"/>

    How do I fix this so that it is properly included?
    Donald Firesmith, Jan 4, 2005
    #1
    1. Advertising

  2. Donald Firesmith

    Joris Gillis Guest

    Hi,
    > I am having trouble having Google Adsense code stored in XSL converted
    > properly into HTML. The <> unfortunately become &lt; and &gt; and then
    > no longer work.


    What you are looking for is a way to disable output escaping.

    > XSL code is:
    >
    > <script type="text/javascript">
    > <![CDATA[
    > <!--
    > google_ad_client = "pub-5065036055322567";
    > google_ad_width = 728;
    > google_ad_height = 90;
    > google_ad_format = "728x90_as";
    > google_ad_channel ="";
    > google_page_url = document.location;
    > google_color_border = "0000FF";
    > google_color_bg = "FFFFFF";
    > google_color_link = "0000FF";
    > google_color_url = "0000FF";
    > google_color_text = "000000";
    > //-->
    > ]]>
    > </script>


    From a (X)HTML point of view, I think this is a better (only valid?) way to include scripts in a document:

    > <script type="text/javascript">
    > <![CDATA[
    > google_ad_client = "pub-5065036055322567";
    > google_ad_width = 728;
    > google_ad_height = 90;
    > google_ad_format = "728x90_as";
    > google_ad_channel ="";
    > google_page_url = document.location;
    > google_color_border = "0000FF";
    > google_color_bg = "FFFFFF";
    > google_color_link = "0000FF";
    > google_color_url = "0000FF";
    > google_color_text = "000000";
    > ]]>
    > </script>



    > Resulting HTML code is:
    > How do I fix this?


    specify the 'cdata-section-elements' attribute:
    <xsl:eek:utput cdata-section-elements="script"/>


    > I get a similar problem when I try to have an XML description containing
    > html tags properly included into the meta description:
    >


    Extract from the XSLT1.0 recommendation:
    "It is an error for output escaping to be disabled for a text node that is used for something other than a text node in the result tree."
    In this case, you try disbaling output escaping on an attribute. It is not possible with XSLT1.0

    > How do I fix this so that it is properly included?

    AFAIK, the output returned is the only valid way to use '<' and '>' in attributes, so there isn't anything to 'fix'.


    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Spread the wiki (http://www.wikipedia.org)
    Joris Gillis, Jan 4, 2005
    #2
    1. Advertising

  3. Donald Firesmith

    Peter Flynn Guest

    Donald Firesmith wrote:

    > I am having trouble having Google Adsense code stored in XSL converted
    > properly into HTML. The <> unfortunately become &lt; and &gt; and then
    > no longer work.


    http://www.ucc.ie/xml/#usecdata

    ///Peter
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
    Peter Flynn, Jan 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sky
    Replies:
    5
    Views:
    521
  2. Martin
    Replies:
    1
    Views:
    5,362
    Scott M.
    Mar 4, 2004
  3. JFCM
    Replies:
    4
    Views:
    5,722
  4. Replies:
    1
    Views:
    3,587
    A. Bolmarcich
    May 27, 2005
  5. Replies:
    5
    Views:
    502
    Chris Uppal
    Nov 17, 2006
Loading...

Share This Page