Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Content Query Web Part - Format body text

  Asked By: Ahmed    Date: Mar 24    Category: Sharepoint    Views: 4300

I am using the Content Query Web Part (CQWP) to rollup all tasks on
our site collection. I am bringing in additional fields besides
Title. I am bringing in DueDate and Description. I have formatted
all of this with a custom style sheet, but have some fine-tuning to

The problem is when a user posts a task and includes either the
ampersand sign (&) or quote (") this show in the CQWP as & or

The challenge: Who here knows how to format some xsl code to replace
both & with & and " with ".



5 Answers Found

Answer #1    Answered By: Collin Griffith     Answered On: Mar 24

Well... In the time that it took for my problem  to get posted, the
problem is now solved. Thought I would post my answer, for a
developers later use.

The answer: add - disable-output-escaping="yes" in with the rest of
the code.

Answer #2    Answered By: Scott Nelson     Answered On: Mar 24

It is possible to user  the disable-output -escaping option but I have
read this can be dangerous as it is possible to write a malicious script
which would be executed on your server in some circumstances. Now I have
no idea if this is true or not but I did see some discussion about this
somewhere and several of the contributors suggested it could be
dangerous. I searched and eventually found some code  which I have used
and it works very well. However, I am no expert so I just used it as it
was given. I've included the relevant extracts below. However, I can't
find the link to the page but here is the code that I used.

First a recursive function to remove markup. This would be embedded in
your code at a convenient location.

<xsl:template name="removeMarkup">

<xsl:param name="string" />


<xsl:when test="contains($string, '<')">

<xsl:variable name="nextString">

<xsl:call-template name="removeMarkup">

<xsl:with-param name="string"
select="substring-after($string, '>')" />



<xsl:value-of select="concat(substring-before($string,
'<'), $nextString)" />



<xsl:value-of select="$string" />




To use it you would include something like

<xsl:variable name="issueContent">

<xsl:call-template name="removeMarkup">

<xsl:with-param name="string" select="@Issue"/>


In this example I have a column in the custom  lists that I am rolling up
called "Issue". I can then use "issueContent" later in the code to
display the text  with all markup removed.

I did not write this code and never in a month of Sundays would I claim
that I could. I would normally credit the author properly but as I said
I can't find the page where I found this and therefore can't find the
author either. If he or she reads this please accept my apologies for
this omission.

Answer #3    Answered By: Blake Marshall     Answered On: Mar 24

I got a kick out of the posting of the
xsl remove markup template. I have that currently in my itemstyle
sheet and works flawlessly, except it does not convert & into &
and " into ". When you display the description  and a stament
is typed in as - "Information & Technology" it is displayed as -
"Information & Technology" - If you know how to add
that into the RemoveMarkup, please tell me how. The only that we
were able to remove it is to do this:

<td valign="top" colspan="2" style="width: 500px">
<xsl:value-of select="substring($bodyContent,1,70)" disable-
<a href="{$SafeLinkUrl}" mce_href="{$SafeLinkUrl}"
target="{$LinkTarget}" title="{@LinkToolTip}">more</a>)

This is obviously used in a table and $bodyContent is defined as:
<xsl:variable name="bodyContent">
<xsl:call-template name="removeMarkup">
<xsl:with-param name="string" select="@Body"/>

If anybody has any other ideas, please share them.

Answer #4    Answered By: Dwayne Jensen     Answered On: Mar 24

I did have a look but I'm afraid XSLT is
inexplicable to me. Having spent most of a lifetime writing code  in
assembler, fortran, simula, bcpl, C and C++ it is depressing that
nearing the end of my working life we seem to be reverting to languages
that look more like Elliot autocode than something that looks like it
belongs in the 21st century. Come to think if it Elliot Autocode was
quite understandable compared to xslt. I guess I could read a book on it
but then again perhaps a beer would be better.

Answer #5    Answered By: Jose Baker     Answered On: Mar 24

I call XSLT the Yoda language of our industry.

Didn't find what you were looking for? Find more on Content Query Web Part - Format body text Or get search suggestion and latest updates.