RTF data in secondary data source - InfoPath Dev
in

InfoPath Dev

RTF data in secondary data source

Last post 09-25-2006 10:39 AM by Patrick Halstead. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 04-11-2006 02:25 PM

    RTF data in secondary data source

    Hello,

    unfortunately I had to recognize that I can´t bind a "Rich text control" to a data field in a secondary datasource.

    Actually I have a "ntext" data field in my "SQL Server 2005" database with "rich text formatted" data in it.

    Can anyone show me if there is a way that I can load the "rich text formatted" data in a RTF control in my form with script or even with manged code.

    I have tried many ways but all without success.

    A small sample how I can handle the rtf control in script code or even in managed code would be really appreciated.

    Thank you very much for any help.
    Karsten
  • 04-19-2006 11:12 PM In reply to

    Re: RTF data in secondary data source

    Hi Karsten,
    Thanks for the great idea on a HowTo topic. We have code that does this. Send me e-mail and we'll mail it to you or wait a week and we'll add a HowTo on how to do this.
    Patrick Halstead
    Project Manager at Qdabra
  • 04-20-2006 03:26 PM In reply to

    • Shyam
    • Not Ranked
    • Joined on 08-02-2005
    • Posts 10

    Re: RTF data in secondary data source

    Is the 'ntext' field coming as an attribute or element. I think when we do secondary data connection to DB we will get the columns as attributes, if that is so then you will not be able to convert it to rich text field. If it is coming as element then you can change the schema for that column to accomodate XHTML.
    Shyam
    InfoPath Dev
    India
  • 04-20-2006 04:02 PM In reply to

    Re: RTF data in secondary data source

    Hi Shyam,

    thank you for your efforts to help me.

    I truly have to say that I don´t know if the 'ntext' field is coming as an attribut or element. How can I identify if the data field is an attribute or an element?

    I have defined the secondary data connection in the same way like any other secondary data connection. I have used the wizard in the menu 'Tools, Data connection' and choose SQL server and my appropriate view.

    Is there a way that I can force the 'ntext' field coming as an element so that we can change the schema for that column. But even in this case I would appreciate your help cause I don´t know how to change the schema for that column.

    Hopefully looking forward... ;-))

    BTW: 'Good Night' as it´s late in the night in germany now and I would like to dream about elements and attributes now... ;-))
    Karsten
  • 09-20-2006 12:41 AM In reply to

    Re: RTF data in secondary data source

    Hi, I have the same problem as yours. Did you risolve the problem?????
    Thanks
    Gianca
  • 09-20-2006 01:20 AM In reply to

    Re: RTF data in secondary data source

    Hi gianca,

    I´m sorry to say but the problem is still not resolved by me and my colleagues. In the meantime I have contacted Tim Pash (Infopath MVP)from Microsoft and he was very anxious to help us but the only way that he could suggested by now is -in my opinion- really complicated.
    He has sent me a link where at the bottom of this article is a sample which describe the way to use a webservice to fill the "Rich text control" --- but please have a look for yourself.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/office_infopath_using_datasets.asp

    Please, share your experience with this... I´m very interested

    Regards,
    Karsten
  • 09-21-2006 12:25 AM In reply to

    Re: RTF data in secondary data source

    I can't believe it has been since April. Yikes. OK, I'll ask someone to reply with the code tonight. Sorry for the delay.
    Patrick Halstead
    Project Manager at Qdabra
  • 09-21-2006 11:13 PM In reply to

    Re: RTF data in secondary data source

    Below is a template to convert richtext that has been encoded and stored in a database to XHTML. This has been extracted from a larger transform used on a project which passed richtext fields as strings within an element. The xslt then transformed those nodes into XHTML.

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="no" encoding="utf-8" />

    <xsl:template match="RichTextNode">
    <!-- store in tmp variable and emit below with escaping disabled -->
    <xsl:variable name="tmp">
    <xsl:call-template name="xhtml-decode">
    <xsl:with-param name="text" select="." />
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of disable-output-escaping="yes" select="$tmp" />
    </xsl:template>

    <!-- Replace encoded < > & " ' with unencoded versions for output -->
    <!-- Note: replacement is order dependent -->
    <xsl:template name="xhtml-decode">
    <xsl:param name="text" />
    <xsl:variable name="tmp">
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="to" select="'&'" />
    <xsl:with-param name="from" select="'&amp;'" />
    <xsl:with-param name="value">
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="to" select="concat('&','apos;')" />
    <xsl:with-param name="from" select="'&apos;'" />
    <xsl:with-param name="value">
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="to" select="'"'" />
    <xsl:with-param name="from" select="'&quot;'" />
    <xsl:with-param name="value">
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="to" select="'<'" />
    <xsl:with-param name="from" select="'&lt;'" />
    <xsl:with-param name="value">
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="to" select="'>'" />
    <xsl:with-param name="from" select="'&gt;'" />
    <xsl:with-param name="value" select="$text" />
    </xsl:call-template>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="$tmp" />
    </xsl:template>
    <xsl:template name="replace-substring">
    <xsl:param name="value" />
    <xsl:param name="from" />
    <xsl:param name="to" />
    <xsl:choose>
    <xsl:when test="contains($value,$from)">
    <xsl:value-of select="substring-before($value,$from)" />
    <xsl:value-of select="$to" />
    <xsl:call-template name="replace-substring">
    <xsl:with-param name="value" select="substring-after($value,$from)" />
    <xsl:with-param name="from" select="$from" />
    <xsl:with-param name="to" select="$to" />
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$value" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    </xsl:stylesheet>
  • 09-22-2006 04:41 PM In reply to

    Re: RTF data in secondary data source

    Thanks Jim!!!
    Patrick Halstead
    Project Manager at Qdabra
  • 09-25-2006 03:51 AM In reply to

    Re: RTF data in secondary data source

    Hi Jim and Patrick,

    thank you very much for your efforts to help us.

    I hope that this code will help not only myself but many others cause I know that this is a popular problem in many infopath forums.
    Karsten
  • 09-25-2006 10:39 AM In reply to

    Re: RTF data in secondary data source

    Hi Karsten,
    Thanks. Let us know if you have any problems using the code or if you are going to take a different approach. We have actually used this code in projects so it has been tested, etc. Good luck!
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.