weird xslt characters Options
jason
Posted: Thursday, December 21, 2006 7:52:15 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
I get a ton of 
 in my xslt output. Doesnt' seem to hurt anything but can anyone explain why they are there?

Thanks

Jason
desmo
Posted: Thursday, December 21, 2006 8:16:34 PM

Rank: Aficionado

Joined: 7/19/2006
Posts: 174
Location: NYC
Those are carriage return/line feed characters.

- Mark
jason
Posted: Friday, December 22, 2006 2:18:12 AM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
Why are they in my output? They are right in the middle of lines....not where they would normally be found. And they're not in the source.



Jason
mortenbock
Posted: Friday, December 22, 2006 12:00:42 PM

Rank: Addict

Joined: 7/19/2006
Posts: 820
Location: Århus, Denmark
Can you give an example of the surrounding xslt?

I've seen someone using this to get rid of it:

Code:

<xsl:value-of select="translate(ContentArea, '&#x0d;&#x0a;&#xA;&#9;', '')" disable-output-escaping="yes" />


Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

mortenbock
Posted: Friday, December 22, 2006 12:01:49 PM

Rank: Addict

Joined: 7/19/2006
Posts: 820
Location: Århus, Denmark
hmm... there should be some

&#x0d;&#x0a;&#xA;&#9;

instead of the linebreaks in the code :-)

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

jason
Posted: Friday, December 22, 2006 1:22:14 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
yes, that is the weird part, I don't have them in the source code. It seems to be only where I use a cdata.

This code:

Code:

        <a>
          <xsl:attribute name="id">
            <xsl:value-of select="concat($sMenuName,'link')"/>
          </xsl:attribute>
          <xsl:attribute name="class">
               <![CDATA[main]]>
          </xsl:attribute>
          <xsl:attribute name="href">
          <xsl:value-of select="umbraco.library:NiceUrl(./data[@alias='menuInternalURL'])"/>
          </xsl:attribute>
          <xsl:value-of select="@nodeName"/>
        </a>
 


Outputs:

Code:

<a id="eventslink" class="&#xD;&#xA;            main&#xD;&#xA;          " href="events.aspx">EVENTS</a>


The value in cdata (<![CDATA[main]]>) is not cut-n-paste from elsewhere so I know there are no stray characters. This is just a small example, it seems anywhere I have a cdata, I get the &#xD;&#xA; characters. There is no disable-output-escaping on a cdata .

Thanks


Jason
jason
Posted: Friday, December 22, 2006 1:22:41 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
yes, that is the weird part, I don't have them in the source code. It seems to be only where I use a cdata.

This code:

Code:

        <a>
          <xsl:attribute name="id">
            <xsl:value-of select="concat($sMenuName,'link')"/>
          </xsl:attribute>
          <xsl:attribute name="class">
               <![CDATA[main]]>
          </xsl:attribute>
          <xsl:attribute name="href">
          <xsl:value-of select="umbraco.library:NiceUrl(./data[@alias='menuInternalURL'])"/>
          </xsl:attribute>
          <xsl:value-of select="@nodeName"/>
        </a>
 


Outputs:

Code:

<a id="eventslink" class="&#xD;&#xA;            main&#xD;&#xA;          " href="events.aspx">EVENTS</a>


The value in cdata (<![CDATA[main]]>) is not cut-n-paste from elsewhere so I know there are no stray characters. This is just a small example, it seems anywhere I have a cdata, I get the &#xD;&#xA; characters. There is no disable-output-escaping on a cdata .

Thanks


Jason
jason
Posted: Friday, December 22, 2006 1:23:03 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
yes, that is the weird part, I don't have them in the source code. It seems to be only where I use a cdata.

This code:

Code:

        <a>
          <xsl:attribute name="id">
            <xsl:value-of select="concat($sMenuName,'link')"/>
          </xsl:attribute>
          <xsl:attribute name="class">
               <![CDATA[main] ]>
          </xsl:attribute>
          <xsl:attribute name="href">
          <xsl:value-of select="umbraco.library:NiceUrl(./data[@alias='menuInternalURL'])"/>
          </xsl:attribute>
          <xsl:value-of select="@nodeName"/>
        </a>
 


Outputs:

Code:

<a id="eventslink" class="&#xD;&#xA;            main&#xD;&#xA;          " href="events.aspx">EVENTS</a>


The value in cdata (<![CDATA[main] ]>) is not cut-n-paste from elsewhere so I know there are no stray characters. This is just a small example, it seems anywhere I have a cdata, I get the &#xD;&#xA; characters. There is no disable-output-escaping on a cdata .

Thanks


Jason
jason
Posted: Friday, December 22, 2006 1:25:12 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
That output should look like this:


<a id="eventslink" class="&#xD;&#xA; main&#xD;&#xA; " href="events.aspx">EVENTS</a>


also, I know there shouldn't be an extra space between the ]] on a cdata but the forum editor won't let me submit with a properly formed cdata....even within the code block.



Jason
neehouse
Posted: Friday, December 22, 2006 1:40:25 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,076
Location: Charleston, West Virginia, United States
I think this is the answer you are looking for...

http://neehouse.com/code/xslt/cdata_string_output.aspx

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
neehouse
Posted: Friday, December 22, 2006 1:46:11 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,076
Location: Charleston, West Virginia, United States
I re-read that and see that was not the answer.

In your XSLT, remove the carriage returns from the class attribute, and see if those characters disappear.

Code:
<xsl:attribute name="class"><![CDATA[main] ]></xsl:attribute>


• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
jason
Posted: Friday, December 22, 2006 2:31:36 PM
Rank: Aficionado

Joined: 7/19/2006
Posts: 182
Location: Pittsburgh, Pennsylvania, USA
That was it exactly!!! Too simple...don't I feel stoopid:blush:

Thanks

Jason
neehouse
Posted: Friday, December 22, 2006 3:56:58 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,076
Location: Charleston, West Virginia, United States
Well, it is annoying that xslt sometimes includes the CRLF and sometimes does not, especially when your use to structure in your code.

Glad to help..

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.