Strings strings strings strings…


I was just talking to someone internally about this, and thought I should post it:  All of the values that the Data View Web Part get back are strings.  Basically, we just take the values in the XML and display them as they are (in some cases, like with SharePoint data, we can be a little bit smart about how to format these strings, but still, we get it wrong sometimes).


So, what does that mean to you?  It means that if you want your XML data to look a certain way, you need to use either FrontPage's formatting tools, or hand-code some XSLT.


In some cases, hand-coding will be the only way to go.


So in the how to section, I'm going to start posting quick XSLT code snippets to help with some formatting issues.


For example, <xsl:value-of select=”substring-before(@URL, ', ')”/> grabs you everything before the comma in a URL field type.


So if you have a code snippet to share or if you have a question you think might be a Top 10, share it.  I only have about five or six to post for now.


-John


Comments (4)
  1. Ian Morrish says:

    Being an old ASP coder since the NT4 Option Pack beta I have avoided XSL (and FP for that matter) like the plague. That was until wss came out and I was forced to use FrontPage. Now I use FP more than any other app (well, Outlook is still number 1). When I show ASP.Net developers the Data View Web Part (DVWP, hey, I may have created a new acronym) they are blown away. The side effect of the DVWP is that you soon find out that under the covers it is all XSL so I have had to learn it.

    My current favorite is the concat function.

    If I want to append something to the URI I can do it like this

    "><xsl:value-of select="concat(@FileRef, ‘?menu=’, @Menu)"/>

  2. Jim Duncan says:

    Hi John,

    Any tips for using the ddwrt namespace? Specifically the ddwrt:AutoHyperLink function?

    In a list view I converted to XSLT, the multi-line field is like this:

    xsl:value-of disable-output-escaping="yes" select="ddwrt:AutoNewLine(string(@Comment))"

    In this case, hyperlinks in the field value render as plain text. Changing the XSLT to

    xsl:value-of disable-output-escaping="yes" select="ddwrt:AutoHyperLink(string(@Comment),’true’)"

    renders correctly in FrontPage (design and preview) and hyperlinks in the field are ‘linkified’. However, in the browser the links are plain text.

    I would be forever in your debt if you know of a way I could get this to work correctly.

    See the comments section on http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=197 the TinyURL links are not clickable.

    Thanks,

    Jim

  3. John Jansen says:

    Hi Jim,

    I am not seeing the TinyURL part of the above linked discussion, but I don’t think I need to.

    You should just not have to use the AutoHyperLink function.

    Try this:

    xsl:value-of disable-output-escaping="yes" select="@Comment"

    Does that not work for you?

    -John

  4. Mike Walsh says:

    Apologies to both Jim and John. I already incorporated the comments into the main wss FAQ item (and converted the tinyurl links Jim loves to full links while I was at it).

Comments are closed.

Skip to main content