Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

XSLT Transforms for List Views

  Asked By: Kimberlee    Date: Aug 06    Category: Sharepoint    Views: 1302

As the "guy who knows XSLT" I was asked to help one of my co-workers
with a problem he was encountering in a list view. Specifically, one
of his columns is a multi-view field (semi-colon delimited) and he is
being required to blow this out in a group-by manner. Specifically,
he needs to blow the following:

<Row @item1="Label" @item2="category1;category2;category3;category4"/>

into something more like:

<Row @item1="Label" @item2="category1"/>
<Row @item1="Label" @item2="category2"/>
<Row @item1="Label" @item2="category3"/>
<Row @item1="Label" @item2="category4"/>

Now, in XSLT there are MANY ways to do this, and I've tried three so
far, none of which worked. Let me be more specific. EVERY ONE OF
THEM worked in XMLSpy using its built-in parser, but none worked when
translated into SPD. The three techniques I have tried so far are:

1 - tokenize - This is by far the easiest, but it requires XSLT 2.0
to work, and apparently that's no go for Sharepoint.
2 - double process the nodes by processing the multi-value field into
a $variable and then looping through that in addition to the rows.
This claimed the results coming back from the named template wasn't a
3 - C# method to embedded as a script in the XSLT. This apparently
is a security breach and therefore disallows. Ok, I'll buy that... I
could see how that could be a problem if allowed open ;)

I have not yet tried the Muenchian Method for grouping, since I know
from previous experience that MS tools and XML keys are often
problematic but... that's my next route to try.

So... I'd love it if someone told me I was trying too hard and that
there's a well understood methodology/pattern for this sort of



4 Answers Found

Answer #1    Answered By: Kala Solomon     Answered On: Aug 06

Yeah, unfortunately SharePoint doesn't support xslt  2.0, scripting,

If you use XSLSpy don't forget to set msxml as the default xml  parser.
You might get better results  if you use the DataFormWebPart within
SharePoint Designer and make all required  XSLT manipulations from there.
A recursive template  like the following should get you started towards
the desired result :


Answer #2    Answered By: Madison Clark     Answered On: Aug 06

This does
work for me conceptually, but the problem  it leads to appears to be
inevitable: this is unsortable. In XSLT 2.0 (or perhaps just other
parsers) I can copy the results  of a recursion like this into a
variable and then output the variable sorted... but that isn't doable
using the parser  sharepoint is using. Btw, is it really MSXML (DOM)
or is sharepoint  using the native .Net Parser? I always assumed the
latter, and my latest experience  tends to make me believe it even
more. I spent alot of time learning how to make things work  in
MSXML, and the transition to using .Net's parser basically led me to
stop using XSLT in my solutions.

Answer #3    Answered By: Dhanraj Saxsena     Answered On: Aug 06

To be honest I'm not sure what version of parser  SharePoint is using,
it's a strange animal anyway.
Re sorting:
Did you try to define your Variable and then reference it using

<xsl:variable name="NodeSet" select="msxsl:node-set($Variable)" />

Answer #4    Answered By: Kacie Calhoun     Answered On: Aug 06

That was indeed what I needed to get rid of the node-set error...
only issue now is that those chunks I parsed out recursively don't
seem to want to sort, even when I sort  the variable. I suspect this
is related to the fact that variables are just pointers... and
its "preserving" the original sort order. But definitely I'm much
closer today than I was yesterday when I posted this.

Didn't find what you were looking for? Find more on XSLT Transforms for List Views Or get search suggestion and latest updates.